-
Notifications
You must be signed in to change notification settings - Fork 990
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 json index #1998
Search json index #1998
Conversation
573d43c
to
d9acc9e
Compare
I really like this idea. It also makes me wonder if this could be leveraged to generate a css file? At the very least I can take a look at what you have done here to get some ideas. |
A css file for what? Edit: I think you mean csp |
My idea was to create a way for shortcodes to be able to write a portion of their output into a css file. The issue I linked discusses it in more detail, this is unrelated to search functionality, the only connection is being able to write to a file other than html. The problem is that you don't want style tags in the middle of an html page if you have a strict content security policy, because it would disallow this, so instead you would make the shortcode write the style related stuff directly to a css file. Writing style tags to a page via a shortcode is probably not a common use for a shortcode, but it is how I facilitate changing the image on mouse hover (useful thing for image comparison, especially in photography and video compression related blogs). |
That's not going to happen I think but it would be unrelated to that |
This will be useful if support for more search libraries are added in the future
d9acc9e
to
c716bfc
Compare
* search: Add support for a JSON index * docs: Document JSON index for search * docs: Use lazy-loaded JSON index * Add elasticlunr prefix to search engine format configuration This will be useful if support for more search libraries are added in the future
I am in the process of refactoring the Abridge theme, I got this json index search feature working a few moments ago, but noticed one thing... there is no cachebust hash on the json index so if you add new posts... repeat visitors may not have those posts in their index if their browser still has the old index cached, correct? Other than that works great! One very nice thing about fetching json instead of loading the javascript later is that it will not violate a strict csp since its simply json, before I was using this: https://github.com/Jieiku/abridge/blob/master/static/search_facade.js (with the above script, I update the hashes using an npm script) |
Can you open a new issue for the missing cachebust? |
Based on this discussion
Sanity check:
Code changes
(Delete or ignore this section for documentation changes)
next
branch?If the change is a new feature or adding to/changing an existing one:
Description
This PR adds an
index_format
configuration item.When set to Javascript, a JSON file is created instead of a
js
file for the index.This is:
fetch
API and be manipulated more easily than a script that sets a global variable for which you don't control the name. While it's not a use case I encountered, I don't think the current setup makes it easy to load multiple search index at the same time, for example for multiple languages.The docs are updated to