From 8a097206fcbf3931614ad0b36a8ad4ddc9679f27 Mon Sep 17 00:00:00 2001 From: tdro Date: Thu, 23 Jun 2022 01:48:06 -0400 Subject: themes/default/layouts: Translate raw into generated content Reuse short code for markdown embeds. --- config.json | 2 +- config.toml | 2 +- config.yaml | 2 +- content/canory/messages/markdown.md | 10 +++++----- content/canory/messages/selfdestruct.md | 6 ++---- .../default/layouts/partials/function-paths-markdown.html | 1 + themes/default/layouts/partials/meta-source.html | 4 +++- themes/default/layouts/shortcodes/markdown.html | 14 ++++++++++++++ 8 files changed, 28 insertions(+), 13 deletions(-) create mode 100644 themes/default/layouts/partials/function-paths-markdown.html create mode 100644 themes/default/layouts/shortcodes/markdown.html diff --git a/config.json b/config.json index 57bbc29..2d23181 100644 --- a/config.json +++ b/config.json @@ -309,7 +309,7 @@ }, { "source": "content", - "target": "static/raw" + "target": "static/data/generates/content" }, { "source": "themes/default/layouts", diff --git a/config.toml b/config.toml index 92d171c..7f78cf4 100644 --- a/config.toml +++ b/config.toml @@ -233,7 +233,7 @@ enableRobotsTXT = true [[module.mounts]] source = "content" - target = "static/raw" + target = "static/data/generates/content" [[module.mounts]] source = "themes/default/layouts" diff --git a/config.yaml b/config.yaml index c7e60dd..0e3f7ca 100644 --- a/config.yaml +++ b/config.yaml @@ -210,7 +210,7 @@ module: target: archetypes - source: content - target: static/raw + target: static/data/generates/content - source: themes/default/layouts target: static/sources/files - source: data diff --git a/content/canory/messages/markdown.md b/content/canory/messages/markdown.md index 2fbffb0..032f5e5 100644 --- a/content/canory/messages/markdown.md +++ b/content/canory/messages/markdown.md @@ -7,9 +7,9 @@ author = "canory" [//]: # "That's a comment alright, hiding in plain sight." -The `metadata` :arrow_up: has a [`raw`](/raw/canory/messages/markdown.md) link -to the [`markdown`](https://www.markdownguide.org/cheat-sheet/) that generates -this message --- might as well show my internals. Casual users will frown, power users -will delight. +The `metadata` :arrow_up: has a link to the raw +[Markdown](https://www.markdownguide.org/cheat-sheet/) file {{< markdown >}} +that generates this message --- might as well show my internals. Casual users +will frown, power users will delight. -{{< self "/raw/canory/messages/markdown.md" >}} +{{< markdown embed=true >}} diff --git a/content/canory/messages/selfdestruct.md b/content/canory/messages/selfdestruct.md index a793638..c4bb726 100644 --- a/content/canory/messages/selfdestruct.md +++ b/content/canory/messages/selfdestruct.md @@ -22,9 +22,7 @@ controversy. This is not to be indexed --- search engine bots {{< smallcaps "shall not pass" >}} (hopefully), neither will this message propogate through `JSON` and `RSS` feeds. -This -[hidden message](/raw/canory/messages/selfdestruct.md "hidden in plain sight") -will only disappear in my timeline because I'm an intergalactic time traveler. - +This {{< markdown title="hidden in plain sight" >}} will only disappear in my +timeline because I'm an intergalactic time traveler. ![Isaac Asimov](/canory/media/internet-is-serious.jpg) diff --git a/themes/default/layouts/partials/function-paths-markdown.html b/themes/default/layouts/partials/function-paths-markdown.html new file mode 100644 index 0000000..ab92b8d --- /dev/null +++ b/themes/default/layouts/partials/function-paths-markdown.html @@ -0,0 +1 @@ +{{ return "data/generates/content" }} diff --git a/themes/default/layouts/partials/meta-source.html b/themes/default/layouts/partials/meta-source.html index c314cdd..a172726 100644 --- a/themes/default/layouts/partials/meta-source.html +++ b/themes/default/layouts/partials/meta-source.html @@ -5,7 +5,9 @@ {{- with .Params.feed.raw -}} {{- else -}} - + {{- end -}} raw diff --git a/themes/default/layouts/shortcodes/markdown.html b/themes/default/layouts/shortcodes/markdown.html new file mode 100644 index 0000000..c40c0b9 --- /dev/null +++ b/themes/default/layouts/shortcodes/markdown.html @@ -0,0 +1,14 @@ +{{- $link := default (print "/" (partial "function-paths-markdown.html") "/" .Page.File ) (.Get "link" | default (.Get 0)) -}} +{{- $name := default (path.Base .Page.File) (.Get "name" | default (.Get 1)) -}} +{{- $title := default "Markdown Embed" (.Get "title" | default (.Get 2)) -}} +{{- $embed := default false (.Get "embed" | default (.Get 3)) -}} + +{{- if $embed -}} + {{ print + "{{< self " + "url=" "\"" $link "\"" " " + "title=" "\"" $title "\"" " " + ">}}" | markdownify }} +{{- else -}} + {{- print "[" $name "]" "(" $link " " "\"" $link "\"" ")" | markdownify -}} +{{- end -}} -- cgit v1.2.3