File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
1716const allDocsArray = [
18- ...allGenerals ,
1917 ...allGstarteds ,
2018 ...allShikis ,
2119 ...allShighs ,
2220 ...allReacts ,
2321] ;
2422
2523type 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 } ;
You can’t perform that action at this time.
0 commit comments