From 84384062ac4ca08bf4a62d7fa0d41733f23c7a8f Mon Sep 17 00:00:00 2001 From: Duncan Mackenzie Date: Mon, 27 May 2024 18:46:51 -0700 Subject: [PATCH] Updates to oembed code --- .../layouts/_default/baseof.oembed.json | 18 +++++++++--------- .../layouts/_default/oembed.json | 4 ++-- .../layouts/albums/single.oembed.json | 18 +++++++++--------- .../layouts/partials/json-escape.html | 1 + .../layouts/posts/single.oembed.json | 4 ++-- 5 files changed, 23 insertions(+), 22 deletions(-) create mode 100644 themes/hello-friend-ng/layouts/partials/json-escape.html diff --git a/themes/hello-friend-ng/layouts/_default/baseof.oembed.json b/themes/hello-friend-ng/layouts/_default/baseof.oembed.json index a16e952c..3bfb8197 100644 --- a/themes/hello-friend-ng/layouts/_default/baseof.oembed.json +++ b/themes/hello-friend-ng/layouts/_default/baseof.oembed.json @@ -1,10 +1,10 @@ { - "version": "1.0", - "provider_name": "{{ .Site.Title }}", - "provider_url": "{{ .Site.BaseURL }}", - "type": "rich", - "title": "{{ .Title }} | {{ .Site.Title }}", - "url": "{{ .Permalink }}", - "author_name": "{{ if .Params.author }}{{ .Params.author }}{{ else }}Anonymous{{ end }}", - "html": "" - } \ No newline at end of file + "version": "1.0", + "provider_name": "{{ .Site.Title }}", + "provider_url": "{{ .Site.BaseURL }}", + "type": "rich", + "title": "{{ .Title | partial "json-escape" }} | {{ .Site.Title }}", + "url": "{{ .Permalink }}", + "author_name": "{{ if .Params.author }}{{ .Params.author }}{{ else }}Anonymous{{ end }}", + "html": "" +} \ No newline at end of file diff --git a/themes/hello-friend-ng/layouts/_default/oembed.json b/themes/hello-friend-ng/layouts/_default/oembed.json index a16e952c..ae4fb413 100644 --- a/themes/hello-friend-ng/layouts/_default/oembed.json +++ b/themes/hello-friend-ng/layouts/_default/oembed.json @@ -3,8 +3,8 @@ "provider_name": "{{ .Site.Title }}", "provider_url": "{{ .Site.BaseURL }}", "type": "rich", - "title": "{{ .Title }} | {{ .Site.Title }}", + "title": "{{ .Title | partial "json-escape" }} | {{ .Site.Title }}", "url": "{{ .Permalink }}", "author_name": "{{ if .Params.author }}{{ .Params.author }}{{ else }}Anonymous{{ end }}", - "html": "" + "html": "" } \ No newline at end of file diff --git a/themes/hello-friend-ng/layouts/albums/single.oembed.json b/themes/hello-friend-ng/layouts/albums/single.oembed.json index 12867d9a..3bfb8197 100644 --- a/themes/hello-friend-ng/layouts/albums/single.oembed.json +++ b/themes/hello-friend-ng/layouts/albums/single.oembed.json @@ -1,10 +1,10 @@ { - "version": "1.0", - "provider_name": "{{ .Site.Title }}", - "provider_url": "{{ .Site.BaseURL }}", - "type": "rich", - "title": "{{ .Title }} | {{ .Site.Title }}", - "url": "{{ .Permalink }}", - "author_name": "{{ if .Params.author }}{{ .Params.author }}{{ else }}Anonymous{{ end }}", - "html": "" - } \ No newline at end of file + "version": "1.0", + "provider_name": "{{ .Site.Title }}", + "provider_url": "{{ .Site.BaseURL }}", + "type": "rich", + "title": "{{ .Title | partial "json-escape" }} | {{ .Site.Title }}", + "url": "{{ .Permalink }}", + "author_name": "{{ if .Params.author }}{{ .Params.author }}{{ else }}Anonymous{{ end }}", + "html": "" +} \ No newline at end of file diff --git a/themes/hello-friend-ng/layouts/partials/json-escape.html b/themes/hello-friend-ng/layouts/partials/json-escape.html new file mode 100644 index 00000000..aa31ed03 --- /dev/null +++ b/themes/hello-friend-ng/layouts/partials/json-escape.html @@ -0,0 +1 @@ +{{ . | replaceRE `\"` `\"` | safeHTML }} \ No newline at end of file diff --git a/themes/hello-friend-ng/layouts/posts/single.oembed.json b/themes/hello-friend-ng/layouts/posts/single.oembed.json index 47a24fcb..ae4fb413 100644 --- a/themes/hello-friend-ng/layouts/posts/single.oembed.json +++ b/themes/hello-friend-ng/layouts/posts/single.oembed.json @@ -3,8 +3,8 @@ "provider_name": "{{ .Site.Title }}", "provider_url": "{{ .Site.BaseURL }}", "type": "rich", - "title": "{{ .Title }} | {{ .Site.Title }}", + "title": "{{ .Title | partial "json-escape" }} | {{ .Site.Title }}", "url": "{{ .Permalink }}", "author_name": "{{ if .Params.author }}{{ .Params.author }}{{ else }}Anonymous{{ end }}", - "html": "" + "html": "" } \ No newline at end of file