diff options
| author | Francesco Tomaselli <tomaselli.fr@gmail.com> | 2025-04-02 12:19:08 +0200 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-02 12:19:08 +0200 | 
| commit | b8f85832c51ba1ab21700e7b7a674f563b7a2657 (patch) | |
| tree | 5321c0152756c3a13213b03a28cb08427455992c /layouts | |
| parent | 9794243a3ff85aae024d6a8f7439702cc66f3f73 (diff) | |
| parent | c9e49557f43a31b6072035e25f0bbfcd408a1a87 (diff) | |
Merge pull request #112 from crnh/crnh/feature/hooks
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_default/baseof.html | 4 | ||||
| -rw-r--r-- | layouts/partials/footer.html | 3 | ||||
| -rw-r--r-- | layouts/partials/functions/get_hook.html | 19 | ||||
| -rw-r--r-- | layouts/partials/head.html | 5 | 
4 files changed, 30 insertions, 1 deletions
| diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 7a5579d..2decab0 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -24,6 +24,9 @@      </main>    </div> +  {{/* Body end hook */}} +  {{ partial "functions/get_hook.html" (dict "hook" "body_end" "context" .) }} +    <footer>      {{ partial "footer.html" . }}    </footer> @@ -31,7 +34,6 @@    {{ if .Param "math" }}    {{ partialCached "math.html" . }}    {{ end }} -  </body>  <script src="{{ "js/theme-switch.js" | relURL }}"></script> diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 579e50a..cb20f6f 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,5 +1,8 @@  {{ $showFooter := default true .Site.Params.showFooter }}  {{ if $showFooter }} +    {{/* Footer start hook */}} +    {{ partial "functions/get_hook.html" (dict "hook" "footer_start" "context" .) }} +      {{ if not .Site.Params.footerContent }}      <p>Powered by          <a href="https://gohugo.io/">Hugo</a> diff --git a/layouts/partials/functions/get_hook.html b/layouts/partials/functions/get_hook.html new file mode 100644 index 0000000..3e6b4fb --- /dev/null +++ b/layouts/partials/functions/get_hook.html @@ -0,0 +1,19 @@ +{{/*  +    Customize layouts without overwriting files. +    Hooks should be defined in the layouts/partials/hooks directory. +     +    Parameters: +    - hook: The name of the hook to be used. +    - context: The context to be passed to the partial. +*/}} + +{{ $hook := .hook }} +{{ $context := .context }} + +{{ if not (hasSuffix $hook ".html") }} +    {{ $hook = printf "%s.html" $hook }} +{{ end }} + +{{ if fileExists (path.Join "layouts/partials/hooks" $hook) }}    +    {{ partial (path.Join "hooks" $hook) $context }} +{{ end }}
\ No newline at end of file diff --git a/layouts/partials/head.html b/layouts/partials/head.html index 5eea693..f62f983 100644 --- a/layouts/partials/head.html +++ b/layouts/partials/head.html @@ -1,6 +1,9 @@  <meta charset="utf-8">  <meta name="viewport" content="width=device-width"> +{{/* Head start hook */}} +{{ partial "functions/get_hook.html" (dict "hook" "head_start" "context" .) }} +  {{ $faviconPath := (.Site.Params.faviconPath | default "" | absURL) }}  <link rel="icon" type="image/ico" href="{{ $faviconPath }}/favicon.ico"> @@ -46,3 +49,5 @@  {{ end }}  {{ end }} +{{/* Head end hook */}} +{{ partial "functions/get_hook.html" (dict "hook" "head_end" "context" .) }} | 
