fumadocs-core 12.4.0 → 12.4.2

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.
@@ -22,7 +22,9 @@ interface SimpleOptions {
22
22
  interface AdvancedOptions {
23
23
  indexes: AdvancedIndex[] | Dynamic<AdvancedIndex>;
24
24
  /**
25
- * Enabled custom tags
25
+ * Enable search tags for filtering results
26
+ *
27
+ * @defaultValue false
26
28
  */
27
29
  tag?: boolean;
28
30
  language?: string;
@@ -47,6 +49,7 @@ declare function initSearchAPI({ indexes, language }: SimpleOptions): SearchAPI;
47
49
  interface AdvancedIndex {
48
50
  id: string;
49
51
  title: string;
52
+ keywords?: string;
50
53
  /**
51
54
  * Required if `tag` is enabled
52
55
  */
@@ -117,25 +117,30 @@ function initSearchAPIAdvanced({
117
117
  language,
118
118
  tag = false
119
119
  }) {
120
- const store = ["id", "url", "content", "page_id", "type"];
120
+ const store = ["id", "url", "content", "page_id", "type", "keywords"];
121
121
  function getDocument() {
122
122
  return __async(this, null, function* () {
123
123
  const items = typeof indexes === "function" ? yield indexes() : indexes;
124
124
  const index = new Document({
125
125
  language,
126
126
  cache: 100,
127
- tokenize: "forward",
128
127
  optimize: true,
129
- context: {
130
- depth: 2,
131
- bidirectional: true,
132
- resolution: 9
133
- },
134
128
  document: {
135
129
  id: "id",
136
130
  tag: tag ? "tag" : void 0,
137
131
  store,
138
- index: ["content"]
132
+ index: [
133
+ {
134
+ field: "content",
135
+ tokenize: "forward",
136
+ context: { depth: 2, bidirectional: true, resolution: 9 }
137
+ },
138
+ {
139
+ field: "keywords",
140
+ tokenize: "strict",
141
+ resolution: 9
142
+ }
143
+ ]
139
144
  }
140
145
  });
141
146
  for (const page of items) {
@@ -146,6 +151,7 @@ function initSearchAPIAdvanced({
146
151
  page_id: page.id,
147
152
  type: "page",
148
153
  content: page.title,
154
+ keywords: page.keywords,
149
155
  tag: page.tag,
150
156
  url: page.url
151
157
  });
@@ -185,8 +191,8 @@ function initSearchAPIAdvanced({
185
191
  const map = /* @__PURE__ */ new Map();
186
192
  for (const item of (_b = (_a = results[0]) == null ? void 0 : _a.result) != null ? _b : []) {
187
193
  if (item.doc.type === "page") {
188
- if (!map.has(item.doc.page_id)) {
189
- map.set(item.doc.page_id, []);
194
+ if (!map.has(item.doc.id)) {
195
+ map.set(item.doc.id, []);
190
196
  }
191
197
  continue;
192
198
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fumadocs-core",
3
- "version": "12.4.0",
3
+ "version": "12.4.2",
4
4
  "description": "The library for building a documentation website in Next.js",
5
5
  "keywords": [
6
6
  "NextJs",