About how to be independent of the search engine. I think of 2
solutions.

# Solution 1

After looking at Pagefind, I was thinking of taking inspiration from
"org-export-define-backend".

Creating a function named like "org-html-define-search-engine" and that
will have as parameters:

- A search engine name

- A HTML template for the search field (can be nil)

- A HTML template for the header (to load JS and CSS, can be nil)

- A function to build the index (can be nil for no function)

- A function to install JS and CSS on the output folder (can be nil for
  no function)

- Maybe a function to download/install external command line tool (like
  the pagefind tool used to index content and install JS+CSS)

The new defined engine is stored in a variable and its name is the name
given to "org-html-define-search-engine".

Then, for a user who want to add a search field in its org-publish
project, he or she just add an option ":html-search-engine 'pagefind".
Or any defined search engine.


# Solution 2

I was looking into tools suggested for the Hugo static site
generator:
https://gohugo.io/tools/search/

And this was interesting:
https://gist.github.com/eddiewebb/735feb48f50f0ddd65ae5606a1cb41ae

It use Hugo to directly generate an Index: It is configured to export
the home page into JSON in addition to HTML. Then, it use Fuse.js to add
a search field in the generated HTML.

It could be possible take this path with Org-mode. In this case:

- It need an official json export in Org-mode to build the index

- The search field is just 2 templates: 1 for the field itself, 1 for the
  header

- We still need to include JS + CSS in the output folder in a way or another

- We can generate the index automatically for each published files or
  let the user do it in another org-publish project


This second solution could ask more steps from the user, may be less
flexible than the solution 1 and I don't know if the performance with
multiple json files is good. Maybe we need to generate only 1 JSON files
with an entry for each published files.

But: A JSON org-export could be useful for other case. After all, an
org-mode file containing headings with properties is a form of database.
Other persons could find an utility to have a JSON exporter.

And we maybe do an hybrid solution between solution 1 and 2:

- We can have a function to define new search engines plus a simple
  option in org-publish project to choose the used search engine

- And having an official JSON org exporter can be used for some search
  engines when we prefer to do the index with Org-mode/Emacs

- And the official JSON exporter can also be used manually for people
  who want or need it


What do you think ?





Ihor Radchenko <yanta...@posteo.net> writes:

> Sébastien Gendre <s...@k-7.ch> writes:
>
>> Ok, I have some free time for the next weeks.
>>
>> To summary, and to refresh my memory:
>> ...
>>
>> Did I miss something ?
>
> Everything looks right.

Attachment: signature.asc
Description: PGP signature

Reply via email to