From 955bb8dd7ff445258be80f954581f4c21df4fce0 Mon Sep 17 00:00:00 2001 From: Simon Guest Date: Thu, 9 Jun 2022 03:59:23 +1200 Subject: [PATCH] feat(shortcodes): add quote shortcode, and example (#414) * Add quote shortcode, and example * Use trim to improve whitespace * Allow for quote with neither author nor source * Format code and move quote.scss to article.scss This style is only used on the article page, so it makes more sense to have it there. Co-authored-by: Jimmy Cai --- assets/scss/partials/layout/article.scss | 10 ++++++++ .../content/post/rich-content/index.md | 23 ++++++++++++++++++- layouts/shortcodes/quote.html | 15 ++++++++++++ 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 layouts/shortcodes/quote.html diff --git a/assets/scss/partials/layout/article.scss b/assets/scss/partials/layout/article.scss index d789e10..ce2dc48 100644 --- a/assets/scss/partials/layout/article.scss +++ b/assets/scss/partials/layout/article.scss @@ -231,6 +231,16 @@ border-inline-start: var(--blockquote-border-size) solid var(--card-separator-color); padding: 15px calc(var(--card-padding) - var(--blockquote-border-size)); background-color: var(--blockquote-background-color); + + .cite { + display: block; + text-align: right; + font-size: 0.75em; + + a { + text-decoration: underline; + } + } } hr { diff --git a/exampleSite/content/post/rich-content/index.md b/exampleSite/content/post/rich-content/index.md index f2b45db..1d45fba 100644 --- a/exampleSite/content/post/rich-content/index.md +++ b/exampleSite/content/post/rich-content/index.md @@ -39,4 +39,25 @@ Hugo ships with several [Built-in Shortcodes](https://gohugo.io/content-manageme ## Gist Shortcode -{{< gist spf13 7896402 >}} \ No newline at end of file +{{< gist spf13 7896402 >}} + +## Quote Shortcode + +Stack adds a `quote` shortcode. For example: + +{{< quote author="A famous person" source="The book they wrote" url="https://en.wikipedia.org/wiki/Book">}} +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +{{< /quote >}} + +{{< quote source="Anonymous book" url="https://en.wikipedia.org/wiki/Book">}} +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +{{< /quote >}} + +{{< quote source="Some book">}} +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +{{< /quote >}} + +{{< quote author="Somebody">}} +Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +{{< /quote >}} + diff --git a/layouts/shortcodes/quote.html b/layouts/shortcodes/quote.html new file mode 100644 index 0000000..09bb07c --- /dev/null +++ b/layouts/shortcodes/quote.html @@ -0,0 +1,15 @@ +
+

{{ .Inner | markdownify }}

+ {{- if or (.Get "author") (.Get "source") -}} + + {{- if .Get "author" -}} + + {{- .Get "author" -}}{{- if .Get "source" -}}, {{ end -}} + + {{- end -}} + {{- with .Get "url" -}}{{- end -}} + {{ .Get "source" }} + {{- if .Get "url" -}}{{- end -}} + + {{- end -}} +
\ No newline at end of file