diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/niwa.sh | 34 | ||||
| -rw-r--r-- | scripts/publish.el | 38 |
2 files changed, 72 insertions, 0 deletions
diff --git a/scripts/niwa.sh b/scripts/niwa.sh new file mode 100644 index 0000000..623763d --- /dev/null +++ b/scripts/niwa.sh @@ -0,0 +1,34 @@ +#!/usr/bin/bash + +# 配置变量 +GARDEN_DIR="$HOME/niwa" # 项目根目录 +NOTES_DIR="$GARDEN_DIR/notes" # 每篇笔记的目录 +SCRIPTS_DIR="$GARDEN_DIR/scripts" # 脚本文件目录 +PUBLIC_DIR="$GARDEN_DIR/public" # html文件目录 +TEMPLATE_FILE="$GARDEN_DIR/template/template.org" # 模板文件目录 + +# 命令 +COMMAND_NEW="new" # 新建笔记 +COMMAND_BUILD="build" + + +new_note() { + file_name=$1 + cp $TEMPLATE_FILE "$NOTES_DIR/${file_name}.org" && echo "创建笔记成功:$NOTES_DIR/${file_name}.org" + echo "#+EXPORT_FILE_NAME: $PUBLIC_DIR/${file_name}.html" >> "$NOTES_DIR/${file_name}.org" +} + +build() { + emacs --batch \ + -l ~/.config/emacs/lisp/doom.el \ + -l "${SCRIPTS_DIR}/publish.el" \ + --eval "(org-publish-project \"niwa\" t)" +} + +if test $1 = $COMMAND_NEW; then + new_note $2 +fi + +if test $1 = $COMMAND_BUILD; then + build +fi diff --git a/scripts/publish.el b/scripts/publish.el new file mode 100644 index 0000000..3db900f --- /dev/null +++ b/scripts/publish.el @@ -0,0 +1,38 @@ +;;; publish.el +;;; export notes to html +;;;-*- lexical-binding: t; -*- +;; +;; Copyright (C) 2026 Verdant +;; +;; Author: Verdant <i@glowisleme> +;; Maintainer: Verdant <i@glowisle.me> +;; Created: February 02, 2026 +;; Modified: February 02, 2026 +;; Version: 0.0.1 +;; Keywords: abbrev bib c calendar comm convenience data docs emulations extensions faces files frames games hardware help hypermedia i18n internal languages lisp local maint mail matching mouse multimedia news outlines processes terminals tex tools unix vc wp +;; Package-Requires: ((emacs "24.3")) +;; +;; This file is not part of GNU Emacs. +;; +;;; Code: + +(require 'ox-html) +(require 'org) + +(setq org-publish-project-alist + '(("niwa-notes" + :base-directory "~/niwa/notes" + :base-extension "org" + :recursive t + :publishing-directory "~/niwa/public" + :publishing-function org-html-publish-to-html + :with-author nil + :with-creator nil + :section-numbers nil) + + ("niwa" + :components ("niwa-notes")))) + +(provide 'publish) + +;;; publish.el ends here |
