From 9454948ee3d41eb52ce0e2d074b908d2f1d0a14f Mon Sep 17 00:00:00 2001 From: Kaushal Modi Date: Sun, 3 Apr 2022 17:27:13 -0400 Subject: [PATCH] doc: Inline the `author.html` partial code in the 'Author' doc --- doc/go.mod | 2 +- doc/go.sum | 4 ++-- doc/ox-hugo-manual.org | 32 +++++++++++++++++++++++++------- doc/srv | 2 +- 4 files changed, 29 insertions(+), 11 deletions(-) diff --git a/doc/go.mod b/doc/go.mod index 8b238cd8..a50b2a8d 100644 --- a/doc/go.mod +++ b/doc/go.mod @@ -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 ) diff --git a/doc/go.sum b/doc/go.sum index a0b4613c..7a88ee7a 100644 --- a/doc/go.sum +++ b/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= diff --git a/doc/ox-hugo-manual.org b/doc/ox-hugo-manual.org index 1a36bfe0..21751050 100644 --- a/doc/ox-hugo-manual.org +++ b/doc/ox-hugo-manual.org @@ -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 }} + — + {{ if (reflect.IsSlice .) }} + {{ delimit . ", " }} + {{ else }} + {{ . }} + {{ end }} + +{{ 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/, @@ -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. diff --git a/doc/srv b/doc/srv index f1e4b7d9..93694d77 100755 --- a/doc/srv +++ b/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'