This is an automated email from the ASF dual-hosted git repository.

ddekany pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/freemarker-docgen.git

commit b55fb55ba5e792ed80635ad556864adfcee6d3ce
Author: ddekany <[email protected]>
AuthorDate: Sun Jun 22 12:13:03 2025 +0200

    Pagefind: Improved search hit titles
---
 .../org/freemarker/docgen/core/templates/navigation.ftlh  | 15 ++++++++++-----
 .../org/freemarker/docgen/core/templates/page.ftlh        | 12 +++++++++++-
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git 
a/freemarker-docgen-core/src/main/resources/org/freemarker/docgen/core/templates/navigation.ftlh
 
b/freemarker-docgen-core/src/main/resources/org/freemarker/docgen/core/templates/navigation.ftlh
index a70797a..3f187f0 100644
--- 
a/freemarker-docgen-core/src/main/resources/org/freemarker/docgen/core/templates/navigation.ftlh
+++ 
b/freemarker-docgen-core/src/main/resources/org/freemarker/docgen/core/templates/navigation.ftlh
@@ -49,12 +49,9 @@
   </#if>
 </#macro>
 
-<#macro breadcrumb>
-  <#if !showBreadCrumb>
-    <#return>
-  </#if>
+<#function breadCrumbPathToNode target>
   <#local path = []>
-  <#local curNode = .node>
+  <#local curNode = target>
   <#list 1.. as _>
     <#local path = [curNode] + path>
     <#if curNode.@docgen_root_element?size != 0>
@@ -62,6 +59,14 @@
     </#if>
     <#local curNode = curNode?parent>
   </#list>
+  <#return path>
+</#function>
+
+<#macro breadcrumb>
+  <#if !showBreadCrumb>
+    <#return>
+  </#if>
+  <#local path = breadCrumbPathToNode(.node)>
   <div class="breadcrumbs">
     <#if (path?size > 1)>
       <ul class="breadcrumb" itemscope 
itemtype="http://schema.org/BreadcrumbList";><#t>
diff --git 
a/freemarker-docgen-core/src/main/resources/org/freemarker/docgen/core/templates/page.ftlh
 
b/freemarker-docgen-core/src/main/resources/org/freemarker/docgen/core/templates/page.ftlh
index 6428563..2500ab3 100644
--- 
a/freemarker-docgen-core/src/main/resources/org/freemarker/docgen/core/templates/page.ftlh
+++ 
b/freemarker-docgen-core/src/main/resources/org/freemarker/docgen/core/templates/page.ftlh
@@ -167,7 +167,17 @@
           <#if !simpleNavigationMode>
             <@nav.pagers class="top" /><#t>
           </#if>
-          <div class="title-wrapper"><#t>
+          <#if hasSearch && pagefindBasedSearch>
+            <div style="display: none" data-pagefind-meta="title"><#t>
+              <#local pagefindPageTitlePath = nav.breadCrumbPathToNode(.node)>
+              <#-- Skip the book title in Pagefind search hits, except if 
that's all we have: -->
+              <#if pagefindPageTitlePath?size gt 1>
+                <#local pagefindPageTitlePath = pagefindPageTitlePath[1..]>
+              </#if>
+              <#list pagefindPageTitlePath as 
step>${u.getRequiredTitleAsString(step)}<#sep> / </#list><#t>
+            </div><#t>
+          </#if>
+          <div class="title-wrapper" data-pagefind-ignore="all"><#t>
             <#visit titleElement using nodeHandlers><#t>
           </div><#t>
         </div><#t>

Reply via email to