Skip to content

Commit cf69d81

Browse files
authoredMay 27, 2024
feat: search.liquid over all collections (alshedivat#2447)
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.
1 parent 3043fcb commit cf69d81

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed
 

‎_includes/scripts/search.liquid

+13-11
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,20 @@
8484
},
8585
},
8686
{%- endfor -%}
87-
{%- for project in site.projects -%}
88-
{
89-
{%- assign title = project.title | escape -%}
90-
id: "project-{{ title | slugify }}",
91-
title: "{{ title }}",
92-
description: "{{ project.description | strip_html | strip_newlines | escape }}",
93-
section: "Projects",
94-
handler: () => {
95-
window.location.href = "{{ project.url | relative_url }}";
87+
{% for collection in site.collections %}
88+
{%- for item in collection.docs -%}
89+
{
90+
{%- assign title = item.title | escape -%}
91+
id: "{{ collection.label }}-{{ title | slugify }}",
92+
title: "{{ title }}",
93+
description: "{{ item.description | strip_html | strip_newlines | escape }}",
94+
section: "{{ collection.label | capitalize }}",
95+
handler: () => {
96+
window.location.href = "{{ item.url | relative_url }}";
97+
},
9698
},
97-
},
98-
{%- endfor -%}
99+
{%- endfor -%}
100+
{% endfor %}
99101
{%- if site.socials_in_search -%}
100102
{%- if site.email -%}
101103
{

0 commit comments

Comments
 (0)
Please sign in to comment.