Skip to content

Split search_index.js into Liquid data and pure JS#638

Closed
xr843 wants to merge 2 commits intobuddhist-uni:mainfrom
xr843:split-search-index
Closed

Split search_index.js into Liquid data and pure JS#638
xr843 wants to merge 2 commits intobuddhist-uni:mainfrom
xr843:split-search-index

Conversation

@xr843
Copy link
Copy Markdown
Contributor

@xr843 xr843 commented Mar 19, 2026

What

Splits search_index.js into two files:

  • search_worker_init.js — pure JavaScript logic (unaccent, OBU_STEMMER, buildSearchIndex, initSearchWorker)
  • search_index.js — keeps the Liquid/Jekyll template data (store variable) and calls initSearchWorker(store) at the end

Why

As discussed in #636, the current search_index.js mixes Liquid template syntax with JavaScript functions, which means unit tests can't import the JS logic directly — they'd need to parse Liquid first. By extracting the pure JS into a separate file, tests can import search_worker_init.js (and search_functions.js) without needing a Jekyll build.

Changes

  1. New file assets/js/search_worker_init.js: Contains unaccent, OBU_STEMMER, buildSearchIndex(store), and initSearchWorker(store) — all the pure JS that was previously in search_index.js.
  2. Modified assets/js/search_index.js: Now only has the Liquid front matter, importScripts calls (including the new file), the store data template, and initSearchWorker(store).
  3. Modified scripts/minify.bash: Also minifies search_worker_init.js during the build.

Backward compatibility

  • The web worker entry point (/assets/js/search_index.js) is unchanged from search.js's perspective
  • All function behavior is identical, just moved to a separate file
  • The importScripts loading order preserves the same dependency chain
xr843 added 2 commits March 19, 2026 21:34
Extract unaccent, OBU_STEMMER, buildSearchIndex, and initSearchWorker
into search_worker_init.js so unit tests can import the JS directly
without needing to parse Liquid/Jekyll templates.

search_index.js now only contains the Liquid template data (store variable)
and a call to initSearchWorker(store).
@netlify
Copy link
Copy Markdown

netlify Bot commented Mar 19, 2026

Deploy Preview for obu ready!

Name Link
🔨 Latest commit 0ca7c00
🔍 Latest deploy log https://app.netlify.com/projects/obu/deploys/69bbfbaa79f40000085e2493
😎 Deploy Preview https://deploy-preview-638--obu.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@khemarato
Copy link
Copy Markdown
Collaborator

The little bit of glue code left in search_index.js is fine. That we can test with E2E (manual) testing if/when we touch that file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants