|
162 | 162 | {{- $pageURL := .Permalink -}} |
163 | 163 | {{- $webpageId := printf "%s#webpage" $pageURL -}} |
164 | 164 | {{- $webpageName := .Title | default $siteTitle -}} |
| 165 | +{{- $isPostList := or .IsHome (and (eq .Kind "section") (eq .Section "posts")) -}} |
| 166 | +{{- $webpageType := "WebPage" -}} |
| 167 | +{{- if $isPostList -}} |
| 168 | + {{- $webpageType = "CollectionPage" -}} |
| 169 | +{{- end -}} |
165 | 170 | {{- $webpageNode := dict |
166 | | - "@type" "WebPage" |
| 171 | + "@type" $webpageType |
167 | 172 | "@id" $webpageId |
168 | 173 | "url" $pageURL |
169 | 174 | "name" $webpageName |
|
173 | 178 | {{- $webpageNode = merge $webpageNode (dict "inLanguage" $languageCode) -}} |
174 | 179 | {{- end -}} |
175 | 180 |
|
176 | | -{{- $isPostList := or .IsHome (and (eq .Kind "section") (eq .Section "posts")) -}} |
177 | 181 | {{- if $isPostList -}} |
178 | 182 | {{- $pageSize := 5 -}} |
179 | 183 | {{- $posts := where .Site.RegularPages "Section" "posts" -}} |
|
200 | 204 | {{- end -}} |
201 | 205 | {{- end -}} |
202 | 206 |
|
203 | | -{{- $nodes = $nodes | append $webpageNode -}} |
204 | | - |
205 | 207 | {{- if and .IsPage (eq .Section "posts") -}} |
206 | 208 | {{- $imageURL := "" -}} |
207 | 209 | {{- with .Params.cover.image -}} |
|
226 | 228 | "isPartOf" (dict "@id" $blogId) |
227 | 229 | "publisher" (dict "@id" $orgId) |
228 | 230 | -}} |
| 231 | + {{- $postDescription := .Params.description | default .Summary -}} |
| 232 | + {{- if $postDescription -}} |
| 233 | + {{- $blogPosting = merge $blogPosting (dict "description" ($postDescription | plainify | htmlUnescape)) -}} |
| 234 | + {{- end -}} |
| 235 | + {{- with .Params.tags -}} |
| 236 | + {{- if gt (len .) 0 -}} |
| 237 | + {{- $blogPosting = merge $blogPosting (dict "keywords" .) -}} |
| 238 | + {{- end -}} |
| 239 | + {{- end -}} |
229 | 240 | {{- if $personName -}} |
230 | 241 | {{- $blogPosting = merge $blogPosting (dict "author" (dict "@id" $personId)) -}} |
231 | 242 | {{- end -}} |
232 | 243 | {{- if $hasModified -}} |
233 | 244 | {{- $blogPosting = merge $blogPosting (dict "dateModified" (.Lastmod.Format "2006-01-02T15:04:05Z07:00")) -}} |
234 | 245 | {{- end -}} |
235 | 246 | {{- if $imageURL -}} |
236 | | - {{- $blogPosting = merge $blogPosting (dict "image" $imageURL) -}} |
| 247 | + {{- $imageObject := dict "@type" "ImageObject" "url" $imageURL -}} |
| 248 | + {{- with .Params.cover.image -}} |
| 249 | + {{- with $.Resources.GetMatch . -}} |
| 250 | + {{- $imageObject = merge $imageObject (dict "width" .Width "height" .Height) -}} |
| 251 | + {{- end -}} |
| 252 | + {{- end -}} |
| 253 | + {{- $blogPosting = merge $blogPosting (dict "image" $imageObject) -}} |
237 | 254 | {{- end -}} |
| 255 | + {{- $webpageNode = merge $webpageNode (dict "mainEntity" (dict "@id" (printf "%s#article" .Permalink))) -}} |
238 | 256 | {{- $nodes = $nodes | append $blogPosting -}} |
239 | 257 | {{- end -}} |
240 | 258 |
|
| 259 | +{{- $nodes = $nodes | append $webpageNode -}} |
| 260 | + |
241 | 261 | {{- $graph := dict |
242 | 262 | "@context" "https://schema.org" |
243 | 263 | "@graph" $nodes |
|
0 commit comments