Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve search file #418

Merged
merged 6 commits into from
Dec 17, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add search input include
  • Loading branch information
sylhare committed Dec 16, 2023
commit ae1d3846fae6e7419b8ab32e4b02e312c51d9c6e
41 changes: 41 additions & 0 deletions _includes/default/search_input.liquid
Copy link

@EverettYou EverettYou Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend reverting this commit. This makes all the hidden pages not searchable. But they are just hidden from the navigation bar, not meant to be hidden from the search. Or maybe introduce another page property like searchable to indicate if a page should appear in the search.

Copy link
Owner Author

@sylhare sylhare Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed that was the intent, hidden would mean both from search and navigation bar. Let me think for a solution to have a page hidden from the navigation bar but shown in the search 🤔 (I'd rather have a property to hide it from the search result then)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EverettYou I added an excluded option, instead of using hide. Should be better 👍

Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[
{% 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 | strip_newlines | strip | escape | truncate: '250' | escape | jsonify }},
"content" : {{ post.content | strip_html | strip_newlines | strip | escape | jsonify }}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
{% if site.pages.size > 0 %},{% endif %}
{% for page in site.pages %}
{
{% unless page.title == nil or page.title == "404 Page not found" %}
"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.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" | 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 %}
]