diff --git a/package-lock.json b/package-lock.json index e0a65a6..5a2c60c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,12 +8,14 @@ "axios": "^0.21.1", "dayjs": "^1.10.5", "highlight.js": "^11.0.0", + "lunr": "^2.3.9", "svelte-cloudinary": "^0.2.3" }, "devDependencies": { "@sveltejs/adapter-static": "next", "@sveltejs/kit": "next", "@types/highlight.js": "^10.1.0", + "@types/lunr": "^2.3.4", "svelte": "^3.34.0", "svelte-check": "^2.0.0", "svelte-preprocess": "^4.0.0", @@ -98,6 +100,12 @@ "highlight.js": "*" } }, + "node_modules/@types/lunr": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@types/lunr/-/lunr-2.3.4.tgz", + "integrity": "sha512-j4x4XJwZvorEUbA519VdQ5b9AOU9TSvfi8tvxMAfP8XzNLtFex7A8vFQwqOx3WACbV0KMXbACV3cZl4/gynQ7g==", + "dev": true + }, "node_modules/@types/node": { "version": "16.7.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.1.tgz", @@ -550,6 +558,11 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "node_modules/lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==" + }, "node_modules/magic-string": { "version": "0.25.7", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", @@ -1028,6 +1041,12 @@ "highlight.js": "*" } }, + "@types/lunr": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/@types/lunr/-/lunr-2.3.4.tgz", + "integrity": "sha512-j4x4XJwZvorEUbA519VdQ5b9AOU9TSvfi8tvxMAfP8XzNLtFex7A8vFQwqOx3WACbV0KMXbACV3cZl4/gynQ7g==", + "dev": true + }, "@types/node": { "version": "16.7.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-16.7.1.tgz", @@ -1362,6 +1381,11 @@ "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" }, + "lunr": { + "version": "2.3.9", + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.9.tgz", + "integrity": "sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow==" + }, "magic-string": { "version": "0.25.7", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.7.tgz", diff --git a/package.json b/package.json index 7234f91..7a0fa2e 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "@sveltejs/adapter-static": "next", "@sveltejs/kit": "next", "@types/highlight.js": "^10.1.0", + "@types/lunr": "^2.3.4", "svelte": "^3.34.0", "svelte-check": "^2.0.0", "svelte-preprocess": "^4.0.0", @@ -22,6 +23,7 @@ "axios": "^0.21.1", "dayjs": "^1.10.5", "highlight.js": "^11.0.0", + "lunr": "^2.3.9", "svelte-cloudinary": "^0.2.3" } } diff --git a/src/lib/components/SearchResult.svelte b/src/lib/components/SearchResult.svelte index 900a2ff..b21ddc1 100644 --- a/src/lib/components/SearchResult.svelte +++ b/src/lib/components/SearchResult.svelte @@ -1,5 +1,12 @@ - + + - Works + Blog - {data.title} - + {#if data.content} diff --git a/src/routes/blog/index.svelte b/src/routes/blog/index.svelte index 4af7abc..0422a8c 100644 --- a/src/routes/blog/index.svelte +++ b/src/routes/blog/index.svelte @@ -1,6 +1,7 @@ + + + + + + {#if needle} +
    + {#each results as result (result.ref)} + + {/each} +
+ {:else} +

Start typing...

+ {/if} +
+ +