From 169f20256a1879e4a480fa5ec63a50c90a177850 Mon Sep 17 00:00:00 2001 From: younsl Date: Mon, 18 Nov 2024 01:04:24 +0900 Subject: [PATCH 1/3] feat: add toggle option for footer display - Add isShowFooter option in config.toml (default: true) - Implement conditional rendering in footer.html based on isShowFooter value --- config.toml | 1 + layouts/partials/footer.html | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/config.toml b/config.toml index 70f42a6..26d72ec 100644 --- a/config.toml +++ b/config.toml @@ -34,3 +34,4 @@ back_home_text = ".." date_format = "2006-01-02" isListGroupByDate = false + isShowFooter = true diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 319153e..37fe512 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,2 +1,4 @@ -{{ $footerContent := readFile "layouts/footer.md" }} -{{ $footerContent | markdownify }} +{{ if site.Params.theme_config.isShowFooter }} + {{ $footerContent := readFile "layouts/footer.md" }} + {{ $footerContent | markdownify }} +{{ end }} \ No newline at end of file From a0684e5add17d66d951b691c747981f1c32f91da Mon Sep 17 00:00:00 2001 From: younsl Date: Mon, 18 Nov 2024 01:26:06 +0900 Subject: [PATCH 2/3] feat(footer): Add fallback footer and improve file reading - Use resources.Get for safer file reading instead of readFile - Prevents directory traversal attacks - Ensures file access within Hugo's assets pipeline - Better error handling for missing files - Add fallback copyright notice when footer.md is not found - Add warning message for fallback to default footer --- layouts/partials/footer.html | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 37fe512..3b9522e 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -1,4 +1,10 @@ {{ if site.Params.theme_config.isShowFooter }} - {{ $footerContent := readFile "layouts/footer.md" }} - {{ $footerContent | markdownify }} -{{ end }} \ No newline at end of file + {{ with resources.Get "layouts/footer.md" }} + {{ .Content | markdownify }} + {{ else }} + {{ warnf "layouts/footer.md file is not found, fallback to the default copyright" }} +
+

© {{ now.Format "2006" }} {{ site.Title }}

+
+ {{ end }} +{{ end }} From f4b19aef86e7432b779b19a800c2b28646772ab7 Mon Sep 17 00:00:00 2001 From: younsl Date: Mon, 18 Nov 2024 22:46:07 +0900 Subject: [PATCH 3/3] style: improve formatting and alignment in config.toml - Adjusted alignment and whitespace for better readability - Maintained consistency between configuration items --- config.toml | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/config.toml b/config.toml index 26d72ec..2c4349d 100644 --- a/config.toml +++ b/config.toml @@ -1,7 +1,7 @@ [module] [module.hugoVersion] - extended=true - min = "0.41.0" + extended = true + min = "0.41.0" [markup] [markup.goldmark] @@ -9,29 +9,31 @@ [markup.goldmark.parser.attribute] block = true title = true + [markup.highlight] - anchorLineNos = false - codeFences = true - guessSyntax = false - hl_Lines = '' - hl_inline = false - lineAnchors = '' - lineNoStart = 1 - lineNos = false + anchorLineNos = false + codeFences = true + guessSyntax = false + hl_Lines = '' + hl_inline = false + lineAnchors = '' + lineNoStart = 1 + lineNos = false lineNumbersInTable = true - noClasses = true - noHl = false - style = 'rrt' - tabWidth = 4 + noClasses = true + noHl = false + style = 'rrt' + tabWidth = 4 + [markup.tableOfContents] startLevel = 2 - endLevel = 3 - ordered = false + endLevel = 3 + ordered = false [params] [params.theme_config] - appearance = "auto" - back_home_text = ".." - date_format = "2006-01-02" + appearance = "auto" + back_home_text = ".." + date_format = "2006-01-02" isListGroupByDate = false - isShowFooter = true + isShowFooter = true