Просмотр исходного кода

refactor: don't create properties for new pages

Tienson Qin 4 лет назад
Родитель
Сommit
4f6809768b
3 измененных файлов с 9 добавлено и 21 удалено
  1. 1 1
      src/main/frontend/handler.cljs
  2. 2 2
      src/main/frontend/handler/repo.cljs
  3. 6 18
      src/main/frontend/util.cljc

+ 1 - 1
src/main/frontend/handler.cljs

@@ -185,4 +185,4 @@
       (el/listen!))))
 
 (defn stop! []
-  (shortcut/uninstall-shortcuts!))
+  (prn "stop!"))

+ 2 - 2
src/main/frontend/handler/repo.cljs

@@ -119,7 +119,7 @@
            format (state/get-preferred-format repo-url)
            title (date/today)
            file-name (date/journal-title->default title)
-           default-content (util/default-content-with-title format title false)
+           default-content (util/default-content-with-title format)
            template (state/get-journal-template)
            template (if (and template
                              (not (string/blank? template)))
@@ -132,7 +132,7 @@
                      (str default-content template)
 
                      :else
-                     (util/default-content-with-title format title true))
+                     default-content)
            path (str config/default-journals-directory "/" file-name "."
                      (config/get-file-extension format))
            file-path (str "/" path)

+ 6 - 18
src/main/frontend/util.cljc

@@ -1057,24 +1057,12 @@
     keyboard-shortcut))
 
 (defn default-content-with-title
-  ([text-format title]
-   (default-content-with-title text-format title true))
-  ([text-format title new-block?]
-   (let [contents? (= (string/lower-case title) "contents")
-         properties (case (name text-format)
-                      "org"
-                      (format "#+TITLE: %s" title)
-                      "markdown"
-                      (format "---\ntitle: %s\n---" title)
-                      "")
-         new-block (case (name text-format)
-                     "org"
-                     "* "
-
-                     "- ")]
-     (if contents?
-       new-block
-       (str properties "\n\n" (if new-block? new-block))))))
+  [text-format]
+  (case (name text-format)
+    "org"
+    "* "
+
+    "- "))
 
 #?(:cljs
     (defn get-first-block-by-id