From 5bbe13fd43ffe57ae39dddc3840146b7e7f4d289 Mon Sep 17 00:00:00 2001 From: Sangeeth Sudheer Date: Fri, 7 Mar 2025 10:19:49 +0530 Subject: [PATCH] Add breadcrumbs config to hide current page and change home text Changes `breadcrumbs` config into an object to add customizations such as hiding current page and changing the text of the home crumb. By default, Typo will now show breadcrumbs. If breadcrumbs are enabled, the current default of showing the current page crumb is preserved. BREAKING CHANGE: `breadcrumbs` is now an object so existing `breadcrumbs = ` line in config needs to be changed. --- .gitignore | 2 ++ assets/css/main.css | 8 +++----- hugo.toml | 6 ++++++ layouts/partials/breadcrumbs.html | 28 +++++++++++++++++++++------- wiki/features/other-parameters.md | 14 ++++++++++++-- wiki/setup.md | 5 +++-- 6 files changed, 47 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 6e26b2b..19716da 100644 --- a/.gitignore +++ b/.gitignore @@ -108,3 +108,5 @@ $RECYCLE.BIN/ # Windows shortcuts *.lnk + +.idea/ diff --git a/assets/css/main.css b/assets/css/main.css index 65ea0b4..6e83511 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -524,16 +524,14 @@ figcaption { /* breadcrumbs */ .breadcrumbs { + display: flex; + flex-wrap: wrap; + gap: 2px; font-size: small; margin-bottom: calc(-0.5 * var(--h1-margin-top)); font-family: var(--font-mono); } -.breadcrumbs span { - margin-right: -5px; - margin-left: -5px; -} - /* Comments */ .giscus { diff --git a/hugo.toml b/hugo.toml index 709ba78..cfc1669 100644 --- a/hugo.toml +++ b/hugo.toml @@ -7,3 +7,9 @@ title = 'typo' [module.hugoVersion] extended = false min = "0.116.0" + +# Default config +[params.breadcrumbs] +enabled = true +showCurrentPage = true +home = "Home" \ No newline at end of file diff --git a/layouts/partials/breadcrumbs.html b/layouts/partials/breadcrumbs.html index 5c4fb62..df67cb8 100644 --- a/layouts/partials/breadcrumbs.html +++ b/layouts/partials/breadcrumbs.html @@ -1,9 +1,23 @@ -{{ if .Site.Params.breadcrumbs }} +{{- if .Site.Params.breadcrumbs.enabled -}} +{{- $breadcrumbs := .Site.Params.breadcrumbs -}} -{{ end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/wiki/features/other-parameters.md b/wiki/features/other-parameters.md index 136698e..a6e370d 100644 --- a/wiki/features/other-parameters.md +++ b/wiki/features/other-parameters.md @@ -25,11 +25,21 @@ description = "Your description" Show breadcrumbs on pages. +Example: + ```toml -[params] -breadcrumbs = true +[params.breadcrumbs] +enabled = true +showCurrentPage = true +home = "~" ``` +Set `enabled` to `false` if you want to hide breadcrumbs. By default, breadcrumbs are shown. + +Set `showCurrentPage` to `false` to hide the last crumb, i.e, the current page. + +`home` when set with a non-empty string, uses the latter as the first crumb instead of the string "Home". + ## Comments Enable comments on your posts using [Giscus](https://giscus.app/). diff --git a/wiki/setup.md b/wiki/setup.md index db73c80..eb5c13f 100644 --- a/wiki/setup.md +++ b/wiki/setup.md @@ -114,8 +114,9 @@ paginationSize = 100 listSummaries = true listDateFormat = '2 Jan 2006' -# Breadcrumbs -breadcrumbs = true +# Breadcrumbs (Uncomment to disable) +# [params.breadcrumbs] +# enabled = false # Social icons [[params.social]]