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 <github@jimmycai.com>
This commit is contained in:
Simon Guest 2022-06-09 03:59:23 +12:00 committed by GitHub
parent 0a5cbea10f
commit 955bb8dd7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 1 deletions

View File

@ -231,6 +231,16 @@
border-inline-start: var(--blockquote-border-size) solid var(--card-separator-color); border-inline-start: var(--blockquote-border-size) solid var(--card-separator-color);
padding: 15px calc(var(--card-padding) - var(--blockquote-border-size)); padding: 15px calc(var(--card-padding) - var(--blockquote-border-size));
background-color: var(--blockquote-background-color); background-color: var(--blockquote-background-color);
.cite {
display: block;
text-align: right;
font-size: 0.75em;
a {
text-decoration: underline;
}
}
} }
hr { hr {

View File

@ -40,3 +40,24 @@ Hugo ships with several [Built-in Shortcodes](https://gohugo.io/content-manageme
## Gist Shortcode ## Gist Shortcode
{{< gist spf13 7896402 >}} {{< 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 >}}

View File

@ -0,0 +1,15 @@
<blockquote>
<p>{{ .Inner | markdownify }}</p>
{{- if or (.Get "author") (.Get "source") -}}
<span class="cite"><span></span>
{{- if .Get "author" -}}
<span>
{{- .Get "author" -}}{{- if .Get "source" -}}, {{ end -}}
</span>
{{- end -}}
{{- with .Get "url" -}}<a href="{{ . }}">{{- end -}}
<cite>{{ .Get "source" }}</cite>
{{- if .Get "url" -}}</a>{{- end -}}
</span>
{{- end -}}
</blockquote>