diff options
| author | tdro <tdro@noreply.example.com> | 2025-03-08 00:00:00 +0000 |
|---|---|---|
| committer | tdro <tdro@noreply.example.com> | 2025-03-08 00:00:00 +0000 |
| commit | 650a28427df7c521cec678c3f8b84b2e3aee505e (patch) | |
| tree | 32410735d2ed28e03bd06298281948e895f54ae0 | |
| parent | 1b71ce4775cbfbc89502f24b322b836c6511b93c (diff) | |
| download | canory-650a28427df7c521cec678c3f8b84b2e3aee505e.tar.gz canory-650a28427df7c521cec678c3f8b84b2e3aee505e.tar.bz2 canory-650a28427df7c521cec678c3f8b84b2e3aee505e.zip | |
themes/default/layouts/partials: Factor out URL normalize
10 files changed, 24 insertions, 19 deletions
diff --git a/themes/default/layouts/_default/_markup/render-image.html b/themes/default/layouts/_default/_markup/render-image.html index 1c0d4ba..018b225 100644 --- a/themes/default/layouts/_default/_markup/render-image.html +++ b/themes/default/layouts/_default/_markup/render-image.html @@ -91,10 +91,10 @@ {{- $href = print ("" | relURL) $source -}} {{- end -}} -{{- $cache = replaceRE `:\/` "://" ($cache | replaceRE `\/+` "/") 1 -}} -{{- $source = replaceRE `:\/` "://" ($source | replaceRE `\/+` "/") 1 -}} -{{- $srcset = replaceRE `:\/` "://" ($srcset | replaceRE `\/+` "/") 1 -}} -{{- $href = replaceRE `:\/` "://" ($href | replaceRE `\/+` "/") 1 -}} +{{- $cache = partial "function-normalize-url.html" $cache -}} +{{- $source = partial "function-normalize-url.html" $source -}} +{{- $srcset = partial "function-normalize-url.html" $srcset -}} +{{- $href = partial "function-normalize-url.html" $href -}} {{- with $caption := $.Title -}} {{- $figcaption = $caption | markdownify -}} diff --git a/themes/default/layouts/_default/rss.xml b/themes/default/layouts/_default/rss.xml index 6fb59f0..a59cedd 100644 --- a/themes/default/layouts/_default/rss.xml +++ b/themes/default/layouts/_default/rss.xml @@ -48,7 +48,7 @@ {{- $filteredPages := partial "function-filters-content.html" .Paginator.Pages -}} -{{- $xsl := replaceRE `:\/` "://" (print ("" | relURL) "/rss.xsl" | replaceRE `\/+` "/") 1 -}} +{{- $xsl := partial "function-normalize-url.html" (print ("" | relURL) "/rss.xsl") -}} {{- printf `<?xml version="1.0" encoding="utf-8" standalone="yes"?>` | safeHTML }} {{ printf `<?xml-stylesheet href=%q type="text/xsl"?>` $xsl | safeHTML }} @@ -67,7 +67,7 @@ <lastBuildDate>{{ $lastBuildDate }}</lastBuildDate> <image> <title>{{ $title }}</title> - <url>{{ replaceRE `:\/` "://" (print $absURL $image | replaceRE `\/+` "/") 1 }}</url> + <url>{{ partial "function-normalize-url.html" (print $absURL $image) }}</url> <link>{{ .Permalink }}</link> </image> @@ -104,7 +104,7 @@ </description> <atom:author> <atom:name>{{ $atomAuthorName }}</atom:name> - <atom:uri>{{ replaceRE `:\/` "://" ($atomAuthorUri | replaceRE `\/+` "/") 1 }}</atom:uri> + <atom:uri>{{ partial "function-normalize-url.html" $atomAuthorUri }}</atom:uri> </atom:author> </item> diff --git a/themes/default/layouts/_default/sitemap.xml b/themes/default/layouts/_default/sitemap.xml index 9b6720a..d78868d 100644 --- a/themes/default/layouts/_default/sitemap.xml +++ b/themes/default/layouts/_default/sitemap.xml @@ -1,4 +1,4 @@ -{{- $xsl := replaceRE `:\/` "://" (print ("" | relURL) "/sitemap.xsl" | replaceRE `\/+` "/") 1 -}} +{{- $xsl := partial "function-normalize-url.html" (print ("" | relURL) "/sitemap.xsl") -}} {{- printf `<?xml version="1.0" encoding="utf-8" standalone="yes"?>` | safeHTML }} {{ printf `<?xml-stylesheet href=%q type="text/xsl"?>` $xsl | safeHTML }} diff --git a/themes/default/layouts/partials/function-normalize-url.html b/themes/default/layouts/partials/function-normalize-url.html new file mode 100644 index 0000000..8cc2892 --- /dev/null +++ b/themes/default/layouts/partials/function-normalize-url.html @@ -0,0 +1,5 @@ +{{- $input := . -}} + +{{- $output := replaceRE `:\/` "://" ($input | replaceRE `\/+` "/") 1 -}} + +{{- return $output -}} diff --git a/themes/default/layouts/partials/function-page-modified.html b/themes/default/layouts/partials/function-page-modified.html index 9f56f6d..959a25a 100644 --- a/themes/default/layouts/partials/function-page-modified.html +++ b/themes/default/layouts/partials/function-page-modified.html @@ -9,7 +9,7 @@ ) $format -}} -{{- $page = replaceRE `:\/` "://" ($page | replaceRE `\/+` "/") 1 -}} +{{- $page = partial "function-normalize-url.html" $page -}} {{- with $pageContext.Page.File -}} {{- $file = print $pageContext.Page.File.Dir $pageContext.Page.File.BaseFileName "." $pageContext.Page.File.Ext -}} diff --git a/themes/default/layouts/partials/gallery-walk.html b/themes/default/layouts/partials/gallery-walk.html index c1e9198..7a0a460 100644 --- a/themes/default/layouts/partials/gallery-walk.html +++ b/themes/default/layouts/partials/gallery-walk.html @@ -12,8 +12,8 @@ "style" (delimit (findRE `(?sU)\s{8}style=".*"` .Content 1) "") "title" (delimit (findRE `(?sU)\s{8}title=".*"` .Content 1) "") "width" (delimit (findRE `(?sU)\s{8}width=".*"` .Content 1) "") - "srcset" (replaceRE `:\/` "://" (delimit (findRE `(?sU)\s{8}srcset=".*"` .Content 1) "" | replaceRE `\/+` "/") 1) - "src" (replaceRE `:\/` "://" (delimit (findRE `(?sU)\s{8}src=".*"` .Content 1) "" | replaceRE `\/+` "/") 1) + "srcset" (partial "function-normalize-url.html" (delimit (findRE `(?sU)\s{8}srcset=".*"` .Content 1) "")) + "src" (partial "function-normalize-url.html" (delimit (findRE `(?sU)\s{8}src=".*"` .Content 1) "")) ) -}} {{- end -}} diff --git a/themes/default/layouts/partials/menu-markdown.html b/themes/default/layouts/partials/menu-markdown.html index bd78f74..00d6ed4 100644 --- a/themes/default/layouts/partials/menu-markdown.html +++ b/themes/default/layouts/partials/menu-markdown.html @@ -4,7 +4,7 @@ {{- $href := print (partial "function-paths.html").markdown "/" $source | relURL -}} {{- $title := .File.LogicalName -}} - {{- $href = replaceRE `:\/` "://" ($href | replaceRE `\/+` "/") 1 -}} + {{- $href = partial "function-normalize-url.html" $href -}} <meta-source> <a href="{{ $href }}" title="{{ $title }}"> diff --git a/themes/default/layouts/partials/navigator.css.html b/themes/default/layouts/partials/navigator.css.html index 3545096..8970510 100644 --- a/themes/default/layouts/partials/navigator.css.html +++ b/themes/default/layouts/partials/navigator.css.html @@ -1,6 +1,6 @@ {{- $href := print ("" | relURL) .Link -}} -{{- $href = replaceRE `:\/` "://" ($href | replaceRE `\/+` "/") 1 -}} +{{- $href = partial "function-normalize-url.html" $href -}} icon-navigator a[href="{{ $href }}"], column-base[position="left"] nav a[href="{{ $href }}"] { diff --git a/themes/default/layouts/partials/video-container.html b/themes/default/layouts/partials/video-container.html index 0463505..20ba3d7 100644 --- a/themes/default/layouts/partials/video-container.html +++ b/themes/default/layouts/partials/video-container.html @@ -57,8 +57,8 @@ {{- $source = .Source -}} {{- end -}} -{{- $cache = replaceRE `:\/` "://" ($cache | replaceRE `\/+` "/") 1 -}} -{{- $source = replaceRE `:\/` "://" ($source | replaceRE `\/+` "/") 1 -}} +{{- $cache = partial "function-normalize-url.html" $cache -}} +{{- $source = partial "function-normalize-url.html" $source -}} <video-container> <video diff --git a/themes/default/layouts/shortcodes/attach.html b/themes/default/layouts/shortcodes/attach.html index f8e78dc..bb552fb 100644 --- a/themes/default/layouts/shortcodes/attach.html +++ b/themes/default/layouts/shortcodes/attach.html @@ -71,10 +71,10 @@ {{- if (in $data "pdf") -}} {{- $type = "application/pdf" -}} {{- end -}} -{{- $cache = replaceRE `:\/` "://" ($cache | replaceRE `\/+` "/") 1 -}} -{{- $canonical = replaceRE `:\/` "://" ($canonical | replaceRE `\/+` "/") 1 -}} -{{- $data = replaceRE `:\/` "://" ($data | replaceRE `\/+` "/") 1 -}} -{{- $url = replaceRE `:\/` "://" ($url | replaceRE `\/+` "/") 1 -}} +{{- $cache = partial "function-normalize-url.html" $cache -}} +{{- $canonical = partial "function-normalize-url.html" $canonical -}} +{{- $data = partial "function-normalize-url.html" $data -}} +{{- $url = partial "function-normalize-url.html" $url -}} <document-attachment title="{{ $title }}"> <object type="{{ $type }}" data="{{ $data }}"> |
