aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authoryingyu5658 <i@yingyu5658.me>2026-02-02 23:19:02 +0800
committeryingyu5658 <i@yingyu5658.me>2026-02-02 23:19:02 +0800
commite76b6c6e3dc4500647d3dabf5f05f214b020ca19 (patch)
tree16d733cf6bad041c5bd3f7bb7d2dfc2205aa4a19 /scripts
parent1c4d5a38881b6c7d896b2014ed142957b315f30b (diff)
downloadniwa-e76b6c6e3dc4500647d3dabf5f05f214b020ca19.tar.gz
niwa-e76b6c6e3dc4500647d3dabf5f05f214b020ca19.zip
Initial commit
Diffstat (limited to 'scripts')
-rw-r--r--scripts/niwa.sh34
-rw-r--r--scripts/publish.el38
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