diff --git a/wowchemy/layouts/partials/book_layout.html b/wowchemy/layouts/partials/book_layout.html index 693fc438d..d73c1e8e4 100644 --- a/wowchemy/layouts/partials/book_layout.html +++ b/wowchemy/layouts/partials/book_layout.html @@ -12,7 +12,7 @@ {{/* Show ToC by default. */}} {{ if ne .Params.toc false }}
- {{ partial "hooks/page_toc_start" . }} + {{ partial "functions/get_hook" (dict "hook" "toc-start" "context" .) }}
{{ end }} diff --git a/wowchemy/layouts/partials/custom_head.html b/wowchemy/layouts/partials/custom_head.html deleted file mode 100644 index 7f262fae1..000000000 --- a/wowchemy/layouts/partials/custom_head.html +++ /dev/null @@ -1,4 +0,0 @@ -{{/* Do not directly modify this file! */}} -{{/* Instead, create a `layouts/partials/custom_head.html` file in your site and add your code to it. */}} - -{{/* This partial is included in `themes/academic/layouts/partials/site_head.html`. */}} diff --git a/wowchemy/layouts/partials/custom_js.html b/wowchemy/layouts/partials/custom_js.html deleted file mode 100644 index 8d081963f..000000000 --- a/wowchemy/layouts/partials/custom_js.html +++ /dev/null @@ -1,4 +0,0 @@ -{{/* Do not directly modify this file! */}} -{{/* Instead, create a `layouts/partials/custom_js.html` file in your site and add your code to it. */}} - -{{/* This partial is included in `themes/academic/layouts/partials/site_js.html`. */}} diff --git a/wowchemy/layouts/partials/functions/get_hook.html b/wowchemy/layouts/partials/functions/get_hook.html new file mode 100644 index 000000000..c1a0a0e41 --- /dev/null +++ b/wowchemy/layouts/partials/functions/get_hook.html @@ -0,0 +1,18 @@ +{{/* Function to inject custom code into layouts without overriding files. */}} +{{/* Input: hook folder name (str) */}} +{{/* Output: loaded (bool) */}} + +{{ $loaded := false }} +{{ $partial_dir := printf "hooks/%s/" .hook }} +{{ $hook_dir_path := path.Join "layouts/partials" $partial_dir }} +{{ if fileExists $hook_dir_path }} + {{ range os.ReadDir $hook_dir_path }} + {{ if not .IsDir }} + {{ $partial_path := path.Join $partial_dir .Name }} + {{ partial $partial_path . }} + {{ $loaded = true }} + {{ end }} + {{ end }} +{{ end }} +{{/* The return statement below is for debug purposes only and prevents the above partial(s) being included in the page */}} +{{/* return $loaded */}} diff --git a/wowchemy/layouts/partials/hooks/footer.html b/wowchemy/layouts/partials/hooks/footer.html deleted file mode 100644 index 9c47df60b..000000000 --- a/wowchemy/layouts/partials/hooks/footer.html +++ /dev/null @@ -1,2 +0,0 @@ -{{/* Override this file to add a custom footer to every page. */}} -{{/* This partial is included in `layouts/partials/site_footer.html`. */}} diff --git a/wowchemy/layouts/partials/hooks/page_toc_end.html b/wowchemy/layouts/partials/hooks/page_toc_end.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/wowchemy/layouts/partials/hooks/page_toc_start.html b/wowchemy/layouts/partials/hooks/page_toc_start.html deleted file mode 100644 index e69de29bb..000000000 diff --git a/wowchemy/layouts/partials/site_footer.html b/wowchemy/layouts/partials/site_footer.html index 82a14b7ab..34c13e010 100644 --- a/wowchemy/layouts/partials/site_footer.html +++ b/wowchemy/layouts/partials/site_footer.html @@ -1,6 +1,6 @@