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

Search is Broken #1233

Open
systemcenterblog opened this issue Nov 1, 2023 · 2 comments
Open

Search is Broken #1233

systemcenterblog opened this issue Nov 1, 2023 · 2 comments

Comments

@systemcenterblog
Copy link

https://github.com/systemcenterblog/systemcenterblog.github.io

I have read others with identical issue however, I have applied your updated search.html and I don't have any errors relating to escaped chars.

It behaves like the JS is not running and the JSON file is not created.

@daattali
Copy link
Owner

daattali commented Nov 1, 2023

I saw your other comment "I have removed all my HTML posts that were converted from Blogger so only .MD posts are present and the search feature is working. What Character break the search script? i.e. _ ' ._ [] $"

To answer: I don't know exactly what breaks it. This is the javascript code that is responsible for this piece

var searchjson = '[ \
{% for post in site.posts %} \
{ \
"title" : "{% if post.title != "" %}{{ post.title | strip_html | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}", \
"desc" : "{% if post.title != "" %}{{ post.title | strip_html | escape }}{% else %}{{ post.excerpt | strip_html | escape | strip }}{%endif%}", \
"category" : "{{ post.tags | join: \', \' }}", \
"url" : "{{ site.baseurl }}{{ post.url | escape }}", \
"date" : "{{ post.date | date: "%B %e, %Y" | default: "January 1, 1970" }}" \
}, \
{% endfor %} \
{% for page in site.html_pages %}{% if page.title != "{title}" and page.title != "404 - Page not found" %} \
{ \
"title" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}", \
"desc" : "{% if page.title != "" %}{{ page.title | strip_html | escape }}{% else %}{{ page.excerpt | strip_html | escape | strip }}{% endif %}", \
"category" : "{% if page.tags %}{{ page.tags | join: \', \' }}{% else %}page{% endif %}", \
"url" : "{{ site.baseurl }}{{ page.url }}", \
"date" : "{{ page.date | date: '%B %e, %Y' | default: "January 1, 1970" }}" \
}{% unless forloop.last %},{% endunless %} \
{% endif %}{% endfor %} \
]';
searchjson = JSON.parse(searchjson);

I'm working on many other open source projects this week so I can't invest any more time on this issue now. I'll try to come back to it in the future. If you have familiarity with javascript, I would welcome you to try to debug it and let me know if you find the cause!

@daattali
Copy link
Owner

daattali commented Nov 1, 2023

For the other guy's case it was very easy to find the issue because the JS console error clearly showed where the problem is. With your site, I don't see a trivial cause. Maybe the string is just too long? That's just my first baseless guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants