diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 3cd9f54..6b66912 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -27,6 +27,9 @@ and this project adheres to https://semver.org/spec/v2.0.0.html[Semantic Version ** `.icon` has been updated to `.site__icon`. ** `.list` has been updated to `.site__list`. +* Update the icon template. +This is also useful for those who are extensively modifying the theme. + diff --git a/assets/templates/heroicon.svg b/assets/templates/heroicon.svg index beb8f9f..e1d6a96 100644 --- a/assets/templates/heroicon.svg +++ b/assets/templates/heroicon.svg @@ -2,7 +2,8 @@ This template applies an ID to an SVG from the Heroicons set to be used with `` element. */ -}} {{- $match := "^\\s*" }} -{{- $icon := resources.Get (printf "svg/heroicons/24/solid/%s.svg" .) }} -{{- $replaceWith := printf `` . }} +{{- $name := default .id .name }} +{{- $icon := resources.Get (printf "svg/heroicons/24/solid/%s.svg" .id) }} +{{- $replaceWith := printf `` $name }} {{- replaceRE $match $replaceWith $icon.Content | safeHTML -}} diff --git a/assets/templates/simple-icon.svg b/assets/templates/simple-icon.svg index ce81168..d2f6bc6 100644 --- a/assets/templates/simple-icon.svg +++ b/assets/templates/simple-icon.svg @@ -2,8 +2,8 @@ This template applies an ID to an SVG from the Simple Icons set to be used with `` element. */ -}} {{- $match := "\\s*(.*)\\s*" }} -{{- $icon := resources.Get (printf "svg/simple-icons/%s.svg" .) }} -{{- $replaceWith := printf `${2}` . }} +{{- $name := default .id .name }} +{{- $icon := resources.Get (printf "svg/simple-icons/%s.svg" .id) }} +{{- $replaceWith := printf `${2}` $name }} {{- replaceRE $match $replaceWith $icon.Content | safeHTML }} - diff --git a/config.toml b/config.toml index 34eabff..2eb5ab4 100644 --- a/config.toml +++ b/config.toml @@ -1,7 +1,7 @@ [module] [module.hugoVersion] extended = true - min = "0.95.0" + min = "0.110.0" [[module.imports]] path = "github.com/foo-dogsquared/hugo-theme-contentful" diff --git a/layouts/partials/components.html b/layouts/partials/components.html index 1e228ce..98e5924 100644 --- a/layouts/partials/components.html +++ b/layouts/partials/components.html @@ -3,32 +3,30 @@ If the partial is short enough, it should be put here. */ -}} -{{- /* - This is a partial that creates an icon from the icon templates and links them from the created file. - Why not embed the text into the resulting document, you ask? - I just want to save a few kilobytes of the total site weight. :) - - It accepts a dictionary with the specified keys: - - - id - The name of the resource in a specific set. - - output - The output location of the resource relative to the base URL. - It can accept a formatted string (e.g., "icons/brand/%s.svg") where 'id' will be used. - - template - The template file to be used. - It should be relative to the asset directory. -*/ -}} -{{- define "partials/components/icon.html" }} - {{- $icon := . }} - {{- $res := resources.ExecuteAsTemplate (printf $icon.output $icon.id) $icon.id (resources.Get $icon.template) }} - - - -{{- end }} - - {{- /* A partial that aliases the Heroicon template from the icon partial. - It only needs a string of the ID from one of the icons. */ -}} {{- define "partials/components/heroicon.html" }} - {{- partial "components/icon.html" (dict "id" . "output" "icons/generic/%s.svg" "template" "templates/heroicon.svg") }} + {{ $name := default .id .name }} + {{- $res := resources.ExecuteAsTemplate (printf "icons/generic/%s.svg" .id) + (dict "id" .id + "name" $name) + (resources.Get "templates/heroicon.svg") }} + + + {{ end }} + +{{- /* + A partial for easily using icons from Simple Icons set. +*/ -}} +{{- define "partials/components/simple-icon.html" }} + {{ $name := default .id .name }} + {{- $res := resources.ExecuteAsTemplate (printf "icons/brand/%s.svg" .id) + (dict "id" .id + "name" $name) + (resources.Get "templates/simple-icon.svg") }} + + + +{{- end }} diff --git a/layouts/partials/components/post-meta.html b/layouts/partials/components/post-meta.html index 4d99fcf..fee0cd3 100644 --- a/layouts/partials/components/post-meta.html +++ b/layouts/partials/components/post-meta.html @@ -6,7 +6,7 @@