浏览代码

about widget: Allow for multiple organizations (Close #132)

- Remove `organization` and `organization_url` options from config
- Add `organizations = [ {name="Org Name", url=""} ]`
- Continue to support legacy options
- Only show `role` if it is set
George Cushen 7 年之前
父节点
当前提交
b031608ee4
共有 2 个文件被更改,包括 16 次插入3 次删除
  1. 5 2
      exampleSite/config.toml
  2. 11 1
      layouts/partials/widgets/about.html

+ 5 - 2
exampleSite/config.toml

@@ -35,8 +35,11 @@ defaultContentLanguageInSubdir = false
   # Your details.
   name = "Lena Smith"
   role = "Professor of Artificial Intelligence"
-  organization = "Stanford University"
-  organization_url = ""
+
+  # Organizations/Affiliations.
+  #   Separate multiple entries with a comma, using the form: `[ {name="Org1", url=""}, {name="Org2", url=""} ]`.
+  organizations = [ { name = "Stanford University", url = "" } ]
+
   gravatar = false  # Get your avatar from Gravatar.com? (true/false)
   avatar = "portrait.jpg"  # Specify an avatar image (in `static/img/` folder) or delete value to disable avatar.
   email = "test@example.org"

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

@@ -16,7 +16,9 @@
 
       <div class="portrait-title">
         <h2 itemprop="name">{{ $.Site.Params.name }}</h2>
-        <h3 itemprop="jobTitle">{{ $.Site.Params.role }}</h3>
+        {{ with $.Site.Params.role }}<h3 itemprop="jobTitle">{{ . }}</h3>{{ end }}
+
+        {{/* Support legacy `organization` option. */}}
         {{ if $.Site.Params.organization }}
         <h3 itemprop="worksFor" itemscope itemtype="http://schema.org/Organization">
           {{ with $.Site.Params.organization_url }}<a href="{{ . }}" target="_blank" itemprop="url">{{ end }}
@@ -24,6 +26,14 @@
           {{ if $.Site.Params.organization_url }}</a>{{ end }}
         </h3>
         {{ end }}
+
+        {{ range $.Site.Params.organizations }}
+        <h3 itemprop="worksFor" itemscope itemtype="http://schema.org/Organization">
+          {{ with .url }}<a href="{{ . }}" target="_blank" itemprop="url">{{ end }}
+          <span itemprop="name">{{ .name }}</span>
+          {{ if .url }}</a>{{ end }}
+        </h3>
+        {{ end }}
       </div>
 
       <link itemprop="url" href="{{ $.Site.BaseURL }}">