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,