Skip to content

Commit

Permalink
doc: Inline the author.html partial code in the 'Author' doc
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalmodi committed Apr 3, 2022
1 parent fc1fc8c commit 9454948
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion doc/go.mod
Expand Up @@ -4,5 +4,5 @@ go 1.16

require (
github.com/kaushalmodi/hugo-debugprint v0.1.0 // indirect
github.com/kaushalmodi/hugo-onyx-theme v0.6.0 // indirect
github.com/kaushalmodi/hugo-onyx-theme v0.7.0 // indirect
)
4 changes: 2 additions & 2 deletions doc/go.sum
@@ -1,7 +1,7 @@
github.com/julmot/mark.js v0.0.0-20210820195258-8b57fccf976b/go.mod h1:aAyDyl2EhNPiZbFqqURsAmxYwwTHslrIxZErXMO3pJQ=
github.com/kaushalmodi/hugo-debugprint v0.1.0 h1:L8McCoJ0WPkKSRQ0f3j4mMGubIedbOWdLs9Y4/rPGAs=
github.com/kaushalmodi/hugo-debugprint v0.1.0/go.mod h1:vusrDLlGE+4Uc1b4PgM0dI8lJCEqC1o7NjFr8WIfkaQ=
github.com/kaushalmodi/hugo-onyx-theme v0.6.0 h1:8NQPkeBI4c+OBELmftxpJlJuMGbiYD5xCd5WhL6F/7E=
github.com/kaushalmodi/hugo-onyx-theme v0.6.0/go.mod h1:bHX/lQn7AsnQmcdB7XhLUnBUHhG1UxgWHaEaTIXjcq4=
github.com/kaushalmodi/hugo-onyx-theme v0.7.0 h1:bfQtZkuXX0d5R2fb8Y3lHV2DnZZIUNM2FTJvvlujCXQ=
github.com/kaushalmodi/hugo-onyx-theme v0.7.0/go.mod h1:bHX/lQn7AsnQmcdB7XhLUnBUHhG1UxgWHaEaTIXjcq4=
github.com/kaushalmodi/hugo-search-fuse-js v0.4.1/go.mod h1:Wr6gbPat+KW6wReh/hDBykKIWn296FsEkuhojJvHHxw=
github.com/krisk/Fuse v3.2.1+incompatible/go.mod h1:3moWv8rDjwoKic9nwiPLgZjldkbdTAbtzJHCu/Vsj4A=
32 changes: 25 additions & 7 deletions doc/ox-hugo-manual.org
Expand Up @@ -2094,13 +2094,27 @@ Author exporting can be disabled using any of these ways:
The ~author~ front-matter parameter is *always* exported as a
TOML/YAML *list*.
#+end_note
If you already have Hugo posts with the ~author~ front-matter already
set, it is possible that those values exist as single string values
instead of lists.

If so, you can use a snippet like the [[https://github.com/kaushalmodi/hugo-onyx-theme/blob/master/layouts/partials/author.html][~author.html~ partial]] used by
this doc site to parse the ~author~ parameter correctly (whether it's
a plain string or a list of strings).
If you have Hugo posts with the ~author~ front-matter already set, it
is possible that those values exist as single string values instead of
lists.

If so, you can use an ~author.html~ Hugo partial[fn:10] like below to
parse the ~author~ parameter correctly, whether it's a plain string or
a /slice/ (list) of strings.

#+name: code__author_partial
#+caption: ~author.html~ partial code that supports both ~string~ and ~slice~ (list) type ~author~ front-matter
#+begin_src go-html-template
{{ with .Params.author }}
<span class="author">&mdash;
{{ if (reflect.IsSlice .) }}
{{ delimit . ", " }}
{{ else }}
{{ . }}
{{ end }}
</span>
{{ end }}
#+end_src
***** Forcing ~author~ to be a /string/ (alternative 1)
If you are not comfortable with Hugo templates, you can alternatively
force the ~author~ param to be a plain /string/ instead of a /list/,
Expand Down Expand Up @@ -4625,6 +4639,10 @@ Categories,)}}}.
- Code optimization: Use of =org-entry-get= at places instead of
maintaining global variables.
* Footnotes

[fn:10] You can find the same (or similar) ~author.html~ partial used
in the [[https://github.com/kaushalmodi/hugo-onyx-theme][Hugo theme]] used for this doc site.

[fn:9] "figure" is not exactly a proper "Org element". A "figure" is a
standalone figure link in an Org paragraph.

Expand Down
2 changes: 1 addition & 1 deletion doc/srv
@@ -1,5 +1,5 @@
#!/usr/bin/env bash
# Time-stamp: <2022-02-22 11:40:20 kmodi>
# Time-stamp: <2022-04-03 17:28:55 kmodi>

set -euo pipefail # http://redsymbol.net/articles/unofficial-bash-strict-mode
IFS=$'\n\t'
Expand Down

0 comments on commit 9454948

Please sign in to comment.