Fixed title search and truncating if larger than 13 words (#2561)
Fixes #2459 Signed-off-by: George Araujo <george.gcac@gmail.com>
This commit is contained in:
parent
cb0375c128
commit
e7d5c2f36a
|
|
@ -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 }} <svg width="1.2rem" height="1.2rem" top=".5rem" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><path d="M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9" class="icon_svg-stroke" stroke="#999" stroke-width="1.5" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg>',
|
||||
title: '{{ title | truncatewords: 13 }} <svg width="1.2rem" height="1.2rem" top=".5rem" viewBox="0 0 40 40" xmlns="http://www.w3.org/2000/svg"><path d="M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9" class="icon_svg-stroke" stroke="#999" stroke-width="1.5" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg>',
|
||||
{% 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: '<p>' | remove: '</p>' | 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: '<p>' | remove: '</p>' | 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: () => {
|
||||
|
|
|
|||
Loading…
Reference in New Issue