Oliver-Loeffler / docbox

DocDrop: A platform to host and serve documentation artifacts from CI/CD processes.
Apache License 2.0
3 stars 0 forks source link

Add simple (yet static) search function #7

Open Oliver-Loeffler opened 1 month ago

Oliver-Loeffler commented 1 month ago

Users want to know whats inside Docbox. Hence a search page is needed. One option could be: https://pagefind.app/

Pagefind creates a static search index - the actual search is performed on client side.

Indexing can be as easy as:

npx pagefind --site /var/www/html/artifacts/

Alternatively one can define an environment variable PAGEFIND_SITE pointing to /var/www/html/artifacts/ and just run npx pagefind.

Oliver-Loeffler commented 1 month ago

Well, one can add the following snippet to ge a working search:

<html>
<head>
    <link href="pagefind/pagefind-ui.css" rel="stylesheet">
    <script src="pagefind/pagefind-ui.js"></script>
</head>
<body>
    <div id="search"></div>
    <script>
        window.addEventListener('DOMContentLoaded', (event) => {
            new PagefindUI({ element: "#search", showSubResults: true });
        });
    </script>
    </body>
</html>

This requires that pagefind has created an index.