Jieiku / abridge

Fast & Lightweight Zola Theme
https://abridge.pages.dev/
MIT License
142 stars 41 forks source link

Add pagefind search to abridge #179

Open Hysterelius opened 5 days ago

Hysterelius commented 5 days ago

I have added a new pagefind.index.js, which can successfully build the index.

What needs to be fixed:

netlify[bot] commented 5 days ago

Deploy Preview for abridge failed.

Name Link
Latest commit c8e2609e4a7ddc778bd6f61db5f1282666125c6f
Latest deploy log https://app.netlify.com/sites/abridge/deploys/6688a4c780e7c200095ddc52
Hysterelius commented 5 days ago

@Jieiku The pagefind has to write to static to make sure that all the files get included in public/, do you want all these files to be added to git?

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   static/js/abridge.min.js
    modified:   static/js/abridge_nopwa.min.js
    modified:   static/sw.js
    modified:   static/sw.min.js

Untracked files:
  (use "git add <file>..." to include in what will be committed)
    index.html
    static/js/fragment/
    static/js/index/
    static/js/pagefind-entry.json
    static/js/pagefind-highlight.js
    static/js/pagefind-modular-ui.css
    static/js/pagefind-modular-ui.js
    static/js/pagefind-ui.css
    static/js/pagefind-ui.js
    static/js/pagefind.en_ccab42ec59.pf_meta
    static/js/pagefind.en_d5bbd35c84.pf_meta
    static/js/pagefind.es_62f452c0d4.pf_meta
    static/js/pagefind.es_7556d6166a.pf_meta
    static/js/pagefind.fr_78454663b6.pf_meta
    static/js/pagefind.fr_b5d517652d.pf_meta
    static/js/pagefind.js
    static/js/wasm.en.pagefind
    static/js/wasm.es.pagefind
    static/js/wasm.fr.pagefind
    static/js/wasm.unknown.pagefind
Jieiku commented 5 days ago

Initially it is fine to add whatever you need to add to static, it can always be changed later if needed.

I have been busy with work and will be a couple more days but I can't wait to check this out once I get a little down time.

Hysterelius commented 4 days ago

I just wondering how you do testing with abridge? Like the base url attribute means that it tries to fetch from netlify and when I tried to change it to localhost I got some weird errors... None of the "sha384" hashes in the integrity attribute match the content of the subresource

Jieiku commented 4 days ago

For most things I test using zola serve.

When I want to test a live build I push it to one of my development containers in my proxmox server. I have haproxy handing SSL termination and just hardcode a host override in the unbound dns resolver (but you could just as easily do it in your hosts file.)

I use the following bash script to build a site and push it to my container:

    # change directory to my site that uses abridge on my local workstation
    cd ~/.dev/mytestdomain.com
    # update abridge
    git submodule update --init --recursive
    git submodule update --remote --merge
    # update the abridge theme node backage in my root site that is using abridge as a submodule
    rsync themes/abridge/package_abridge.js package_abridge.js
    rsync themes/abridge/package.json package.json
    # build the site
    npm run abridge
    cd public
    # The following line is optional it is just to pre gzip/brotli the content to save some cpu cycles when serving content.
    find ~/.dev/mytestdomain.com/public -type f -regextype posix-extended -regex '.*\.(htm|html|css|js|json|xml|xsl|txt|svg|otf|eot|ttf|webmanifest)' -exec gzip --best -k -f {} \+ -exec brotli --best -f {} \;
    # rsync transfers the data to the development container
    rsync -zvrhog --chown=www-data:www-data --delete ~/.dev/mytestdomain.com/public/ webdev:/var/www/mytestdomain.com

Your error indicates that the integrity value of a script does not match what is listed in the head, it has to do with lines like this:

<script src="https://abridge.pages.dev/js/theme.min.js" integrity="sha384-pb++s6uBRKaQv+iAXpgA/H3IlpLZdO14tTwuCI7uXmz4aaZdByoCcM+6BhynMq/1"></script>

<script defer src="https://abridge.pages.dev/js/abridge.min.js?h=4dbe2f6c7673e0a145f0" integrity="sha384-en9uTP2jQMLjO9fwbuGUKlCZ+kGMvN97ASddcA7mljWRGw70rs3zSMPNIozwGYFU"></script>

Zola generates these hashes when we issue a zola build, and because abridge minifies and bundles js files, it is the reason the node script issues zola build twice, once to generate the index, then after minification and bundling it does a second zola build to generate the correct integrity hashes for the newly minified/bundled js files.