Skip to content

Commit 16ad928

Browse files
committed
add guide title to guides index entries
1 parent ac73ad2 commit 16ad928

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

data-api/fetchGuides.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export default async function fetchDocs() {
88
const files = await fg(directory + '/**/*.md')
99

1010
return files.map(fileName => {
11+
const isIndex = fileName.endsWith('/index.md')
1112
const fullPath = path.resolve(directory, fileName)
1213

1314
const slug = fullPath
@@ -18,8 +19,15 @@ export default async function fetchDocs() {
1819

1920
const file = fs.readFileSync(fullPath)
2021
const doc = matter(file)
22+
let guideTitle = null
23+
if (!isIndex) {
24+
const guideMeta = JSON.parse(
25+
fs.readFileSync(`${path.dirname(fullPath)}/meta.json`)
26+
)
27+
guideTitle = guideMeta.title
28+
}
2129
return {
22-
data: { ...doc.data, slug },
30+
data: { ...doc.data, slug, guideTitle },
2331
content: doc.content,
2432
}
2533
})

0 commit comments

Comments
 (0)