Skip to content

Commit 2a191b4

Browse files
committed
add desc to orama
1 parent c8743da commit 2a191b4

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/generators/orama-db/constants.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
export const SCHEMA = {
44
title: 'string',
55
description: 'string',
6+
path: 'string',
67
};

src/generators/orama-db/index.mjs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { persistToFile } from '@orama/plugin-data-persistence/server';
55

66
import { SCHEMA } from './constants.mjs';
77
import { groupNodesByModule } from '../../utils/generators.mjs';
8+
import { transformNodeToString } from '../../utils/unist.mjs';
89

910
/**
1011
* Builds a hierarchical title chain based on heading depths
@@ -67,13 +68,16 @@ export default {
6768

6869
// Process all API groups and flatten into a single document array
6970
const documents = Array.from(apiGroups.values()).flatMap(headings =>
70-
headings.map((node, index) => {
71+
headings.map((entry, index) => {
7172
const hierarchicalTitle = buildHierarchicalTitle(headings, index);
73+
const paragraph = entry.content.children.find(
74+
child => child.type === 'paragraph'
75+
);
7276

7377
return {
7478
title: hierarchicalTitle,
75-
// TODO(@avivkeller): Add `description` key.
76-
path: `${node.api}.html#${node.slug}`,
79+
description: paragraph ? transformNodeToString(paragraph) : undefined,
80+
path: `${entry.api}.html#${entry.slug}`,
7781
};
7882
})
7983
);

0 commit comments

Comments
 (0)