Преглед на файлове

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
Simone Rossi преди 5 години
родител
ревизия
d0fb759153
променени са 1 файла, в които са добавени 10 реда и са изтрити 0 реда
  1. 10 0
      layouts/shortcodes/mention.html

+ 10 - 0
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 -}}
+  <a href="{{$profile_page.RelPermalink}}">{{$name}}</a>
+{{- else -}}
+  {{- $name -}}
+{{- end -}}