Refactor: Use Liquid filter to find home page title (#3448)
Refactored the script in _scripts/search.liquid.js to use a more efficient Liquid 'where' filter to find the home page title. This replaces an inefficient for loop that iterated through all site pages. --- *PR created automatically by Jules for task [5748098109809984605](https://jules.google.com/task/5748098109809984605) started by @alshedivat* Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
This commit is contained in:
parent
2e308ed606
commit
24d730578a
@ -6,9 +6,7 @@ const ninja = document.querySelector('ninja-keys');
|
||||
|
||||
// add the home and posts menu items
|
||||
ninja.data = [
|
||||
{%- for page in site.pages -%}
|
||||
{%- if page.permalink == '/' -%}{%- assign about_title = page.title | strip -%}{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- assign about_title = site.pages | where: "permalink", "/" | first.title | strip -%}
|
||||
{
|
||||
id: "nav-{{ about_title | slugify }}",
|
||||
title: "{{ about_title | truncatewords: 13 }}",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user