From e22ba14e6408cca42c707bc5c84c33b69b0c55cb Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Thu, 19 Nov 2020 12:17:17 +0800 Subject: [PATCH] feat: journal file names add custom format support Add `:journal/file-name-format "yyyy_MM_dd"` to the `config.edn`. --- src/main/frontend/date.cljs | 5 ++++- src/main/frontend/state.cljs | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/date.cljs b/src/main/frontend/date.cljs index 9e671e970..016e8c8e2 100644 --- a/src/main/frontend/date.cljs +++ b/src/main/frontend/date.cljs @@ -182,7 +182,10 @@ (defn journal-title->default [journal-title] - (journal-title-> journal-title #(tf/unparse default-journal-title-formatter %))) + (let [formatter (if-let [format (state/get-journal-file-name-format)] + (tf/formatter format) + default-journal-title-formatter)] + (journal-title-> journal-title #(tf/unparse formatter %)))) (defn journal-title->custom-format [journal-title] diff --git a/src/main/frontend/state.cljs b/src/main/frontend/state.cljs index 8e7c23296..d1149f48d 100644 --- a/src/main/frontend/state.cljs +++ b/src/main/frontend/state.cljs @@ -190,6 +190,11 @@ [repo] (:org-mode/insert-file-link? (get-config repo))) +(defn get-journal-file-name-format + [] + (when-let [repo (get-current-repo)] + (:journal/file-name-format (get-config repo)))) + (defn get-preferred-workflow [] (keyword