try to improve search
This commit is contained in:
1 parent
cc92419dca
commit
62ccab7522
3 files changed
+43
No files matched your search
@@ -60,6 +60,9 @@ jobs:
|
|||||||
- name: Install theme package
|
- name: Install theme package
|
||||||
working-directory: site
|
working-directory: site
|
||||||
run: npm install @quartz-themes/everforest-spruce
|
run: npm install @quartz-themes/everforest-spruce
|
||||||
|
- name: Patch search fuzz
|
||||||
|
working-directory: site
|
||||||
|
run: python ../publish/quartz-patches/apply.py search
|
||||||
- name: Build Quartz
|
- name: Build Quartz
|
||||||
working-directory: site
|
working-directory: site
|
||||||
run: npx quartz build -d ..
|
run: npx quartz build -d ..
|
||||||
|
|||||||
@@ -24,6 +24,16 @@ SCRIPT: Path = Path(__file__).resolve()
|
|||||||
VAULT: Path = SCRIPT.parents[2]
|
VAULT: Path = SCRIPT.parents[2]
|
||||||
QUARTZ_REPO: Path = VAULT / "site" / "quartz"
|
QUARTZ_REPO: Path = VAULT / "site" / "quartz"
|
||||||
SPA_FILE: Path = QUARTZ_REPO / "components" / "scripts" / "spa.inline.ts"
|
SPA_FILE: Path = QUARTZ_REPO / "components" / "scripts" / "spa.inline.ts"
|
||||||
|
SEARCH_FILE: Path = (
|
||||||
|
VAULT
|
||||||
|
/ "site"
|
||||||
|
/ "node_modules"
|
||||||
|
/ "@quartz-community"
|
||||||
|
/ "search"
|
||||||
|
/ "dist"
|
||||||
|
/ "components"
|
||||||
|
/ "index.js"
|
||||||
|
)
|
||||||
PUBLIC: Path = VAULT / "site" / "public"
|
PUBLIC: Path = VAULT / "site" / "public"
|
||||||
OVERLAY: Path = VAULT / "publish" / "quartz.config.yaml"
|
OVERLAY: Path = VAULT / "publish" / "quartz.config.yaml"
|
||||||
|
|
||||||
@@ -128,6 +138,30 @@ def patch_spa() -> bool:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
SEARCH_CONTENT_FORWARD: str = '{field:"content",tokenize:"forward"}'
|
||||||
|
SEARCH_CONTENT_FULL: str = '{field:"content",tokenize:"full"}'
|
||||||
|
|
||||||
|
|
||||||
|
def patch_search() -> bool:
|
||||||
|
"""Index note bodies with FlexSearch `full` tokenize (substring match)."""
|
||||||
|
if not SEARCH_FILE.exists():
|
||||||
|
print(f"missing {SEARCH_FILE}")
|
||||||
|
return False
|
||||||
|
text = SEARCH_FILE.read_text(encoding="utf-8")
|
||||||
|
if SEARCH_CONTENT_FULL in text:
|
||||||
|
print("search already patched")
|
||||||
|
return True
|
||||||
|
if SEARCH_CONTENT_FORWARD not in text:
|
||||||
|
print("search content tokenize missing")
|
||||||
|
return False
|
||||||
|
SEARCH_FILE.write_text(
|
||||||
|
text.replace(SEARCH_CONTENT_FORWARD, SEARCH_CONTENT_FULL, 1),
|
||||||
|
encoding="utf-8",
|
||||||
|
)
|
||||||
|
print("search patched")
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
# --- post-build HTML rewrites ----------------------------------------------
|
# --- post-build HTML rewrites ----------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
@@ -199,6 +233,11 @@ def main() -> int:
|
|||||||
if not ok and mode == "spa":
|
if not ok and mode == "spa":
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
if mode in ("search", "all"):
|
||||||
|
ok = patch_search()
|
||||||
|
if not ok and mode == "search":
|
||||||
|
return 1
|
||||||
|
|
||||||
if mode in ("built", "all"):
|
if mode in ("built", "all"):
|
||||||
b, t, total = rewrite_built_htmls()
|
b, t, total = rewrite_built_htmls()
|
||||||
print(f"base tag: {b}, title link: {t}, total {total}")
|
print(f"base tag: {b}, title link: {t}, total {total}")
|
||||||
|
|||||||
@@ -12,3 +12,4 @@ Set-Location -LiteralPath $site
|
|||||||
npm ci
|
npm ci
|
||||||
npx quartz plugin install --from-config
|
npx quartz plugin install --from-config
|
||||||
npm install @quartz-themes/everforest-spruce
|
npm install @quartz-themes/everforest-spruce
|
||||||
|
python (Join-Path $PSScriptRoot "quartz-patches\apply.py") search
|
||||||
Reference in new issue
Block a user