Skip to content

Commit

Permalink
feat: search.liquid over all collections (alshedivat#2447)
Browse files Browse the repository at this point in the history
Thank you @george-gca for the awesome work. on alshedivat#2415.

This PR generalizes the search on all collections. Currently, only
projects are added to the search.
This PR uses all of them, such as news. On my personal website, I use a
teaching collection which is then also automatically searched.
  • Loading branch information
CheariX authored and Suraj-Bhor committed Aug 13, 2024
1 parent 5fa6877 commit 3a0c277
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions _includes/scripts/search.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,20 @@
},
},
{%- endfor -%}
{%- for project in site.projects -%}
{
{%- assign title = project.title | escape -%}
id: "project-{{ title | slugify }}",
title: "{{ title }}",
description: "{{ project.description | strip_html | strip_newlines | escape }}",
section: "Projects",
handler: () => {
window.location.href = "{{ project.url | relative_url }}";
{% for collection in site.collections %}
{%- for item in collection.docs -%}
{
{%- assign title = item.title | escape -%}
id: "{{ collection.label }}-{{ title | slugify }}",
title: "{{ title }}",
description: "{{ item.description | strip_html | strip_newlines | escape }}",
section: "{{ collection.label | capitalize }}",
handler: () => {
window.location.href = "{{ item.url | relative_url }}";
},
},
},
{%- endfor -%}
{%- endfor -%}
{% endfor %}
{%- if site.socials_in_search -%}
{%- if site.email -%}
{
Expand Down

0 comments on commit 3a0c277

Please sign in to comment.