Files
AFFiNE-Mirror/blocksuite/docs-site/.vitepress/theme/composables/use-posts.ts
T
2026-04-29 17:23:23 +08:00

20 lines
489 B
TypeScript

import { useRoute } from 'vitepress';
import { computed } from 'vue';
import { data as posts } from './posts.data';
export function usePosts() {
const route = useRoute();
const path = route.path;
function findCurrentIndex() {
const result = posts.findIndex(p => p.url === route.path);
if (result === -1) console.error(`blog post missing: ${route.path}`);
return result;
}
const post = computed(() => posts[findCurrentIndex()]);
return { posts, post, path };
}