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:
google-labs-jules[bot] 2026-01-15 21:41:26 -08:00 committed by GitHub
parent 2e308ed606
commit 24d730578a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 }}",