Browse Source

fix(layouts/post): add support for after-dark@7 layout refactoring

prevents error as soon as module is set-up

fix #24
Josh Habdas 4 months ago
parent
commit
65de9db9d6
Signed by: Josh Habdas <jhabdas@protonmail.com> GPG Key ID: B148B31154C75A74
2 changed files with 83 additions and 22 deletions
  1. 82
    21
      layouts/post/single.html
  2. 1
    1
      package.json

+ 82
- 21
layouts/post/single.html View File

@@ -1,30 +1,95 @@
1 1
 {{ define "header" }}
2
-  {{ partial "menu.html" . }}
2
+  {{ partial "masthead.html" . }}
3 3
 {{ end }}
4 4
 {{ define "main" }}
5
-  <article itemscope itemtype="http://schema.org/BlogPosting">
5
+  <article itemscope itemtype="https://schema.org/BlogPosting">
6 6
     {{ template "_internal/schema.html" . }}
7 7
     <header>
8
-      <h1 itemprop="headline">{{ .Title }}</h1>
8
+      <h1 itemprop="headline name">{{ .Title }}</h1>
9 9
       <p class="muted">
10 10
         {{ partial "post/meta.html" . }}
11 11
       </p>
12 12
       {{ if .Description }}
13 13
         <blockquote itemprop="description">{{ .Description }}</blockquote>
14 14
       {{ end }}
15
-      {{ if .Resources.GetMatch "header" }}
16
-        {{ $image600 := (.Resources.GetMatch "header").Fill "600x338 q60 Center" }}
17
-        {{ $image900 := (.Resources.GetMatch "header").Fill "900x506 q70 Center" }}
18
-        {{ $image1200 := (.Resources.GetMatch "header").Fill "1200x675 q80 Center" }}
19
-        {{ $image1600 := (.Resources.GetMatch "header").Fill "1600x900 q90 Center" }}
20
-        <img
21
-          alt=""
22
-          class="lazyload blur-up"
23
-          src="{{ $image600.RelPermalink }}"
24
-          data-sizes="auto"
25
-          data-src="{{ $image1200.RelPermalink }}"
26
-          data-srcset="{{ $image600.RelPermalink }} 600w, {{ $image900.RelPermalink }} 900w, {{ $image1200.RelPermalink }} 1200w, {{ $image1600.RelPermalink }} 1600w"
27
-        >
15
+      {{ with $.Resources.GetMatch "header" }}
16
+        {{ $meta_sameas := .Params.meta.sameas }}
17
+        {{ $meta_license := .Params.meta.license }}
18
+        {{ $meta_creator := .Params.meta.creator }}
19
+        {{ $meta_description := .Params.meta.description }}
20
+        {{ $meta_keywords := .Params.meta.keywords }}
21
+        {{ $meta_contentlocation := .Params.meta.contentlocation }}
22
+        {{ $image600 := .Fill "600x338 q60 Center" }}
23
+        {{ $image900 := .Fill "900x506 q70 Center" }}
24
+        {{ $image1200 := .Fill "1200x675 q80 Center" }}
25
+        {{ $image1600 := .Fill "1600x900 q90 Center" }}
26
+        <figure aria-hidden="true" itemscope itemtype="https://schema.org/ImageObject">
27
+          <link itemprop="contentUrl" href="{{ .RelPermalink }}">
28
+          <meta itemprop="encodingFormat" content="{{ .MediaType }}">
29
+          <meta itemprop="name" content="{{ .Name | plainify }}">
30
+          {{ if (urls.Parse $meta_sameas).Host }}
31
+            <link itemprop="sameAs" href="{{ $meta_sameas }}">
32
+          {{ end }}
33
+          {{ if (urls.Parse $meta_license).Host }}
34
+            <link itemprop="license" href="{{ $meta_license }}">
35
+          {{ end }}
36
+          {{ with $meta_keywords }}
37
+            <meta itemprop="keywords" content="{{ delimit . ", " }}">
38
+          {{ end }}
39
+          {{ with $meta_contentlocation }}
40
+            <meta itemprop="contentLocation" content="{{ . | plainify }}">
41
+          {{ end }}
42
+          {{ with $meta_description }}
43
+            <meta itemprop="description" content="{{ . | plainify }}">
44
+          {{ end }}
45
+          <img
46
+            itemprop="thumbnailUrl"
47
+            alt="{{ with $meta_description }}{{ . }}{{ else }}{{ .Name | plainify }}{{ end }}"
48
+            class="lazyload blur-up"
49
+            src="{{ $image600.RelPermalink }}"
50
+            data-sizes="auto"
51
+            data-src="{{ $image1200.RelPermalink }}"
52
+            data-srcset="{{ $image600.RelPermalink }} 600w, {{ $image900.RelPermalink }} 900w, {{ $image1200.RelPermalink }} 1200w, {{ $image1600.RelPermalink }} 1600w"
53
+          >
54
+          {{ if or (not (path.Ext .Title)) (or $meta_creator $meta_sameas) }}
55
+            <style>
56
+              .hack header figure[itemtype*="ImageObject"] {
57
+                position: relative;
58
+              }
59
+              .hack header figure[itemtype*="ImageObject"] figcaption {
60
+                position: absolute;
61
+                bottom: 0;
62
+                right: 0;
63
+                text-align: right;
64
+                padding: 15px;
65
+                font-style: oblique;
66
+                font-size: smaller;
67
+                mix-blend-mode: soft-light;
68
+              }
69
+              .hack header figure[itemtype*="ImageObject"] [itemprop="headline"] {
70
+                font-weight: bold;
71
+              }
72
+            </style>
73
+            <figcaption itemprop="caption">
74
+              {{ if not (path.Ext .Title) }}
75
+                <span itemprop="headline">{{ .Title | plainify }}</span>.
76
+              {{ end }}
77
+              {{ if or $meta_creator $meta_sameas }}
78
+                Photo
79
+                {{ if $meta_creator }}
80
+                  by
81
+                  <span itemprop="creator">
82
+                    {{ $meta_creator | plainify -}}
83
+                  </span>
84
+                {{- end }}
85
+                {{- with (urls.Parse $meta_sameas).Host }}
86
+                  on
87
+                  {{ (strings.TrimSuffix (path.Ext .) .) | title }}
88
+                {{- end }}.
89
+              {{ end }}
90
+            </figcaption>
91
+          {{ end }}
92
+        </figure>
28 93
       {{ end }}
29 94
     </header>
30 95
 
@@ -43,11 +108,6 @@
43 108
     <div itemprop="articleBody">
44 109
       {{ .Content }}
45 110
     </div>
46
-    {{ if .Site.DisqusShortname }}
47
-      <article>
48
-        {{ template "_internal/disqus.html" . }}
49
-      </article>
50
-    {{ end }}
51 111
     <footer>
52 112
       <hr>
53 113
       {{ partial "post/byline.html" . }}
@@ -57,6 +117,7 @@
57 117
 {{ end }}
58 118
 {{ define "footer" }}
59 119
   {{ partial "powered-by.html" . }}
120
+  {{ partial "cookie-disclaimer.html" . }}
60 121
 
61 122
 
62 123
   {{/* NOTE: BEGIN MODULE CUSTOM */}}

+ 1
- 1
package.json View File

@@ -25,7 +25,7 @@
25 25
     "standard-version": "^6.0.1"
26 26
   },
27 27
   "peerDependencies": {
28
-    "after-dark": ">= 6.7.8"
28
+    "after-dark": ">= 7.0.0"
29 29
   },
30 30
   "config": {
31 31
     "commitizen": {

Loading…
Cancel
Save