From 91994df9101b2c2ab01895dc046a9472a5962569 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Sat, 21 Oct 2023 21:46:52 -0500 Subject: [PATCH 1/3] Create markdown output template Further progress is blocked by Hugo feature requests: - https://discourse.gohugo.io/t/render-alternative-output-format-outside-of-leaf-bundle-subdirectory/46968 - https://github.com/gohugoio/hugo/issues/8927 --- exampleSite/hugo.yaml | 3 +++ hugo.yaml | 5 +++++ layouts/_default/single.markdown.md | 9 +++++++++ 3 files changed, 17 insertions(+) create mode 100644 layouts/_default/single.markdown.md diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index 41a4565..72fe519 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -15,6 +15,9 @@ taxonomies: markup: # this just keeps the bobatheme markup styling _merge: deep +outputs: + _merge: deep + params: author: name: bbaovanc diff --git a/hugo.yaml b/hugo.yaml index f24c261..388022c 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -12,6 +12,11 @@ taxonomies: author: authors series: series +outputs: + page: + - html + - markdown + privacy: googleAnalytics: disable: true diff --git a/layouts/_default/single.markdown.md b/layouts/_default/single.markdown.md new file mode 100644 index 0000000..d8f8dd7 --- /dev/null +++ b/layouts/_default/single.markdown.md @@ -0,0 +1,9 @@ +{{ with .File -}} + {{ with (.Path | readFile) -}} + {{ . -}} + {{ else -}} + {{ errorf "file not found: %s" .Path -}} + {{ end -}} +{{ else -}} + {{ errorf "no file available for markdown template?" -}} +{{ end -}} From f34cffb8499753fa683ab5e70ffef0aa842a4a94 Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Tue, 1 Oct 2024 13:28:19 -0500 Subject: [PATCH 2/3] Make markdown output "ugly" This makes it so, for example, `/blog/swapfile-guide` has markdown file at `/blog/swapfile-guide.md` instead of `/blog/swapfile-guide/index.md`. --- exampleSite/hugo.yaml | 3 +++ hugo.yaml | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/exampleSite/hugo.yaml b/exampleSite/hugo.yaml index 72fe519..7c15f91 100644 --- a/exampleSite/hugo.yaml +++ b/exampleSite/hugo.yaml @@ -18,6 +18,9 @@ markup: # this just keeps the bobatheme markup styling outputs: _merge: deep +outputFormats: + _merge: deep + params: author: name: bbaovanc diff --git a/hugo.yaml b/hugo.yaml index 388022c..9fe82d2 100644 --- a/hugo.yaml +++ b/hugo.yaml @@ -17,6 +17,10 @@ outputs: - html - markdown +outputFormats: + markdown: + ugly: true + privacy: googleAnalytics: disable: true From 9b851ce0e458cdb5f8211ba998e38205835bdf8f Mon Sep 17 00:00:00 2001 From: BBaoVanC Date: Tue, 1 Oct 2024 13:29:14 -0500 Subject: [PATCH 3/3] Add "View raw" button to page to view raw markdown code of page --- i18n/en.yaml | 6 ++++++ layouts/partials/page-metadata/item/viewraw.html | 8 ++++++++ layouts/partials/page-metadata/post-full.html | 3 +++ 3 files changed, 17 insertions(+) create mode 100644 layouts/partials/page-metadata/item/viewraw.html diff --git a/i18n/en.yaml b/i18n/en.yaml index b6dff1d..41890c4 100644 --- a/i18n/en.yaml +++ b/i18n/en.yaml @@ -30,6 +30,9 @@ readingtime: edit_history: other: "Edit history" +view_markdown: + other: "View raw" + # Post count no_posts: @@ -67,6 +70,9 @@ aria_rss_link: aria_post_meta_edit_history: other: "link to page edit history" +aria_post_meta_view_markdown: + other: "link to view raw markdown code of page" + aria_post_meta_categories: other: "categories" diff --git a/layouts/partials/page-metadata/item/viewraw.html b/layouts/partials/page-metadata/item/viewraw.html new file mode 100644 index 0000000..4484e05 --- /dev/null +++ b/layouts/partials/page-metadata/item/viewraw.html @@ -0,0 +1,8 @@ +{{ with .OutputFormats.Get "markdown" }} + +{{ end }} diff --git a/layouts/partials/page-metadata/post-full.html b/layouts/partials/page-metadata/post-full.html index 93225bb..bd13f4d 100644 --- a/layouts/partials/page-metadata/post-full.html +++ b/layouts/partials/page-metadata/post-full.html @@ -20,7 +20,10 @@ {{ partial "page-metadata/item/authors.html" . }} {{ partial "page-metadata/item/readingtime.html" . }} {{ partial "page-metadata/item/edithistory.html" . }} + {{ partial "page-metadata/item/viewraw.html" . }} + {{ partial "page-metadata/item/categories.html" . }} + {{ partial "page-metadata/item/tags.html" . }} {{ end }}