diff --git a/README.md b/README.md index 04d3c7908d..3bc547fb51 100644 --- a/README.md +++ b/README.md @@ -502,10 +502,12 @@ gallery: "assets/img/pexels" The search feature is based on [Simple-Jekyll-search](https://github.com/christian-fei/Simple-Jekyll-Search) there is a `search.liquid` file that will create a list of all the site posts, pages and portfolios. +Then there's a script displaying the formatted results in the _search page_. -Then there's a `search.js` displaying the formatted results in the "search" page. - -The search page can be hidden with the `hide` option. You can remove the icon by removing `icon`: +To exclude contents from the search add the `exclude: true` option in the markdown header. +By default, all posts, pages, and collections are available in the search. +Hide the search page from the navigation bar with the `hide: true` option. +You can remove the icon by removing `icon`: ```yml diff --git a/_includes/default/search_input.liquid b/_includes/default/search_input.liquid new file mode 100644 index 0000000000..44ff7eb3a0 --- /dev/null +++ b/_includes/default/search_input.liquid @@ -0,0 +1,46 @@ +[ +{% for post in site.posts %} + { + {% unless post.excluded %} + "title" : "{{ post.title | strip_newlines | escape }}", + "category" : "{{ post.category }}", + "tags" : "{{ post.tags | join: ', ' | prepend: " " }}", + "url" : "{{ post.url | relative_url }}", + "date" : "{{ post.date | date: "%B %-d, %Y" }}", + "excerpt" : {{ post.content | strip_html | strip_newlines | strip | escape | truncate: '250' | escape | jsonify }}, + "content" : {{ post.content | strip_html | strip_newlines | strip | escape | jsonify }} + {% endunless %} + }{% unless forloop.last %},{% endunless %} +{% endfor %} +{% if site.pages.size > 0 %},{% endif %} +{% for page in site.pages %} + { + {% unless page.excluded or page.title == nil %} + "title" : "{{ page.title | strip_newlines | escape }}", + "category" : "{{ page.category }}", + "tags" : "{{ page.tags | join: ', ' | prepend: " " }}", + "url" : "{{ page.url | relative_url }}", + "date" : "{{ page.date | date: "%B %-d, %Y" | default: "N/A" }}", + "excerpt" : {{ page.content | strip_html | strip_newlines | strip | escape | truncate: '250' | escape | jsonify }}, + "content" : {{ page.content | strip_html | strip_newlines | strip | escape | jsonify }} + {% endunless %} + }{% unless forloop.last %},{% endunless %} +{% endfor %} +{% if site.collections.size > 0 %},{% endif %} +{% for collection in site.collections %} + {% for page in site[collection.label] %} + { + {% if page.excluded or page.title != nil %} + "title" : "{{ page.title | strip_newlines | escape }}", + "category" : "{{ page.category }}", + "tags" : "{{ page.tags | join: ', ' | prepend: " " }}", + "url" : "{{ page.url | relative_url }}", + "date" : "{{ page.date | date: "%B %-d, %Y" | default: "N/A" }}", + "excerpt" : {{ page.content | strip_html | strip_newlines | strip | escape | truncate: '250' | jsonify }}, + "content" : {{ page.content | strip_html | strip_newlines | strip | escape | jsonify }} + {% endif %} + }{% unless forloop.last %},{% endunless %} + {% endfor %} + {% unless forloop.last %},{% endunless %} +{% endfor %} +] diff --git a/_portfolio/hanoi.md b/_portfolio/hanoi.md index 690cf5b7e8..5aa57d9ea3 100644 --- a/_portfolio/hanoi.md +++ b/_portfolio/hanoi.md @@ -5,6 +5,8 @@ img: "assets/img/portfolio/toh.png" date: September 2014 --- +The tower of Hanoi... + ![image]({{ page.img | relative_url }}) Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, diff --git a/assets/data/search.liquid b/assets/data/search.liquid index a54e2fdd7f..d54ddfd79c 100644 --- a/assets/data/search.liquid +++ b/assets/data/search.liquid @@ -1,29 +1,8 @@ --- --- -[ - {% for post in site.posts %} - { - "title" : "{{ post.title | strip_newlines | escape }}", - "category" : "{{ post.category }}", - "tags" : "{{ post.tags | join: ', ' | prepend: " " }}", - "url" : "{{ post.url | relative_url }}", - "date" : "{{ post.date | date: "%B %-d, %Y" }}", - "excerpt" : {{ post.content | strip_html | truncate: '250' | escape | jsonify }}, - "content" : {{ post.content | strip_html | escape | jsonify }} -} {% unless forloop.last %},{% endunless %} - {% endfor %} - {% if site.portfolio.size > 0 %},{% endif %} - {% for page in site.portfolio %} - { - {% if page.title != nil %} - "title" : "{{ page.title | strip_newlines | escape }}", - "category" : "{{ page.category }}", - "tags" : "{{ page.tags | join: ', ' | prepend: " " }}", - "url" : "{{ page.url | relative_url }}", - "date" : "{{ page.date | date: "%B %-d, %Y" }}", - "excerpt" : {{ page.content | strip_html | truncate: '250' | jsonify }}, - "content" : {{ page.content | strip_html | escape | jsonify }} - {% endif %} -} {% unless forloop.last %},{% endunless %} - {% endfor %} -] +{% comment %} +The json is created in search_input.liquid and included here to be compresed +{% endcomment %} +{% capture _search %}{% include default/search_input.liquid %}{% endcapture %} +{% assign emptyField = '{ },' %} +{{ _search | split: " " | join: " " | remove: emptyField }} diff --git a/pages/404.md b/pages/404.md index 8a26e5fb52..5146209c13 100644 --- a/pages/404.md +++ b/pages/404.md @@ -3,6 +3,7 @@ layout: page title: "404 Page not found" permalink: /404.html hide: true +excluded: true --- Sorry, the requested page wasn't found on the server. diff --git a/pages/categories.md b/pages/categories.md index 74f62c9264..7b6acd44a6 100644 --- a/pages/categories.md +++ b/pages/categories.md @@ -3,4 +3,5 @@ layout: categories title: Categories permalink: /categories/ hide: true +excluded: true --- diff --git a/pages/gallery.md b/pages/gallery.md index ba70b50236..effaff49e4 100644 --- a/pages/gallery.md +++ b/pages/gallery.md @@ -4,12 +4,13 @@ title: Gallery subtitle: From the pexels folder permalink: /gallery/ gallery_path: "assets/img/pexels" +excluded: true position: 3 tags: [Page] --- This is a photo gallery made from the static files in the `assets/img/pexels` folder. -I wanted to create automatically a simple gallery from a folder without having to create a markdown page as you would for the portfolio. +I wanted to automatically create a simple gallery from a folder without having to create a markdown page as you would for the portfolio. {% include gallery.html gallery_path=page.gallery_path %} diff --git a/pages/search.md b/pages/search.md index c56f8faece..c3b1cf534f 100644 --- a/pages/search.md +++ b/pages/search.md @@ -5,5 +5,6 @@ permalink: /search/ subtitle: "What are you looking for?" feature-img: "assets/img/pexels/search-map.jpeg" icon: "fa-search" +excluded: true position: 5 ---