mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
20 lines
489 B
TypeScript
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 };
|
|
}
|