Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export default defineConfig({
],

footer: {
message: `<a href="/unitsdb/">UnitsDB</a> · <a href="/schemas.html">Schemas</a> · <a href="/learn/what-is-unitsml.html">Learn</a> · <a href="https://github.com/unitsml">GitHub</a>`,
message: `<a href="/unitsdb/">UnitsDB</a> · <a href="/schemas.html">Schemas</a> · <a href="/learn/what-is-unitsml.html">Learn</a> · <a href="/get-started.html">Get Started</a> · <a href="/software/">Software</a> · <a href="https://github.com/unitsml">GitHub</a>`,
copyright: 'Copyright © 2026 UnitsML Group'
},

Expand Down Expand Up @@ -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' },
]
}
],
Expand Down
21 changes: 13 additions & 8 deletions .vitepress/posts.data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface Post {
authors: string[]
description: string
lastUpdated: number | undefined
readingTime: number
}

declare const data: Post[]
Expand All @@ -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()
Expand Down
16 changes: 15 additions & 1 deletion .vitepress/theme/components/BlogByline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ')
})
</script>

<template>
<div class="blog-byline" v-if="authors || formattedDate">
<div class="byline-content">
<div class="author-info" v-if="authors">
<svg class="author-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<span class="author-avatar" v-if="authorInitials">{{ authorInitials }}</span>
<svg v-else class="author-icon" width="18" height="18" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/>
<circle cx="12" cy="7" r="4"/>
</svg>
Expand Down Expand Up @@ -94,6 +101,13 @@ const authors = computed(() => {
flex-shrink: 0;
}

.author-avatar {
width: 28px; height: 28px; border-radius: 50%;
background: var(--vp-c-brand-soft); color: var(--vp-c-brand-1);
display: flex; align-items: center; justify-content: center;
font-size: 0.6875rem; font-weight: 700; flex-shrink: 0;
}

.date-icon {
color: var(--vp-c-text-3);
flex-shrink: 0;
Expand Down
22 changes: 17 additions & 5 deletions .vitepress/theme/components/BlogIndex.vue
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,14 @@ function formatAuthors(authors: string[]): string {
<span class="post-authors">
By {{ formatAuthors(post.authors) }}
</span>
<span class="read-more">
Read article
<svg class="arrow-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M5 12h14M12 5l7 7-7 7"/>
</svg>
<span class="post-meta">
<span class="reading-time">{{ post.readingTime }} min read</span>
<span class="read-more">
Read article
<svg class="arrow-icon" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M5 12h14M12 5l7 7-7 7"/>
</svg>
</span>
</span>
</div>
</div>
Expand Down Expand Up @@ -232,6 +235,15 @@ function formatAuthors(authors: string[]): string {
color: var(--vp-c-text-3);
}

.post-meta {
display: flex; align-items: center; gap: 0.75rem;
}

.reading-time {
font-size: 0.75rem;
color: var(--vp-c-text-3);
}

.read-more {
display: flex;
align-items: center;
Expand Down
Loading
Loading