From 59e2f19169c8d099201b8cdbf8d6bde9e1372e5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 3 Jul 2022 17:12:44 +0200 Subject: [PATCH] theme: allow for page heading modification #139 --- archetypes/chapter.md | 2 +- .../content/basics/customization/_index.en.md | 6 ++++-- exampleSite/content/basics/migration/_index.en.md | 4 ++++ exampleSite/content/cont/archetypes.en.md | 2 +- exampleSite/content/cont/pages/_index.en.md | 14 +++++++++----- layouts/partials/article.html | 2 +- layouts/partials/heading-post.html | 1 + layouts/partials/heading-pre.html | 1 + layouts/partials/menu-post.html | 3 ++- layouts/partials/menu-pre.html | 2 +- 10 files changed, 25 insertions(+), 12 deletions(-) create mode 100644 layouts/partials/heading-post.html create mode 100644 layouts/partials/heading-pre.html diff --git a/archetypes/chapter.md b/archetypes/chapter.md index 6669355332..9df5bf9973 100644 --- a/archetypes/chapter.md +++ b/archetypes/chapter.md @@ -1,6 +1,6 @@ +++ chapter = true -pre = "X. " +menuPre = "X. " title = "{{ replace .Name "-" " " | title }}" weight = 5 +++ diff --git a/exampleSite/content/basics/customization/_index.en.md b/exampleSite/content/basics/customization/_index.en.md index f05ed60fe9..14113a1927 100644 --- a/exampleSite/content/basics/customization/_index.en.md +++ b/exampleSite/content/basics/customization/_index.en.md @@ -16,10 +16,12 @@ This theme defines the following partials : - `custom-header.html`: custom headers in page. Meant to be overwritten when adding CSS imports. Don't forget to include `style` HTML tag directive in your file. - `custom-footer.html`: custom footer in page. Meant to be overwritten when adding Javacript. Don't forget to include `javascript` HTML tag directive in your file. - `favicon.html`: the favicon +- `heading-pre.html`: side-wide configuration to prepend to pages title headings. If you override this, it is your responsiblity to take the page's `headingPre` setting into account. +- `heading-post.html`: side-wide configuration to append to pages title headings. If you override this, it is your responsiblity to take the page's `headingPost` setting into account. - `logo.html`: the logo, on top left hand corner - `meta.html`: HTML meta tags, if you want to change default behavior -- `menu-pre.html`: side-wide configuration to prepend to menu items. If you override this, it is your responsiblity to take the page's `pre` setting into account. -- `menu-post.html`: side-wide configuration to append to menu items. If you override this, it is your responsiblity to take the page's `post` setting into account. +- `menu-pre.html`: side-wide configuration to prepend to menu items. If you override this, it is your responsiblity to take the page's `menuPre` setting into account. +- `menu-post.html`: side-wide configuration to append to menu items. If you override this, it is your responsiblity to take the page's `menuPost` setting into account. - `menu-footer.html`: footer of the the left menu - `toc.html`: table of contents - `content.html`: the content page itself. This can be overridden if you wan't to display page's meta data above or below the content. diff --git a/exampleSite/content/basics/migration/_index.en.md b/exampleSite/content/basics/migration/_index.en.md index f9686ae612..3deadfe1ea 100644 --- a/exampleSite/content/basics/migration/_index.en.md +++ b/exampleSite/content/basics/migration/_index.en.md @@ -16,6 +16,10 @@ This document shows you what's new in the latest release. For a detailed list of ## 4.3.0 +- **Change**: Renaming the frontmatter options `pre` / `post` to `menuPre` / `menuPost`. The old options will still be used if the new options aren't set. Therefore you don't need to change anything after the upgrade. + +- **New**: Adding new partials `heading-pre.html` / `heading-post.html` and according frontmatter options `headingPre` / `headingPost` to modifiy the way your page`s main heading gets styled. + - **New**: The new shortcode `math` is available to add beautiful math and chemical formulae. See the [documentation]({{% relref "shortcodes/math" %}}) for available features. This feature will not work with Internet Explorer 11. ## 4.2.0 diff --git a/exampleSite/content/cont/archetypes.en.md b/exampleSite/content/cont/archetypes.en.md index 044b63c93b..4c29ff3123 100644 --- a/exampleSite/content/cont/archetypes.en.md +++ b/exampleSite/content/cont/archetypes.en.md @@ -20,7 +20,7 @@ It will create a page with predefined Front-Matter: ```toml +++ chapter = true -pre = "X. " +menuPre = "X. " title = "{{ replace .Name "-" " " | title }}" weight = 5 +++ diff --git a/exampleSite/content/cont/pages/_index.en.md b/exampleSite/content/cont/pages/_index.en.md index c1973d1c62..d62f62fcdd 100644 --- a/exampleSite/content/cont/pages/_index.en.md +++ b/exampleSite/content/cont/pages/_index.en.md @@ -54,7 +54,7 @@ You can define any HTML as prefix for the menu. In the example below, it's just ```markdown +++ chapter = true -pre = "1. " +menuPre = "1. " title = "Basics" weight = 5 +++ @@ -110,10 +110,14 @@ menuTitle = "" alwaysopen = true # If set, this will explicitly override common rules for the sorting order of a page's submenu entries ordersectionsby = "title" +# The title of the page heading will be prefixed by this HTML content +headingPre = "" +# The title of the page heading will be postfixed by this HTML content +headingPost = "" # The title of the page in menu will be prefixed by this HTML content -pre = "" +menuPre = "" # The title of the page in menu will be postfixed by this HTML content -post = "" +menuPost = "" # Set the page as a chapter, changing the way it's displayed chapter = false # Hide a menu entry by setting this to true @@ -127,12 +131,12 @@ LastModifierEmail = "" ### Add icon to a menu entry -In the page frontmatter, add a `pre` param to insert any HTML code before the menu label. The example below uses the GitHub icon. +In the page frontmatter, add a `menuPre` param to insert any HTML code before the menu label. The example below uses the GitHub icon. ```toml +++ title = "GitHub repo" -pre = " " +menuPre = " " +++ ``` diff --git a/layouts/partials/article.html b/layouts/partials/article.html index 1564dfab01..17e89cfb96 100644 --- a/layouts/partials/article.html +++ b/layouts/partials/article.html @@ -2,7 +2,7 @@ {{- with .page }} -{{ if and (not .IsHome ) (not .Params.chapter) }}

{{ .Title }}

+{{ if and (not .IsHome ) (not .Params.chapter) }}{{- partial "heading-pre.html" . }}

{{ .Title }}

{{- partial "heading-post.html" . }} {{ end }}{{ $content | safeHTML }}