From 581faa19e7b33497266493af30289c02ecd49018 Mon Sep 17 00:00:00 2001 From: George Cushen Date: Sat, 25 Jan 2020 22:39:22 +0000 Subject: [PATCH] feat: add icon shortcode to render icons within Markdown content See https://sourcethemes.com/academic/docs/writing-markdown-latex/#icons --- .../post/writing-technical-content/index.md | 18 ++++++++++++++++++ layouts/shortcodes/icon.html | 9 +++++++++ 2 files changed, 27 insertions(+) create mode 100644 layouts/shortcodes/icon.html diff --git a/exampleSite/content/post/writing-technical-content/index.md b/exampleSite/content/post/writing-technical-content/index.md index 405a8f04..f0b2934a 100644 --- a/exampleSite/content/post/writing-technical-content/index.md +++ b/exampleSite/content/post/writing-technical-content/index.md @@ -261,4 +261,22 @@ renders as A Markdown aside is useful for displaying notices, hints, or definitions to your readers. {{% /alert %}} +### Icons + +Academic enables you to use a wide range of [icons from _Font Awesome_ and _Academicons_](https://sourcethemes.com/academic/docs/page-builder/#icons) in addition to [emojis](https://sourcethemes.com/academic/docs/writing-markdown-latex/#emojis). + +Here are some examples using the `icon` shortcode to render icons: + +```markdown +{{}} Terminal +{{}} Python +{{}} R +``` + +renders as + +{{< icon name="terminal" pack="fas" >}} Terminal +{{< icon name="python" pack="fab" >}} Python +{{< icon name="r-project" pack="fab" >}} R + ### Did you find this page helpful? Consider sharing it 🙌 diff --git a/layouts/shortcodes/icon.html b/layouts/shortcodes/icon.html new file mode 100644 index 00000000..dc024701 --- /dev/null +++ b/layouts/shortcodes/icon.html @@ -0,0 +1,9 @@ +{{- if (.Get "name") -}} + {{- $icon := .Get "name" -}} + {{- $pack := or (.Get "pack") "fas" -}} + {{- $pack_prefix := $pack -}} + {{- if in (slice "fab" "fas" "far" "fal") $pack -}} + {{- $pack_prefix = "fa" -}} + {{- end -}} + +{{- end -}} \ No newline at end of file