Skip to content

Commit 88282d1

Browse files
committed
fix: remove unused General type and related code from docs utility functions
1 parent 6b2c494 commit 88282d1

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

apps/website/src/utils/docs.ts

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,21 @@ import {
77
allShikis,
88
allReacts,
99
allShighs,
10-
type General,
1110
type Gstarted,
1211
type Shiki,
1312
type Shigh,
1413
type React,
1514
} from "content-collections";
1615

1716
const allDocsArray = [
18-
...allGenerals,
1917
...allGstarteds,
2018
...allShikis,
2119
...allShighs,
2220
...allReacts,
2321
];
2422

2523
type Doc = Document &
26-
(General | Gstarted | Shiki | Shigh | React) & {
24+
(Gstarted | Shiki | Shigh | React) & {
2725
tableOfContents: ToCItem[];
2826
};
2927

@@ -69,16 +67,13 @@ const getDocsByFolder = () => {
6967
);
7068
};
7169

72-
const getDocumentContent = ({
73-
folder,
74-
document,
75-
}: GetDocument): string | undefined => {
76-
const normalizedDocument = document.replace(/\\/g, "/");
77-
const doc = allDocs.find((doc) => {
78-
const normalizedPath = doc._meta.path.replace(/\\/g, "/");
79-
return doc.folder === folder && normalizedPath === normalizedDocument;
80-
});
81-
return doc ? doc.mdx : undefined;
70+
const getGeneralDocument = (document: string): Doc | undefined => {
71+
const doc = allGenerals.find((doc) => doc._meta.path === document);
72+
if (!doc) {
73+
return undefined;
74+
}
75+
const tableOfContents = getTableOfContents(doc.content);
76+
return { ...doc, tableOfContents };
8277
};
8378

84-
export { getDocument, getDocsByFolder, getDocumentContent };
79+
export { getDocument, getDocsByFolder, getGeneralDocument };

0 commit comments

Comments
 (0)