-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSearchWrapper.astro
More file actions
38 lines (33 loc) · 1.2 KB
/
Copy pathSearchWrapper.astro
File metadata and controls
38 lines (33 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
---
import SearchDialog from './SearchDialog';
import { getCollection } from 'astro:content';
// Get all searchable content
const blogPosts = await getCollection('blog', ({ data }) => !data.draft);
const notes = await getCollection('notes');
// Build search items
const searchItems = [
// Pages
{ title: 'Home', href: '/', type: 'page' as const },
{ title: 'Blog', href: '/blog/', type: 'page' as const },
{ title: 'Notes', href: '/notes/', type: 'page' as const },
{ title: 'About', href: '/about/', type: 'page' as const },
{ title: 'Contact', href: '/contact/', type: 'page' as const },
{ title: 'Reading List', href: '/reading-list/', type: 'page' as const },
{ title: 'Writing', href: '/writing/', type: 'page' as const },
{ title: 'Videos', href: '/videos/', type: 'page' as const },
{ title: 'Case Studies', href: '/case-studies/', type: 'page' as const },
// Blog posts
...blogPosts.map((post) => ({
title: post.data.title,
href: `/blog/${post.slug}/`,
type: 'blog' as const,
})),
// Notes
...notes.map((note) => ({
title: note.data.title,
href: note.data.tweet_url || `/notes/`,
type: 'note' as const,
})),
];
---
<SearchDialog client:idle items={searchItems} />