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
|
// add the home and posts menu items
|
||||||
ninja.data = [
|
ninja.data = [
|
||||||
{%- for page in site.pages -%}
|
{%- 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 -%}
|
{%- endfor -%}
|
||||||
{
|
{
|
||||||
id: "nav-{{ about_title | slugify }}",
|
id: "nav-{{ about_title | slugify }}",
|
||||||
title: "{{ about_title }}",
|
title: "{{ about_title | truncatewords: 13 }}",
|
||||||
section: "Navigation",
|
section: "Navigation",
|
||||||
handler: () => {
|
handler: () => {
|
||||||
window.location.href = "{{ '/' | relative_url }}";
|
window.location.href = "{{ '/' | relative_url }}";
|
||||||
|
|
@ -44,11 +44,11 @@
|
||||||
{%- for child in p.children -%}
|
{%- for child in p.children -%}
|
||||||
{%- unless child.title == 'divider' -%}
|
{%- 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 -%}
|
{%- if child.permalink contains "/blog/" -%}{%- assign url = "/blog/" -%} {%- else -%}{%- assign url = child.url -%}{%- endif -%}
|
||||||
id: "dropdown-{{ title | slugify }}",
|
id: "dropdown-{{ title | slugify }}",
|
||||||
title: "{{ title }}",
|
title: "{{ title | truncatewords: 13 }}",
|
||||||
description: "{{ child.description | strip_html | strip_newlines | escape }}",
|
description: "{{ child.description | strip_html | strip_newlines | escape | strip }}",
|
||||||
section: "Dropdown",
|
section: "Dropdown",
|
||||||
handler: () => {
|
handler: () => {
|
||||||
window.location.href = "{{ url | relative_url }}";
|
window.location.href = "{{ url | relative_url }}";
|
||||||
|
|
@ -59,11 +59,11 @@
|
||||||
|
|
||||||
{%- else -%}
|
{%- 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 -%}
|
{%- if p.permalink contains "/blog/" -%}{%- assign url = "/blog/" -%} {%- else -%}{%- assign url = p.url -%}{%- endif -%}
|
||||||
id: "nav-{{ title | slugify }}",
|
id: "nav-{{ title | slugify }}",
|
||||||
title: "{{ title }}",
|
title: "{{ title | truncatewords: 13 }}",
|
||||||
description: "{{ p.description | strip_html | strip_newlines | escape }}",
|
description: "{{ p.description | strip_html | strip_newlines | escape | strip }}",
|
||||||
section: "Navigation",
|
section: "Navigation",
|
||||||
handler: () => {
|
handler: () => {
|
||||||
window.location.href = "{{ url | relative_url }}";
|
window.location.href = "{{ url | relative_url }}";
|
||||||
|
|
@ -74,17 +74,17 @@
|
||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
{%- for post in site.posts -%}
|
{%- for post in site.posts -%}
|
||||||
{
|
{
|
||||||
{%- assign title = post.title | escape -%}
|
{%- assign title = post.title | escape | strip -%}
|
||||||
id: "post-{{ title | slugify }}",
|
id: "post-{{ title | slugify }}",
|
||||||
{% if post.redirect == blank %}
|
{% if post.redirect == blank %}
|
||||||
title: "{{ title }}",
|
title: "{{ title | truncatewords: 13 }}",
|
||||||
{% elsif post.redirect contains '://' %}
|
{% elsif post.redirect contains '://' %}
|
||||||
// TODO: fix the svg icon position for external posts
|
// 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 %}
|
{% else %}
|
||||||
title: "{{ title }}",
|
title: "{{ title | truncatewords: 13 }}",
|
||||||
{% endif %}
|
{% endif %}
|
||||||
description: "{{ post.description | strip_html | strip_newlines | escape }}",
|
description: "{{ post.description | strip_html | strip_newlines | escape | strip }}",
|
||||||
section: "Posts",
|
section: "Posts",
|
||||||
handler: () => {
|
handler: () => {
|
||||||
{% if post.redirect == blank %}
|
{% if post.redirect == blank %}
|
||||||
|
|
@ -97,37 +97,18 @@
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{%- endfor -%}
|
{%- 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 -%}
|
{%- for collection in site.collections -%}
|
||||||
{%- if collection.label != 'news' and collection.label != 'posts' -%}
|
{%- if collection.label != 'posts' -%}
|
||||||
{%- for item in collection.docs -%}
|
{%- for item in collection.docs -%}
|
||||||
{
|
{
|
||||||
{%- if item.inline -%}
|
{%- if item.inline -%}
|
||||||
{%- assign title = item.content | remove: '<p>' | remove: '</p>' | escape | strip -%}
|
{%- assign title = item.content | strip_html | strip_newlines | escape | strip -%}
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{%- assign title = item.title | escape -%}
|
{%- assign title = item.title | strip_html | strip_newlines | escape | strip -%}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
id: "{{ collection.label }}-{{ title | slugify }}",
|
id: "{{ collection.label }}-{{ title | slugify }}",
|
||||||
title: '{{ title | emojify }}',
|
title: '{{ title | emojify | truncatewords: 13 }}',
|
||||||
description: "{{ item.description | strip_html | strip_newlines | escape }}",
|
description: "{{ item.description | strip_html | strip_newlines | escape | strip }}",
|
||||||
section: "{{ collection.label | capitalize }}",
|
section: "{{ collection.label | capitalize }}",
|
||||||
{%- unless item.inline -%}
|
{%- unless item.inline -%}
|
||||||
handler: () => {
|
handler: () => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue