diff --git a/_includes/scripts/search.liquid b/_includes/scripts/search.liquid index 658ee7d..3acf15c 100644 --- a/_includes/scripts/search.liquid +++ b/_includes/scripts/search.liquid @@ -27,11 +27,11 @@ // add the home and posts menu items ninja.data = [ {%- for page in site.pages -%} - {%- if page.permalink == '/' -%}{%- assign about_title = page.title -%}{%- endif -%} + {%- if page.permalink == '/' -%}{%- assign about_title = page.title | strip -%}{%- endif -%} {%- endfor -%} { id: "nav-{{ about_title | slugify }}", - title: "{{ about_title }}", + title: "{{ about_title | truncatewords: 13 }}", section: "Navigation", handler: () => { window.location.href = "{{ '/' | relative_url }}"; @@ -44,11 +44,11 @@ {%- for child in p.children -%} {%- unless child.title == 'divider' -%} { - {%- assign title = child.title | escape -%} + {%- assign title = child.title | escape | strip -%} {%- if child.permalink contains "/blog/" -%}{%- assign url = "/blog/" -%} {%- else -%}{%- assign url = child.url -%}{%- endif -%} id: "dropdown-{{ title | slugify }}", - title: "{{ title }}", - description: "{{ child.description | strip_html | strip_newlines | escape }}", + title: "{{ title | truncatewords: 13 }}", + description: "{{ child.description | strip_html | strip_newlines | escape | strip }}", section: "Dropdown", handler: () => { window.location.href = "{{ url | relative_url }}"; @@ -59,11 +59,11 @@ {%- else -%} { - {%- assign title = p.title | escape -%} + {%- assign title = p.title | escape | strip -%} {%- if p.permalink contains "/blog/" -%}{%- assign url = "/blog/" -%} {%- else -%}{%- assign url = p.url -%}{%- endif -%} id: "nav-{{ title | slugify }}", - title: "{{ title }}", - description: "{{ p.description | strip_html | strip_newlines | escape }}", + title: "{{ title | truncatewords: 13 }}", + description: "{{ p.description | strip_html | strip_newlines | escape | strip }}", section: "Navigation", handler: () => { window.location.href = "{{ url | relative_url }}"; @@ -74,17 +74,17 @@ {%- endfor -%} {%- for post in site.posts -%} { - {%- assign title = post.title | escape -%} + {%- assign title = post.title | escape | strip -%} id: "post-{{ title | slugify }}", {% if post.redirect == blank %} - title: "{{ title }}", + title: "{{ title | truncatewords: 13 }}", {% elsif post.redirect contains '://' %} // TODO: fix the svg icon position for external posts - title: '{{ title }} ', + title: '{{ title | truncatewords: 13 }} ', {% else %} - title: "{{ title }}", + title: "{{ title | truncatewords: 13 }}", {% endif %} - description: "{{ post.description | strip_html | strip_newlines | escape }}", + description: "{{ post.description | strip_html | strip_newlines | escape | strip }}", section: "Posts", handler: () => { {% if post.redirect == blank %} @@ -97,37 +97,18 @@ }, }, {%- endfor -%} - {%- assign news = site.news | reverse -%} - {%- for item in news -%} - { - {%- if item.inline -%} - {%- assign title = item.content | remove: '
' | remove: '
' | escape | strip -%} - {%- else -%} - {%- assign title = item.title | escape -%} - {%- endif -%} - id: "news-{{ title | slugify }}", - title: '{{ title | emojify }}', - description: "{{ item.description | strip_html | strip_newlines | escape }}", - section: "News", - {%- unless item.inline -%} - handler: () => { - window.location.href = "{{ item.url | relative_url }}"; - }, - {%- endunless -%} - }, - {%- endfor -%} {%- for collection in site.collections -%} - {%- if collection.label != 'news' and collection.label != 'posts' -%} + {%- if collection.label != 'posts' -%} {%- for item in collection.docs -%} { {%- if item.inline -%} - {%- assign title = item.content | remove: '' | remove: '
' | escape | strip -%} + {%- assign title = item.content | strip_html | strip_newlines | escape | strip -%} {%- else -%} - {%- assign title = item.title | escape -%} + {%- assign title = item.title | strip_html | strip_newlines | escape | strip -%} {%- endif -%} id: "{{ collection.label }}-{{ title | slugify }}", - title: '{{ title | emojify }}', - description: "{{ item.description | strip_html | strip_newlines | escape }}", + title: '{{ title | emojify | truncatewords: 13 }}', + description: "{{ item.description | strip_html | strip_newlines | escape | strip }}", section: "{{ collection.label | capitalize }}", {%- unless item.inline -%} handler: () => {