From 58653e7b6788279b0c8673fb95a8ed44c6b08181 Mon Sep 17 00:00:00 2001 From: Hofi Date: Mon, 3 Jun 2024 14:29:24 +0200 Subject: [PATCH 1/3] Fixed earlier accidental edition of the lunr search result generation Signed-off-by: Hofi --- _js/lunr/lunr-en.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_js/lunr/lunr-en.js b/_js/lunr/lunr-en.js index 93b166d5..3debf8fe 100644 --- a/_js/lunr/lunr-en.js +++ b/_js/lunr/lunr-en.js @@ -81,7 +81,7 @@ $(document).ready(function() { '
' + '
' + '

' + - '' + store[ref].title + '' + + '' + store[ref].title + '' + '

' + '
' + '' + From b3fa9aad7b946b638d3122d6ca567e8444a5771f Mon Sep 17 00:00:00 2001 From: Hofi Date: Mon, 3 Jun 2024 15:00:40 +0200 Subject: [PATCH 2/3] Added some lunr search tests Signed-off-by: Hofi --- _config.yml | 6 ++++-- .../02_Tools/01_Self_made_tools/01_Tests/README.md | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/_config.yml b/_config.yml index 5084a22b..49b645c5 100644 --- a/_config.yml +++ b/_config.yml @@ -56,7 +56,7 @@ include: - assets/js/main.min.js # Only lunr is not included now to main.min.js - assets/js/lunr - # site.data.links input + # Input of site.data.links - _data/links/ exclude: - .reftime @@ -178,9 +178,11 @@ search_from_masthead: true search_provider: lunr lunr: - # No we have all the valuable content in collections + # No we have all the valuable content in collections (collection.docs) + # that lunr indexes by default if search: true # Standalone pages like, sitemap.xml, 404, etc. should not be searched search_within_pages: false + test_text_1: "abrakadabra" # search_provider: algolia # algolia: diff --git a/doc/_doc-guide/02_Tools/01_Self_made_tools/01_Tests/README.md b/doc/_doc-guide/02_Tools/01_Self_made_tools/01_Tests/README.md index 6bffc87e..5511ac8b 100644 --- a/doc/_doc-guide/02_Tools/01_Self_made_tools/01_Tests/README.md +++ b/doc/_doc-guide/02_Tools/01_Self_made_tools/01_Tests/README.md @@ -61,6 +61,10 @@ options { }; ``` +## Tests of custom markdown in header [[source]] and [[with turumturum id|doc-jekyll-extensions#titleid-markdown-extension]] + +## Tests of liquid expression {{ site.lunr.test_text_1 }} in header of {{ site.title }} + --------------------- Introduction to {{ site.product.short_name }} is a test for pages without description/subtitle, but text part between the title and the first heading which can have tooltips too this way. From 4fe298cad6b8d5258c8511b10ca02452f0954415 Mon Sep 17 00:00:00 2001 From: Hofi Date: Mon, 3 Jun 2024 14:33:17 +0200 Subject: [PATCH 3/3] Added title liquid pre-rendering to the link generation phase - autolink/tooltip generation now can handle liquid variables in titles Signed-off-by: Hofi --- _plugins/generate_links.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/_plugins/generate_links.rb b/_plugins/generate_links.rb index 3ab16a8d..a0b348f2 100644 --- a/_plugins/generate_links.rb +++ b/_plugins/generate_links.rb @@ -44,8 +44,14 @@ def register_id(page, id, title, ids, titles) end end + def render_title(page, title) + context = page.site.site_payload['site'] + template = Liquid::Template.parse(title) + return template.render('site' => context) + end + public - + def generate_links(page, ids, titles) #puts page.relative_path # Must have to get it parsed by jekyll, these links will be part of the site.data.links array as well, do not touch them @@ -81,7 +87,7 @@ def generate_links(page, ids, titles) link_data = { "id" => page_id + "##{heading_id}", "url" => page_url + "##{heading_id}", - "title" => '"' + heading.text + '"', + "title" => '"' + render_title(page, heading.text) + '"', } #register_id(page, link_data["id"], link_data["title"], ids, titles) @@ -104,7 +110,7 @@ def generate_links(page, ids, titles) link_data = { "id" => anchor_id, "url" => page_url + "##{anchor_name}", - "title" => '"' + (anchor_text.empty? ? anchor_id : anchor_text) + '"', + "title" => '"' + (anchor_text.empty? ? anchor_id : render_title(page, anchor_text)) + '"', } #register_id(page, link_data["id"], link_data["title"], ids, titles) @@ -114,7 +120,7 @@ def generate_links(page, ids, titles) end # Create links data for the page itself too - page_title = page.data["title"] + page_title = render_title(page, page.data["title"]) page_link_data = { "id" => page_id, "url" => page_url,