summaryrefslogtreecommitdiff
path: root/layouts/partials/functions
diff options
context:
space:
mode:
authorFrancesco Tomaselli <tomaselli.fr@gmail.com>2025-04-02 12:19:08 +0200
committerGitHub <noreply@github.com>2025-04-02 12:19:08 +0200
commitb8f85832c51ba1ab21700e7b7a674f563b7a2657 (patch)
tree5321c0152756c3a13213b03a28cb08427455992c /layouts/partials/functions
parent9794243a3ff85aae024d6a8f7439702cc66f3f73 (diff)
parentc9e49557f43a31b6072035e25f0bbfcd408a1a87 (diff)
Merge pull request #112 from crnh/crnh/feature/hooks
Diffstat (limited to 'layouts/partials/functions')
-rw-r--r--layouts/partials/functions/get_hook.html19
1 files changed, 19 insertions, 0 deletions
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