Ver Fonte

feat: add support for non-ASCII tags, authors, and categories

For example, now Chinese can be used in the names of tags, authors, and categories.

Previously, this was blocked due to bugs in Hugo.

As of Hugo v0.65, new functionality for taxonomies was introduced. The Hugo taxonomy feature powers authors, categories, and tags in Academic.

BREAKING CHANGE:
Requires Hugo v0.65+
George Cushen há 5 anos atrás
pai
commit
f78feefee9

+ 75 - 0
exampleSite/content/authors/吳恩達/_index.md

@@ -0,0 +1,75 @@
+---
+# Display name
+title: 吳恩達
+
+# Username (this should match the folder name)
+authors:
+- 吳恩達
+
+# Is this the primary user of the site?
+superuser: false
+
+# Role/position
+role: Professor of Artificial Intelligence
+
+# Organizations/Affiliations
+organizations:
+- name: Stanford University
+  url: ""
+
+# Short bio (displayed in user profile at end of posts)
+bio: My research interests include distributed robotics, mobile computing and programmable matter.
+
+interests:
+- Artificial Intelligence
+- Computational Linguistics
+- Information Retrieval
+
+education:
+  courses:
+  - course: PhD in Artificial Intelligence
+    institution: Stanford University
+    year: 2012
+  - course: MEng in Artificial Intelligence
+    institution: Massachusetts Institute of Technology
+    year: 2009
+  - course: BSc in Artificial Intelligence
+    institution: Massachusetts Institute of Technology
+    year: 2008
+
+# Social/Academic Networking
+# For available icons, see: https://sourcethemes.com/academic/docs/page-builder/#icons
+#   For an email link, use "fas" icon pack, "envelope" icon, and a link in the
+#   form "mailto:your-email@example.com" or "#contact" for contact widget.
+social:
+- icon: envelope
+  icon_pack: fas
+  link: '#contact'  # For a direct email link, use "mailto:test@example.org".
+- icon: twitter
+  icon_pack: fab
+  link: https://twitter.com/GeorgeCushen
+- icon: google-scholar
+  icon_pack: ai
+  link: https://scholar.google.co.uk/citations?user=sIwtMXoAAAAJ
+- icon: github
+  icon_pack: fab
+  link: https://github.com/gcushen
+# Link to a PDF of your resume/CV from the About widget.
+# To enable, copy your resume/CV to `static/files/cv.pdf` and uncomment the lines below.
+# - icon: cv
+#   icon_pack: ai
+#   link: files/cv.pdf
+
+# Enter email to display Gravatar (if Gravatar enabled in Config)
+email: ""
+
+# Organizational groups that you belong to (for People widget)
+#   Set this to `[]` or comment out if you are not using People widget.
+user_groups:
+- Researchers
+- Visitors
+---
+
+吳恩達 is a professor of artificial intelligence at the Stanford AI Lab. His research interests include distributed robotics, mobile computing and programmable matter. He leads the Robotic Neurobiology group, which develops self-reconfiguring robots, systems of self-organizing robots, and mobile sensor networks.
+
+Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed neque elit, tristique placerat feugiat ac, facilisis vitae arcu. Proin eget egestas augue. Praesent ut sem nec arcu pellentesque aliquet. Duis dapibus diam vel metus tempus vulputate.

BIN
exampleSite/content/authors/吳恩達/avatar.jpg


+ 3 - 0
exampleSite/content/post/getting-started/index.md

@@ -4,10 +4,13 @@ subtitle: 'Create a beautifully simple website in under 10 minutes :rocket:'
 summary: Create a beautifully simple website in under 10 minutes.
 authors:
 - admin
+- 吳恩達
 tags:
 - Academic
+- 开源
 categories:
 - Demo
+- 教程
 date: "2016-04-20T00:00:00Z"
 lastmod: "2019-04-17T00:00:00Z"
 featured: false

+ 3 - 3
layouts/partials/page_metadata.html

@@ -53,13 +53,13 @@
   {{ end}}
 
   {{ $taxonomy := "categories" }}
-  {{ with $page.Param $taxonomy }}
+  {{ if $page.Param $taxonomy }}
   <span class="middot-divider"></span>
   <span class="article-categories">
     <i class="fas fa-folder mr-1"></i>
-    {{- range $index, $value := . -}}
+    {{- range $index, $value := ($page.GetTerms $taxonomy) -}}
       {{- if gt $index 0 }}, {{ end -}}
-      <a href="{{ (site.GetPage (printf "/%s/%s" $taxonomy (. | urlize))).RelPermalink }}">{{ . }}</a>
+      <a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
     {{- end -}}
   </span>
   {{ end }}

+ 7 - 6
layouts/partials/page_metadata_authors.html

@@ -1,17 +1,18 @@
 {{/* Display author list. */}}
 
 {{- $taxonomy := "authors" }}
-{{ with .Param $taxonomy }}
+{{ if .Param $taxonomy }}
   {{ $link_authors := site.Params.link_authors | default true }}
-  {{ range $index, $value := . }}
-    {{- $profile_page := site.GetPage (printf "/%s/%s" $taxonomy (. | urlize)) -}}
-    {{- $name := $profile_page.Title | default ($value|markdownify) -}}
+  {{ range $index, $value := (.GetTerms $taxonomy) }}
+    {{- /* Check if a profile was created for this user. */ -}}
+    {{- $profile_page := isset .Page.Params "superuser" -}}
+
     {{- if gt $index 0 }}, {{ end -}}
     <span>
       {{- if and $profile_page $link_authors -}}
-        <a href="{{$profile_page.RelPermalink}}">{{$name}}</a>
+        <a href="{{.RelPermalink}}">{{ .LinkTitle }}</a>
       {{- else -}}
-        {{$name}}
+        {{ .LinkTitle }}
       {{- end -}}
     </span>
   {{- end -}}

+ 3 - 3
layouts/partials/tags.html

@@ -1,8 +1,8 @@
 {{ $taxonomy := "tags" }}
-{{ with .Param $taxonomy }}
+{{ if .Param $taxonomy }}
 <div class="article-tags">
-  {{ range $index, $value := . }}
-  <a class="badge badge-light" href="{{ (site.GetPage (printf "/%s/%s" $taxonomy (. | urlize))).RelPermalink }}">{{ . }}</a>
+  {{ range $index, $value := (.GetTerms $taxonomy) }}
+  <a class="badge badge-light" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
   {{ end }}
 </div>
 {{ end }}

+ 1 - 1
layouts/partials/widgets/about.html

@@ -8,7 +8,7 @@
   {{ $author = $page.Params.author }}
 {{end}}
 
-{{ $person_page_path := (printf "/authors/%s" (urlize $author)) }}
+{{ $person_page_path := (printf "/authors/%s" $author) }}
 {{ $person_page := site.GetPage $person_page_path }}
 {{ if not $person_page }}
   {{ errorf "Could not find an author page at `%s`. Please check the value of `author` in your About widget and create an associated author page if one does not already exist. See https://sourcethemes.com/academic/docs/page-builder/#about " $person_page_path }}

+ 1 - 1
theme.toml

@@ -3,7 +3,7 @@ license = "MIT"
 licenselink = "https://github.com/gcushen/hugo-academic/blob/master/LICENSE.md"
 description = "The website builder for Hugo. Build *anything* with widgets and deploy with one click! Fully personalize your site with themes, plugins, and language packs."
 homepage = "https://sourcethemes.com/academic/"
-min_version = "0.62"
+min_version = "0.65"
 tags = ["widgets",
         "resume",
         "portfolio",