diff --git a/.grenrc.js b/.grenrc.js index 14b10ca699..6c8dcb1c18 100644 --- a/.grenrc.js +++ b/.grenrc.js @@ -1,5 +1,5 @@ module.exports = { - changelogFilename: "exampleSite/content/basics/CHANGELOG.md", + changelogFilename: "CHANGELOG.md", dataSource: "milestones", groupBy: { "Enhancements": [ diff --git a/exampleSite/content/basics/CHANGELOG.md b/CHANGELOG.md similarity index 100% rename from exampleSite/content/basics/CHANGELOG.md rename to CHANGELOG.md diff --git a/exampleSite/config/_default/hugo.toml b/exampleSite/config/_default/hugo.toml index 34e02a462c..64ede84f9e 100644 --- a/exampleSite/config/_default/hugo.toml +++ b/exampleSite/config/_default/hugo.toml @@ -147,7 +147,7 @@ title = "Hugo Relearn Theme" pageRef = "categories/" weight = 50 -# mounts are only needed in this showcase to access the publicly available screenshots; +# mounts are only needed in this showcase to access the publicly available screenshots and CHANGELOG; # remove this section if you don't need further mounts [module] [[module.mounts]] @@ -192,6 +192,10 @@ title = "Hugo Relearn Theme" [[module.mounts]] source = '../images' target = 'assets/images' + # just for this documentation to expose the CHANGELOG.md in the docs + [[module.mounts]] + source = '../CHANGELOG.md' + target = 'assets/CHANGELOG.md' [params] # Demo setting for displaying the siteparam shortcode the docs. diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index 898c82c2c7..9a025728be 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -298,6 +298,19 @@ disableHoverBlockCopyToClipBoard = false # individual code blocks. highlightWrap = true +#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +# Include +# These options configure how the include shortcode works. + +# What to do when path is not resolved. +# Default: "" +# You can control what should happen if a path can not be resolved to as +# a resource or via the file system. If not set, no output will be written +# for the unresolved path. If set to `warning` the same happens and an additional +# warning is printed. If set to `error` an error message is printed and the build +# is aborted. +include.errorlevel = "warning" + #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # Images # These options configure how images are displayed. diff --git a/exampleSite/content/basics/history/_index.en.md b/exampleSite/content/basics/history/_index.en.md index 8c4403e56a..a6d92f3ebc 100644 --- a/exampleSite/content/basics/history/_index.en.md +++ b/exampleSite/content/basics/history/_index.en.md @@ -3,4 +3,4 @@ disableToc = false title = "History" weight = 30 +++ -{{% include "basics/CHANGELOG.md" true %}} +{{% include "CHANGELOG.md" true %}} diff --git a/exampleSite/content/basics/migration/_index.en.md b/exampleSite/content/basics/migration/_index.en.md index ebf3835108..690c2b5d77 100644 --- a/exampleSite/content/basics/migration/_index.en.md +++ b/exampleSite/content/basics/migration/_index.en.md @@ -34,10 +34,12 @@ This document shows you what's new in the latest release and flags it with one o - {{% badge style="warning" title=" " %}}Breaking{{% /badge %}} Support for Internet Explorer 11 was finally dropped. -- {{% badge style="note" title=" " %}}Change{{% /badge %}} Removing support for Internet Explorer 11 finally allowed the theme to upgradte to Font Awesome 6.5.2. +- {{% badge style="note" title=" " %}}Change{{% /badge %}} Removing support for Internet Explorer 11 allowed to upgrade Font Awesome to version 6.5.2. You may experience slight changes for some icons. In addition you have additional ~1700 icons [to chose](https://fontawesome.com/v6/search?m=free) from. +- {{% badge style="note" title=" " %}}Change{{% /badge %}} The [`include` shortcode](shortcodes/include) is now able to resolve links to resources as well as to files in the file system (the old behavior). You can configure to generate warnings or errors during build by setting `include.errorlevel` to either `warning` or `error` in your `hugo.toml` if a path can not be resolved. + - {{% badge style="info" icon="plus-circle" title=" " %}}New{{% /badge %}} Translation into Romanian. --- diff --git a/layouts/partials/shortcodes/include.html b/layouts/partials/shortcodes/include.html index 17ffddd842..4275478d5a 100644 --- a/layouts/partials/shortcodes/include.html +++ b/layouts/partials/shortcodes/include.html @@ -4,16 +4,33 @@ {{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'include' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5180" $page.File.Filename }} {{- end }} {{- $file := .file }} +{{- $content := "" }} +{{- with or + ($page.Resources.Get $file) + (resources.Get $file) +}} + {{- $content = .Content }} +{{- else }} + {{- if (fileExists $file) }} + {{- $content = $file | readFile }} + {{- else }} + {{- if eq $page.Site.Params.include.errorlevel "warning" }} + {{- warnf "%q: file '%s' is not a resource nor accessible via file system" $page.File.Filename $file }} + {{- else if eq $page.Site.Params.include.errorlevel "error" }} + {{- errorf "%q: image '%s' is not a resource nor accessible via file system" $page.File.Filename $file }} + {{- end }} + {{- end }} +{{- end }} {{- $hideFirstHeading := .hidefirstheading | default false }} {{- if eq (printf "%T" $hideFirstHeading) "string" }} {{- $hideFirstHeading = (eq $hideFirstHeading "true") }} {{- end }} -{{- if and (gt (len (trim $file " ")) 0) (fileExists $file) }} +{{- if $content }} {{- if $hideFirstHeading }}
{{ end }} {{- with $page }} -{{- $file | readFile | safeHTML }} +{{- $content | safeHTML }} {{- end }} {{- if $hideFirstHeading }}
{{ end }} {{- end }} \ No newline at end of file