Re-add ability to exclude posts from search (#3089)

Earlier there was a tag in the `_config.yml` file to exclude the posts
from the search results. I could no longer find that option and hence
modified the `search.liquid.js` file.
It basically checks if the `posts_in_search` tag is true or not.
This commit is contained in:
Pranjal Aggarwal 2025-03-22 19:11:34 -06:00 committed by GitHub
parent 485e22fdf0
commit a7b1f8c1b1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 19 deletions

View File

@ -52,6 +52,7 @@ navbar_fixed: true
footer_fixed: true footer_fixed: true
search_enabled: true search_enabled: true
socials_in_search: true socials_in_search: true
posts_in_search: true
bib_search: true bib_search: true
# Dimensions # Dimensions

View File

@ -52,6 +52,7 @@ ninja.data = [
{%- endif -%} {%- endif -%}
{%- endif -%} {%- endif -%}
{%- endfor -%} {%- endfor -%}
{%- if site.posts_in_search -%}
{%- for post in site.posts -%} {%- for post in site.posts -%}
{ {
{%- assign title = post.title | escape | strip -%} {%- assign title = post.title | escape | strip -%}
@ -76,6 +77,7 @@ ninja.data = [
}, },
}, },
{%- endfor -%} {%- endfor -%}
{%- endif -%}
{%- for collection in site.collections -%} {%- for collection in site.collections -%}
{%- if collection.label != 'posts' -%} {%- if collection.label != 'posts' -%}
{%- for item in collection.docs -%} {%- for item in collection.docs -%}