From d0fb759153016ffdae37a0139b8bdf9a9f98b0cc Mon Sep 17 00:00:00 2001 From: Simone Rossi Date: Sat, 16 Nov 2019 17:14:08 +0100 Subject: [PATCH] feat: add Mention shortcode to mention people To mention someone, type `{{% mention "username" %}}` where `username` corresponds to a user account in Academic. This will create a link to the user's profile page. Close #1421 --- layouts/shortcodes/mention.html | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 layouts/shortcodes/mention.html diff --git a/layouts/shortcodes/mention.html b/layouts/shortcodes/mention.html new file mode 100644 index 00000000..3eb5e02b --- /dev/null +++ b/layouts/shortcodes/mention.html @@ -0,0 +1,10 @@ +{{- $username := .Get 0 -}} +{{- $username_url := $username | urlize -}} +{{- $taxonomy := "authors" -}} +{{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy $username_url) -}} +{{- $name := $profile_page.Params.name | default ($username|markdownify) -}} +{{- with $profile_page -}} + {{$name}} +{{- else -}} + {{- $name -}} +{{- end -}}