Просмотр исходного кода

feat(talk): add support for event address

Forms part of the transition from Microdata to JSON-LD.

See #413
George Cushen 5 лет назад
Родитель
Сommit
ec4f5a11bf

+ 6 - 0
archetypes/talk/index.md

@@ -5,6 +5,12 @@ title: "{{ replace .Name "-" " " | title }}"
 event:
 event_url:
 location:
+address:
+  street:
+  city:
+  region:
+  postcode:
+  country:
 summary:
 abstract:
 

+ 9 - 1
exampleSite/content/talk/example/index.md

@@ -2,7 +2,15 @@
 title: Example Talk
 event: Academic Theme Conference
 event_url: https://example.org
-location: London, United Kingdom
+
+location: Source Themes HQ
+address:
+  street: 450 Serra Mall
+  city: Stanford
+  region: CA
+  postcode: '94305'
+  country: United States
+
 summary: An example talk using Academic's Markdown slides feature.
 abstract: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis posuere tellusac convallis placerat. Proin tincidunt magna sed ex sollicitudin condimentum. Sed ac faucibus dolor, scelerisque sollicitudin nisi. Cras purus urna, suscipit quis sapien eu, pulvinar tempor diam."
 

+ 10 - 1
layouts/partials/jsonld/event.html

@@ -28,7 +28,16 @@
   {{ with $page.Params.location }}
   "location": {
     "@type": "Place",
-    "name": {{. | plainify}}
+    "name": {{. | plainify}}{{if $page.Params.address}},
+    "address": {
+      "@type": "PostalAddress",
+      "streetAddress": {{$page.Params.address.street | default ""}},
+      "addressLocality": {{$page.Params.address.city | default ""}},
+      "postalCode": {{$page.Params.address.postcode | default ""}},
+      "addressRegion": {{$page.Params.address.region | default ""}},
+      "addressCountry": {{$page.Params.address.country | default ""}}
+    }
+    {{end}}
   },
   {{end}}
   {{ if $featured_image }}

+ 13 - 2
layouts/talk/single.html

@@ -43,13 +43,24 @@
     </div>
     <div class="d-md-none space-below"></div>
 
-    {{ with .Params.location }}
+    {{ if .Params.location }}
     <div class="row">
       <div class="col-md-1"></div>
       <div class="col-md-10">
         <div class="row">
           <div class="col-12 col-md-3 pub-row-heading">{{ i18n "location" }}</div>
-          <div class="col-12 col-md-9">{{ . | markdownify }}</div>
+          <div class="col-12 col-md-9">{{ .Params.location | markdownify }}</div>
+          {{ if .Params.address }}
+            {{ $addr := slice }}
+            {{with .Params.address.street}}{{$addr = $addr | append .}}{{end}}
+            {{with .Params.address.city}}{{$addr = $addr | append .}}{{end}}
+            {{with .Params.address.region}}{{$addr = $addr | append .}}{{end}}
+            {{with .Params.address.postcode}}{{$addr = $addr | append .}}{{end}}
+            {{with .Params.address.country}}{{$addr = $addr | append .}}{{end}}
+            {{ $addr_formatted := delimit $addr (site.Params.address_delimiter | default ", ") }}
+            <div class="col-md-3"></div>
+            <div class="col-12 col-md-9">{{$addr_formatted}}</div>
+          {{end}}
         </div>
       </div>
       <div class="col-md-1"></div>