Skip to content

Commit

Permalink
update writing guide
Browse files Browse the repository at this point in the history
  • Loading branch information
sky-bro committed Jan 18, 2023
1 parent a3e43e8 commit 690878d
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 11 deletions.
69 changes: 66 additions & 3 deletions content-org/all-posts.en.org
Expand Up @@ -67,7 +67,7 @@ So instead of editing ~.md~ files under ~content~ folder, now I write ~.org~ fil

** Create new post

Invoking org-capture-templates function, and choose hugo post template, as shown in Figure [[fig:org-capture-template-ox-hugo]]
Invoking org-capture-templates (=SPC o c=) function, and choose hugo post template, as shown in Figure [[fig:org-capture-template-ox-hugo]]

#+CAPTION: creating new post with org-capture-template
#+NAME: fig:org-capture-template-ox-hugo
Expand All @@ -85,6 +85,46 @@ As in [[https://ox-hugo.scripter.co/doc/custom-front-matter/][ox-hugo: Custom Fr
:END:
#+end_src

some important front matters can be stored in your org capture template, here's my template:

#+begin_src emacs-lisp
(defun org-hugo-new-subtree-post-capture-template ()
"Returns `org-capture' template string for new Hugo post.
See `org-capture-templates' for more information."
(let* (;; http://www.holgerschurig.de/en/emacs-blog-from-org-to-hugo/
(date (format-time-string (org-time-stamp-format :long :inactive) (org-current-time)))
(title (read-from-minibuffer "Post Title: ")) ;Prompt to enter the post title
(fname (org-hugo-slug title)))
(mapconcat #'identity
`(
,(concat "\n* TODO " title " :@cat:tag:")
":PROPERTIES:"
,(concat ":EXPORT_HUGO_BUNDLE: " fname)
":EXPORT_FILE_NAME: index"
,(concat ":EXPORT_DATE: " date) ;Enter current date and time
":EXPORT_HUGO_CUSTOM_FRONT_MATTER: :image \"/images/icons/tortoise.png\""
":EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :libraries '(mathjax)"
":EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :description \"this is a description\""
":END:"
"%?\n")
"\n")))
(with-eval-after-load 'org-capture
(setq hugo-content-org-dir "~/git-repo/blog/blog-src/content-org")
(add-to-list 'org-capture-templates
`("pe"
"Hugo Post (en)"
entry
(file ,(expand-file-name "all-posts.en.org" hugo-content-org-dir))
(function org-hugo-new-subtree-post-capture-template)))
(add-to-list 'org-capture-templates
`("pz"
"Hugo Post (zh)"
entry
(file ,(expand-file-name "all-posts.zh.org" hugo-content-org-dir))
(function org-hugo-new-subtree-post-capture-template)))
(add-to-list 'org-capture-templates '("p" "Hugo Post")))
#+end_src

** Code

Inline code with '\equal' or '\tilde': ==echo 123==, ~~echo 456~~
Expand Down Expand Up @@ -117,6 +157,16 @@ You can add caption and name (for referencing purpose: as in figure [[fig:gopher
[[../static/images/icons/gopher001.png]]
#+end_src

You can also paste images from clipboard with org-download[fn:org-download]. I've bind =C-M-y= to paste images, and the pasted image will be stored under path =../static/images/posts/<Level-0-Header-Name>=.

You can customize with the =.dir-locals.el= file:

#+begin_src emacs-lisp
((org-mode . ((org-download-timestamp . "")
(org-download-heading-lvl . 0)
(org-download-image-dir . "../static/images/posts"))))
#+end_src

** Math Support (with MathJax)

We need to have MathJax library in our front matter.
Expand Down Expand Up @@ -163,7 +213,7 @@ It seems that zzo theme does not support math equation referencing and numbering

*** Plantuml

use plantuml[fn:plantuml] to draw...
use plantuml[fn:plantuml] to draw, then =C-c C-c= to tangle the image manually (or just org export if you don't need to customize any attributes), then you can add some attributes to the result (width, name, caption, etc.).

#+begin_src plantuml :file "../static/images/posts/Writing-Guide-Org/first.svg"
title Authentication Sequence
Expand All @@ -173,6 +223,11 @@ use plantuml[fn:plantuml] to draw...
Bob->Alice: Authentication Response
#+end_src

#+CAPTION: this is first.svg
#+NAME: first-svg
#+RESULTS:
[[file:../static/images/posts/Writing-Guide-Org/first.svg]]

** Presentation

** Shortcodes
Expand Down Expand Up @@ -360,7 +415,13 @@ Some Markdown Contents

** References

You can refer to something in the footnote like ox-hugo[fn:ox-hugo].
#+begin_src org
You can refer to something in the footnote like ox-hugo[fn:ox-hugo]
,* Footnotes
[fn:ox-hugo] [[https://ox-hugo.scripter.co/][ox-hugo official site]]
#+end_src

You can refer to something in the footnote like ox-hugo[fn:ox-hugo]

* DONE Org Notes :@notes:org:
CLOSED: [2021-12-06 Mon 21:37]
Expand Down Expand Up @@ -3699,6 +3760,8 @@ Here's a snippet of my i3 configuration. Complete configuration is stored at my

* Footnotes

[fn:org-download] [[https://github.com/abo-abo/org-download][org-download]] facilitates moving images from point A to B.

[fn:plantuml] [[https://plantuml.com/][plantuml official site]]

[fn:zzo-docs] [[https://zzo-docs.vercel.app/zzo/shortcodes/][zzo-docs on shortcodes]]
Expand Down
75 changes: 67 additions & 8 deletions content/en/posts/writing-guide--org-plus-ox-hugo/index.md
Expand Up @@ -16,7 +16,7 @@ So instead of editing `.md` files under `content` folder, now I write `.org` fil

## Create new post {#create-new-post}

Invoking org-capture-templates function, and choose hugo post template, as shown in Figure [1](#figure--fig:org-capture-template-ox-hugo)
Invoking org-capture-templates (`SPC o c`) function, and choose hugo post template, as shown in Figure [1](#figure--fig:org-capture-template-ox-hugo)

<a id="figure--fig:org-capture-template-ox-hugo"></a>

Expand All @@ -35,6 +35,46 @@ As in [ox-hugo: Custom Front-matter Parameters](https://ox-hugo.scripter.co/doc/
:END:
```

some important front matters can be stored in your org capture template, here's my template:

```emacs-lisp
(defun org-hugo-new-subtree-post-capture-template ()
"Returns `org-capture' template string for new Hugo post.
See `org-capture-templates' for more information."
(let* (;; http://www.holgerschurig.de/en/emacs-blog-from-org-to-hugo/
(date (format-time-string (org-time-stamp-format :long :inactive) (org-current-time)))
(title (read-from-minibuffer "Post Title: ")) ;Prompt to enter the post title
(fname (org-hugo-slug title)))
(mapconcat #'identity
`(
,(concat "\n* TODO " title " :@cat:tag:")
":PROPERTIES:"
,(concat ":EXPORT_HUGO_BUNDLE: " fname)
":EXPORT_FILE_NAME: index"
,(concat ":EXPORT_DATE: " date) ;Enter current date and time
":EXPORT_HUGO_CUSTOM_FRONT_MATTER: :image \"/images/icons/tortoise.png\""
":EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :libraries '(mathjax)"
":EXPORT_HUGO_CUSTOM_FRONT_MATTER+: :description \"this is a description\""
":END:"
"%?\n")
"\n")))
(with-eval-after-load 'org-capture
(setq hugo-content-org-dir "~/git-repo/blog/blog-src/content-org")
(add-to-list 'org-capture-templates
`("pe"
"Hugo Post (en)"
entry
(file ,(expand-file-name "all-posts.en.org" hugo-content-org-dir))
(function org-hugo-new-subtree-post-capture-template)))
(add-to-list 'org-capture-templates
`("pz"
"Hugo Post (zh)"
entry
(file ,(expand-file-name "all-posts.zh.org" hugo-content-org-dir))
(function org-hugo-new-subtree-post-capture-template)))
(add-to-list 'org-capture-templates '("p" "Hugo Post")))
```


## Code {#code}

Expand Down Expand Up @@ -68,6 +108,16 @@ You can add caption and name (for referencing purpose: as in figure [2](#figure-
[[../static/images/icons/gopher001.png]]
```

You can also paste images from clipboard with org-download[^fn:1]. I've bind `C-M-y` to paste images, and the pasted image will be stored under path `../static/images/posts/<Level-0-Header-Name>`.

You can customize with the `.dir-locals.el` file:

```emacs-lisp
((org-mode . ((org-download-timestamp . "")
(org-download-heading-lvl . 0)
(org-download-image-dir . "../static/images/posts"))))
```


## Math Support (with MathJax) {#math-support--with-mathjax}

Expand Down Expand Up @@ -117,17 +167,19 @@ It seems that zzo theme does not support math equation referencing and numbering

### Plantuml {#plantuml}

use plantuml[^fn:1] to draw...
use plantuml[^fn:2] to draw, then `C-c C-c` to tangle the image manually (or just org export if you don't need to customize any attributes), then you can add some attributes to the result (width, name, caption, etc.).

<a id="figure--first-svg"></a>

{{< figure src="/images/posts/Writing-Guide-Org/first.svg" >}}
{{< figure src="/images/posts/Writing-Guide-Org/first.svg" caption="<span class=\"figure-number\">Figure 3: </span>this is first.svg" >}}


## Presentation {#presentation}


## Shortcodes {#shortcodes}

> zoo-docs[^fn:2] on short codes
> zoo-docs[^fn:3] on short codes
to use shortcodes as you do in markdown, put it after `#+html:`. Like this:

Expand Down Expand Up @@ -351,8 +403,15 @@ func main() {

## References {#references}

You can refer to something in the footnote like ox-hugo[^fn:3].
```org
You can refer to something in the footnote like ox-hugo[fn:ox-hugo]
* Footnotes
[fn:ox-hugo] [[https://ox-hugo.scripter.co/][ox-hugo official site]]
```

You can refer to something in the footnote like ox-hugo[^fn:4]

[^fn:1]: [plantuml official site](https://plantuml.com/)
[^fn:2]: [zzo-docs on shortcodes](https://zzo-docs.vercel.app/zzo/shortcodes/)
[^fn:3]: [ox-hugo official site](https://ox-hugo.scripter.co/)
[^fn:1]: [org-download](https://github.com/abo-abo/org-download) facilitates moving images from point A to B.
[^fn:2]: [plantuml official site](https://plantuml.com/)
[^fn:3]: [zzo-docs on shortcodes](https://zzo-docs.vercel.app/zzo/shortcodes/)
[^fn:4]: [ox-hugo official site](https://ox-hugo.scripter.co/)

1 comment on commit 690878d

@vercel
Copy link

@vercel vercel bot commented on 690878d Jan 18, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

blog-src – ./

blog-src-ky13.vercel.app
blog-src-git-master-ky13.vercel.app
k4i.top

Please sign in to comment.