diff --git a/.vitepress/config.ts b/.vitepress/config.ts index cbe44bf..395b8bb 100644 --- a/.vitepress/config.ts +++ b/.vitepress/config.ts @@ -86,7 +86,7 @@ export default defineConfig({ ], footer: { - message: `UnitsDB · Schemas · Learn · GitHub`, + message: `UnitsDB · Schemas · Learn · Get Started · Software · GitHub`, copyright: 'Copyright © 2026 UnitsML Group' }, @@ -131,6 +131,7 @@ export default defineConfig({ { text: 'Overview', link: '/schemas' }, { text: 'UnitsML XML Schemas', link: '/schemas#unitsml-xml-schemas' }, { text: 'UnitsDB YAML Schemas', link: '/schemas#unitsdb-yaml-schemas' }, + { text: 'Schema Browser', link: '/schemas#schema-browser' }, ] } ], diff --git a/.vitepress/posts.data.ts b/.vitepress/posts.data.ts index 795f04e..233449b 100644 --- a/.vitepress/posts.data.ts +++ b/.vitepress/posts.data.ts @@ -7,6 +7,7 @@ interface Post { authors: string[] description: string lastUpdated: number | undefined + readingTime: number } declare const data: Post[] @@ -16,14 +17,18 @@ export default createContentLoader('blog/*.md', { transform(raw): Post[] { return raw .filter((page) => !page.url.endsWith('/blog/')) - .map((page) => ({ - title: page.frontmatter.title, - url: page.url, - date: page.frontmatter.date, - authors: page.frontmatter.authors || [], - description: page.frontmatter.description || '', - lastUpdated: page.lastUpdated, - })) + .map((page) => { + const wordCount = page.src ? page.src.split(/\s+/).length : 0 + return { + title: page.frontmatter.title, + url: page.url, + date: page.frontmatter.date, + authors: page.frontmatter.authors || [], + description: page.frontmatter.description || '', + lastUpdated: page.lastUpdated, + readingTime: Math.max(1, Math.round(wordCount / 200)), + } + }) .sort((a, b) => { const dateA = new Date(a.date).getTime() const dateB = new Date(b.date).getTime() diff --git a/.vitepress/theme/components/BlogByline.vue b/.vitepress/theme/components/BlogByline.vue index 430d768..b692a97 100644 --- a/.vitepress/theme/components/BlogByline.vue +++ b/.vitepress/theme/components/BlogByline.vue @@ -31,13 +31,20 @@ const authors = computed(() => { if (a.length === 2) return `${a[0]} & ${a[1]}` return a.slice(0, -1).join(', ') + ' & ' + a[a.length - 1] }) + +const authorInitials = computed(() => { + const a = frontmatter.value.authors + if (!a || !Array.isArray(a) || a.length === 0) return '' + return a.map((name: string) => name.split(' ').map((n: string) => n[0]).join('')).join(' ') +})