2020-11-02 08:53:37 +00:00
|
|
|
{{- /*
|
2021-01-26 16:51:05 +00:00
|
|
|
Here's where all of the inline partials are defined.
|
|
|
|
If the partial is short enough, it should be put here.
|
2020-11-02 08:53:37 +00:00
|
|
|
*/ -}}
|
|
|
|
|
2021-01-26 16:51:05 +00:00
|
|
|
{{- /*
|
|
|
|
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.
|
2021-01-27 16:21:42 +00:00
|
|
|
It can accept a formatted string (e.g., "icons/brand/%s.svg") where 'id' will be used.
|
2021-01-26 16:51:05 +00:00
|
|
|
- template - The template file to be used.
|
2021-01-27 16:21:42 +00:00
|
|
|
It should be relative to the asset directory.
|
2021-01-26 16:51:05 +00:00
|
|
|
*/ -}}
|
2020-11-02 08:53:37 +00:00
|
|
|
{{- define "partials/components/icon.html" }}
|
|
|
|
{{- $icon := . }}
|
|
|
|
{{- $res := resources.ExecuteAsTemplate (printf $icon.output $icon.id) $icon.id (resources.Get $icon.template) }}
|
2021-01-21 01:08:29 +00:00
|
|
|
<svg class="icon">
|
2020-11-02 08:53:37 +00:00
|
|
|
<use href="{{ $res.Permalink }}#{{ $icon.id }}"></use>
|
|
|
|
</svg>
|
|
|
|
{{- end }}
|
|
|
|
|
|
|
|
|
2021-01-26 16:51:05 +00:00
|
|
|
{{- /*
|
|
|
|
A partial that aliases the Heroicon template from the icon partial.
|
|
|
|
It only needs a string of the ID from one of the icons.
|
|
|
|
*/ -}}
|
2020-11-02 08:53:37 +00:00
|
|
|
{{- define "partials/components/heroicon.html" }}
|
|
|
|
{{- partial "components/icon.html" (dict "id" . "output" "icons/generic/%s.svg" "template" "templates/heroicon.svg") }}
|
|
|
|
{{ end }}
|