diff --git a/_config.yml b/_config.yml index e34c7fb..885a892 100644 --- a/_config.yml +++ b/_config.yml @@ -52,6 +52,7 @@ navbar_fixed: true footer_fixed: true search_enabled: true socials_in_search: true +posts_in_search: true bib_search: true # Dimensions diff --git a/_scripts/search.liquid.js b/_scripts/search.liquid.js index 995c531..bdb03af 100644 --- a/_scripts/search.liquid.js +++ b/_scripts/search.liquid.js @@ -52,30 +52,32 @@ ninja.data = [ {%- endif -%} {%- endif -%} {%- endfor -%} - {%- for post in site.posts -%} - { - {%- assign title = post.title | escape | strip -%} - id: "post-{{ title | slugify }}", - {% if post.redirect == blank %} - title: "{{ title | truncatewords: 13 }}", - {% elsif post.redirect contains '://' %} - title: '{{ title | truncatewords: 13 }} ', - {% else %} - title: "{{ title | truncatewords: 13 }}", - {% endif %} - description: "{{ post.description | strip_html | strip_newlines | escape | strip }}", - section: "Posts", - handler: () => { + {%- if site.posts_in_search -%} + {%- for post in site.posts -%} + { + {%- assign title = post.title | escape | strip -%} + id: "post-{{ title | slugify }}", {% if post.redirect == blank %} - window.location.href = "{{ post.url | relative_url }}"; + title: "{{ title | truncatewords: 13 }}", {% elsif post.redirect contains '://' %} - window.open("{{ post.redirect }}", "_blank"); + title: '{{ title | truncatewords: 13 }} ', {% else %} - window.location.href = "{{ post.redirect | relative_url }}"; + title: "{{ title | truncatewords: 13 }}", {% endif %} + description: "{{ post.description | strip_html | strip_newlines | escape | strip }}", + section: "Posts", + handler: () => { + {% if post.redirect == blank %} + window.location.href = "{{ post.url | relative_url }}"; + {% elsif post.redirect contains '://' %} + window.open("{{ post.redirect }}", "_blank"); + {% else %} + window.location.href = "{{ post.redirect | relative_url }}"; + {% endif %} + }, }, - }, - {%- endfor -%} + {%- endfor -%} + {%- endif -%} {%- for collection in site.collections -%} {%- if collection.label != 'posts' -%} {%- for item in collection.docs -%}