Add headings in search result

This commit is contained in:
Sat Naing
2022-09-25 19:44:36 +06:30
parent 3f52daf865
commit d275f607a3
2 changed files with 7 additions and 5 deletions
+5 -4
View File
@@ -15,10 +15,11 @@ const posts = await Astro.glob<Frontmatter>("../contents/*.md");
// List of items to search in
const searchList = posts
.filter(({ frontmatter }) => !frontmatter.draft)
.map(({ frontmatter }) => ({
title: frontmatter.title,
description: frontmatter.description,
frontmatter,
.map((post) => ({
title: post.frontmatter.title,
description: post.frontmatter.description,
headings: post.getHeadings().map((h) => h.text),
frontmatter: post.frontmatter,
}));
---