feat: Customize partial to allow for global `ShowCanonicalLinks`
This commit is contained in:
parent
01eb2b2b5c
commit
46739dfefb
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
canonicalURL: http://itsfrommars.blogspot.com/2024/06/hello-world_11.html
|
||||||
|
date: 2024-06-19T09:37:00-07:00
|
||||||
|
description: This is a simple blog post created using the Google API, just to say hello to the world.
|
||||||
|
lastmod: 2024-06-21T13:59:09-07:00
|
||||||
|
title: Hello, world!
|
||||||
|
---
|
||||||
|
|
||||||
|
I created this post from the Google API. Hello, world!
|
|
@ -5,10 +5,12 @@ title: Cross Blogger Showcase
|
||||||
theme: PaperMod
|
theme: PaperMod
|
||||||
|
|
||||||
params:
|
params:
|
||||||
title: Hi, this is a test!
|
description: 'Example Hugo site using Cross Blogger to use Blogger as a headless CMS'
|
||||||
description: "This is a showcase of Cross Blogger, a headless CMS for Hugo."
|
|
||||||
env: production # Enables enhanced SEO
|
env: production # Enables enhanced SEO
|
||||||
|
CanonicalLinkText: "Canonical URLs can optionally be enabled. This post was fetched from"
|
||||||
|
ShowCanonicalLinks: true
|
||||||
profileMode:
|
profileMode:
|
||||||
|
subtitle: 'The blog posts below are fetched from Blogger using Cross Blogger'
|
||||||
enabled: true
|
enabled: true
|
||||||
buttons:
|
buttons:
|
||||||
- name: Blog
|
- name: Blog
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
{{ if and .Params.canonicalURL (or .Params.ShowCanonicalLink site.Params.ShowCanonicalLinks) -}}
|
||||||
|
<!-- https://gohugo.io/functions/urls/parse/ -->
|
||||||
|
{{ $url := urls.Parse .Params.canonicalURL }}
|
||||||
|
<!-- https://gohugo.io/functions/strings/replacere/ -->
|
||||||
|
{{ $urlWithoutScheme := replaceRE "^https?://" "" $url.String }}
|
||||||
|
|
||||||
|
{{- if or .Params.author site.Params.author (.Param "ShowReadingTime") (not .Date.IsZero) .IsTranslated (or .Params.editPost.URL site.Params.editPost.URL) }} | {{- end -}}
|
||||||
|
<span>
|
||||||
|
{{- (site.Params.CanonicalLinkText | default .Params.CanonicalLinkText) | default "Originally published at" -}}
|
||||||
|
<a href="{{ trim .Params.canonicalURL " " }}" title="{{ trim .Params.canonicalURL " " }}" target="_blank" rel="noopener noreferrer">{{ $urlWithoutScheme}}</a>
|
||||||
|
</span>
|
||||||
|
{{- end }}
|
Loading…
Reference in New Issue