@barodoc/plugin-docsearch 7.0.0 → 8.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,12 @@
1
+ import * as _barodoc_core from '@barodoc/core';
2
+
3
+ interface DocSearchPluginOptions {
4
+ appId: string;
5
+ apiKey: string;
6
+ indexName: string;
7
+ container?: string;
8
+ placeholder?: string;
9
+ }
10
+ declare const _default: (options: DocSearchPluginOptions) => _barodoc_core.BarodocPlugin;
11
+
12
+ export { type DocSearchPluginOptions, _default as default };
package/dist/index.js ADDED
@@ -0,0 +1,56 @@
1
+ // src/index.ts
2
+ import { definePlugin } from "@barodoc/core";
3
+ var index_default = definePlugin((options) => {
4
+ return {
5
+ name: "@barodoc/plugin-docsearch",
6
+ hooks: {
7
+ "config:loaded": (config) => {
8
+ return {
9
+ ...config,
10
+ search: { ...config.search, enabled: false }
11
+ };
12
+ }
13
+ },
14
+ astroIntegration: () => {
15
+ const integration = {
16
+ name: "@barodoc/plugin-docsearch",
17
+ hooks: {
18
+ "astro:config:setup": ({ injectScript }) => {
19
+ const cssUrl = "https://cdn.jsdelivr.net/npm/@docsearch/css@3/dist/style.min.css";
20
+ const jsUrl = "https://cdn.jsdelivr.net/npm/@docsearch/js@3";
21
+ injectScript(
22
+ "head-inline",
23
+ `document.head.insertAdjacentHTML('beforeend', '<link rel="stylesheet" href="${cssUrl}" />');`
24
+ );
25
+ injectScript(
26
+ "page",
27
+ `
28
+ import docsearch from "${jsUrl}";
29
+
30
+ function initDocSearch() {
31
+ const container = document.querySelector('${options.container || "#docsearch"}');
32
+ if (!container || container.hasChildNodes()) return;
33
+ docsearch({
34
+ appId: "${options.appId}",
35
+ apiKey: "${options.apiKey}",
36
+ indexName: "${options.indexName}",
37
+ container: "${options.container || "#docsearch"}",
38
+ placeholder: "${options.placeholder || "Search docs..."}",
39
+ });
40
+ }
41
+
42
+ if (document.readyState === "complete") initDocSearch();
43
+ else document.addEventListener("DOMContentLoaded", initDocSearch);
44
+ document.addEventListener("astro:page-load", initDocSearch);
45
+ `
46
+ );
47
+ }
48
+ }
49
+ };
50
+ return integration;
51
+ }
52
+ };
53
+ });
54
+ export {
55
+ index_default as default
56
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barodoc/plugin-docsearch",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
4
4
  "description": "Algolia DocSearch plugin for Barodoc",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -16,14 +16,14 @@
16
16
  ],
17
17
  "peerDependencies": {
18
18
  "astro": "^5.0.0",
19
- "@barodoc/core": "7.0.0"
19
+ "@barodoc/core": "8.0.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/node": "^22.0.0",
23
23
  "astro": "^5.0.0",
24
24
  "tsup": "^8.3.0",
25
25
  "typescript": "^5.7.0",
26
- "@barodoc/core": "7.0.0"
26
+ "@barodoc/core": "8.0.0"
27
27
  },
28
28
  "license": "MIT",
29
29
  "scripts": {