diff --git a/_documentation/src/main/minisite/content/mojos.adoc b/_documentation/src/main/minisite/content/mojos.adoc index 29457197..f6d9368e 100644 --- a/_documentation/src/main/minisite/content/mojos.adoc +++ b/_documentation/src/main/minisite/content/mojos.adoc @@ -297,6 +297,9 @@ Some specific attributes enables to customize the generation. Here is their list * `minisite-highlightjs-skip` enables to not setup highlight.js for the page (useful with swagger-ui for example). * `minisite-nav-prev-label`/`minisite-nav-next-label` enables to add a bottom page "previous"/"next" link to another page, this attribute defines its label. * `minisite-nav-prev-link`/`minisite-nav-next-link` enables to add a bottom page "previous"/"next" link to another page, this attribute defines its link (label is required), if label is defined but not the link, the link is the label lowercased with iphens instead of spaces and html extension. +* `minisite-breadcrumb` enables to define a page breadcrumb (navigation tree) at the top of the content. Syntax is the following: `:minisite-breadcrumb: Home[#] > Another Page[link-to-another-page.html] > This page`. If there is a `[xxx]`, then `xxx` is considered as a link. + +TIP: for a good documentation it is highly recommended to use nav and breadcrumb features. === Index generation diff --git a/minisite-core/src/main/java/io/yupiik/tools/minisite/MiniSite.java b/minisite-core/src/main/java/io/yupiik/tools/minisite/MiniSite.java index f22cfe21..c0a23b02 100644 --- a/minisite-core/src/main/java/io/yupiik/tools/minisite/MiniSite.java +++ b/minisite-core/src/main/java/io/yupiik/tools/minisite/MiniSite.java @@ -471,6 +471,54 @@ protected String getDefaultInterpolation(final String key, final Page page, return readingTimeComputer.toReadingTime(page.content); case "xyz": // passthrough return "{{xyz}}"; + case "breadcrumb": + String def = page.attributes.get("minisite-breadcrumb"); + if (def == null || def.isBlank()) { + return ""; + } + // parse: Home[#] > Another Page[link-to-another-page.html] > This page + final StringBuilder out = new StringBuilder("").toString(); default: try { return findPageTemplate(getTemplatesDir(), key); diff --git a/minisite-core/src/main/resources/yupiik-tools-maven-plugin/minisite/page-content.html b/minisite-core/src/main/resources/yupiik-tools-maven-plugin/minisite/page-content.html index 951e6d4b..840fa781 100644 --- a/minisite-core/src/main/resources/yupiik-tools-maven-plugin/minisite/page-content.html +++ b/minisite-core/src/main/resources/yupiik-tools-maven-plugin/minisite/page-content.html @@ -1,5 +1,5 @@
- {{{title}}} + {{{breadcrumb}}}{{{title}}}
{{{body}}} {{{defaultEndOfContent?emptyIfMissing=true}}} diff --git a/minisite-core/src/test/java/io/yupiik/tools/minisite/MiniSiteTest.java b/minisite-core/src/test/java/io/yupiik/tools/minisite/MiniSiteTest.java index 22572d75..0d86c794 100644 --- a/minisite-core/src/test/java/io/yupiik/tools/minisite/MiniSiteTest.java +++ b/minisite-core/src/test/java/io/yupiik/tools/minisite/MiniSiteTest.java @@ -27,6 +27,19 @@ @MiniSiteConfigurationBuilderProvider class MiniSiteTest { + @Test + void breadcrumb(final MiniSiteConfigurationBuilderProvider.Asserts asserts, + final MiniSiteConfiguration.MiniSiteConfigurationBuilder builder) { + new MiniSite(builder.build()).run(); + asserts.assertContains("page.html", ""); + } + @Test void footerNav(final MiniSiteConfigurationBuilderProvider.Asserts asserts, final MiniSiteConfiguration.MiniSiteConfigurationBuilder builder) { diff --git a/minisite-core/src/test/resources/sites/MiniSiteTest/breadcrumb/content/page.adoc b/minisite-core/src/test/resources/sites/MiniSiteTest/breadcrumb/content/page.adoc new file mode 100644 index 00000000..85d6504f --- /dev/null +++ b/minisite-core/src/test/resources/sites/MiniSiteTest/breadcrumb/content/page.adoc @@ -0,0 +1,4 @@ += Page 1 +:minisite-breadcrumb: Home[/] > Foo[foo.html] > Page 1 + +Content.