All repositories

astro-lunr

License

Lunr integration for Astro; client-side search for statically hosted pages.

2022-05-14 17:06 #1: fixed base path replacement problem
Siver K. Volle 3f44311
2022-05-14 17:06 #1: fixed base path replacement problem master Siver K. Volle 3f44311
2022-05-01 13:57 Fixed problem with import.meta.env when proper npm-module Siver K. Volle 00a915f
2022-04-18 20:31 add demo-link to readme Siver K. Volle d930b81
2022-04-18 19:51 initial steps to turn astro-lunr into its own repo Siver K. Volle 9983ab3
2022-04-18 18:39 better lunr in dev-mode; better file diffs Siver K. Volle 182546c
2022-04-17 19:29 support for github pages; max-lines in file view Siver K. Volle 1612826
2022-04-16 00:25 Included readme and licenses; made the plugins into npm-modules; removed more dead-links and ui/ux-bugs Siver K. Volle 077a354
2022-04-15 17:21 Multi-repo support; refactored astro-git and astro-lunr into independent plugins Siver K. Volle adfedbe
2022-04-14 10:00 lunr-based indexing and search integration; assorted minor ux/ui improvements Siver K. Volle 146ebb5

Differences for commit 9983ab39491aed97762bd060ca41b08840a59f18

client/lunr.js | +2L -3L 9% changed
to file
0 import lunr from 'lunr';
1
2 const LUNR_DIR = import.meta.env.PUBLIC_LUNR_DIR || "";
3 - const BASE_URL = import.meta.env.PUBLIC_BASE_URL || "/";
4
5 function join(...path){
...
10 export async function getIndex(index = ""){
11 if(!idxMap.has(index)){
12 - let response = await fetch(join(BASE_URL, LUNR_DIR, index, "idx.json"));
13 + let response = await fetch(join(LUNR_DIR, index, "idx.json"));
14 if(response.status !== 200){
15 throw new Error(`Astro-lunr: idx.json not found for index=${index}`);
...
24 export async function getDocs(index = ""){
25 if(!docMap.has(index)){
26 - let response = await fetch(join(BASE_URL, LUNR_DIR, index, "docs.json"));
27 + let response = await fetch(join(LUNR_DIR, index, "docs.json"));
28 if(response.status !== 200){
29 throw new Error(`Astro-lunr: docs.json not found for index=${index}`);
...
51 }
52 })
package.json | +13L -1L 47% changed
to file
0 {
1 - "name": "astro-lunr",
2 + "name": "@siverv/astro-lunr",
3 "version": "0.0.1",
4 "private": true,
5 "license" : "GPL-3.0",
6 "description": "Lunr integration for Astro",
7 "type": "module",
8 + "homepage": "https://siverv.github.io/astro-git-view/astro-lunr/",
9 + "contributors": [
10 + {
11 + "name": "Siver K. Volle",
12 + "email": "package-json.astro-lunr@siverv.no",
13 + "url": "https://www.siverv.no"
14 + }
15 + ],
16 + "repository": {
17 + "type": "git",
18 + "url": "https://github.com/siverv/astro-lunr.git"
19 + },
20 "exports": {
21 "./plugin.mjs": "./plugin.mjs",
...
27 "rehype": "^12.0.1"
28 }
plugin.mjs | +4L -4L 5% changed
to file
0 import fs from 'node:fs';
1 import path from 'node:path';
...
57 export function createVitePlugin({ config }) {
58 return {
59 - name: 'astro-lunr:dev-server',
60 + name: '@siverv/astro-lunr:dev-server',
61 configureServer(viteServer) {
62 viteServer.middlewares.use((req, res, next) => {
...
97 let pathsToIndex = []
98 return {
99 - name: 'lunr-filenames',
100 + name: '@siverv/astro-lunr:plugin',
101 hooks: {
102 'astro:config:setup': (options) => {
103 if(options.command === "dev"){
104 options.addRenderer({
105 - name: 'lunr-renderer',
106 - serverEntrypoint: 'astro-lunr/server/renderer.js',
107 + name: '@siverv/astro-lunr:renderer',
108 + serverEntrypoint: '@siverv/astro-lunr/server/renderer.js',
109 });
110 options.updateConfig({ vite: getViteConfiguration(options) });
...
160 }
161 }
README.md | +1L 1% changed
to file
0
1
...
31 | `verbose` | boolean | Debug log |
32
33 + If using `subDir` or the astro-config `base`, set the env-variable `PUBLIC_LUNR_DIR` to be `/base/subDir/`
34
35 ### Example from astro-git-view
...
107 To properly search files that are not usually genereated in the build-step, you would need to have a separate build-step that includes all pages that might be generated.
108