UNPKG

vitepress-plugin-llmstxt

Version:

VitePress plugin to generate llms.txt files automatically

20 lines (17 loc) 499 B
import { useData, useRoute } from 'vitepress'; const getAllData = () => { const { theme } = useData(); return theme.value.llmstxt.pageData; }; const getRouteData = () => { try { const route = useRoute(); const data = getAllData(); const routPath = route.path.endsWith("/") ? route.path.slice(0, -1) : route.path; return data?.find((d) => d.url === routPath); } catch (e) { console.warn("No route data found", e); return; } }; export { getAllData, getRouteData };