From 8a6d697308162874a236c84aac0b0f8c7ac01f83 Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Tue, 1 Sep 2026 14:48:45 +0300 Subject: refactor: separate website presentation from runtime --- website/src/components/AuthorCard.astro | 30 --- website/src/components/Banner.astro | 75 ------- website/src/components/ConfigReference.astro | 204 ------------------ website/src/components/DocsVersionSelect.astro | 84 -------- website/src/components/Head.astro | 67 ------ website/src/components/Header.astro | 99 --------- website/src/components/MarketingLayout.astro | 274 ------------------------- website/src/components/Search.astro | 52 ----- website/src/components/Sidebar.astro | 53 ----- website/src/components/SiteLayout.astro | 223 -------------------- website/src/components/SiteTitle.astro | 95 --------- 11 files changed, 1256 deletions(-) delete mode 100644 website/src/components/AuthorCard.astro delete mode 100644 website/src/components/Banner.astro delete mode 100644 website/src/components/ConfigReference.astro delete mode 100644 website/src/components/DocsVersionSelect.astro delete mode 100644 website/src/components/Head.astro delete mode 100644 website/src/components/Header.astro delete mode 100644 website/src/components/MarketingLayout.astro delete mode 100644 website/src/components/Search.astro delete mode 100644 website/src/components/Sidebar.astro delete mode 100644 website/src/components/SiteLayout.astro delete mode 100644 website/src/components/SiteTitle.astro (limited to 'website/src/components') diff --git a/website/src/components/AuthorCard.astro b/website/src/components/AuthorCard.astro deleted file mode 100644 index ba3a1014..00000000 --- a/website/src/components/AuthorCard.astro +++ /dev/null @@ -1,30 +0,0 @@ ---- -const name = 'Can Celik'; -const role = 'Building Herdr'; -const photo = '/assets/author-can.jpeg'; -const x = 'https://x.com/cancelik'; -const email = 'can@herdr.dev'; ---- - - diff --git a/website/src/components/Banner.astro b/website/src/components/Banner.astro deleted file mode 100644 index cc6567a6..00000000 --- a/website/src/components/Banner.astro +++ /dev/null @@ -1,75 +0,0 @@ ---- -import versions from '../data/docs-versions.json'; -import { docsRoute, docsTargetHref } from '../docs-path'; - -const { entry, locale, isFallback } = Astro.locals.starlightRoute; -const { banner } = entry.data; - -const issuesUrl = 'https://github.com/herdrdev/herdr/issues/new?template=translation.yml'; -const translationNotices = { - ja: `このページの翻訳は LLM によって生成されています。誤りに気づいた場合は GitHub で issue を開いてお知らせください。`, - 'zh-cn': `本页面的翻译由 LLM 生成。如果你发现翻译有误,请在 GitHub 上提交 issue 告诉我们。`, -}; -const translationNotice = locale && !isFallback ? translationNotices[locale] : undefined; -const docs = docsRoute(Astro.url.pathname); -const archivedVersion = - docs.target !== 'stable' && docs.target !== 'preview' && docs.target !== versions.current - ? docs.target - : undefined; -const latestHref = docsTargetHref(docs, 'stable', versions.scopes); -const archivedNotices = { - root: `This page documents Herdr ${archivedVersion}. Switch to the latest release.`, - ja: `このページは Herdr ${archivedVersion} のドキュメントです。最新版に切り替えてください。`, - 'zh-cn': `本页面是 Herdr ${archivedVersion} 的文档。切换到最新版本。`, -}; -const archivedNotice = archivedVersion ? archivedNotices[locale ?? 'root'] : undefined; ---- - -{banner &&
} -{archivedNotice && ( -
-)} -{translationNotice && ( -
-)} - - diff --git a/website/src/components/ConfigReference.astro b/website/src/components/ConfigReference.astro deleted file mode 100644 index 33894993..00000000 --- a/website/src/components/ConfigReference.astro +++ /dev/null @@ -1,204 +0,0 @@ ---- -import stableReference from '../data/config-reference.json'; -import previewReference from '../data/config-reference-preview.json'; -import versionReferences from '../data/config-reference-versions.json'; -import { docsVersion } from '../docs-path'; - -interface Props { - placeholder?: string; - noMatches?: string; - keyCountLabel?: string; -} - -const { - placeholder = 'filter keys, e.g. sidebar, prefix, sound…', - noMatches = 'No keys match this filter.', - keyCountLabel = 'keys', -} = Astro.props; - -const version = docsVersion(Astro.url.pathname); -const archivedReferences = versionReferences as Record; -const reference = version === 'preview' - ? previewReference - : version === 'stable' - ? stableReference - : archivedReferences[version]; -if (!reference) { - throw new Error(`documentation version ${version} has no archived configuration reference`); -} -const totalKeys = reference.sections.reduce((sum, section) => sum + section.keys.length, 0); ---- - -
-
- -

{totalKeys} {keyCountLabel}

-
- - {reference.sections.map((section) => ( -
-

{section.title}

-
    - {section.keys.map((entry) => ( -
  • -
    - {entry.key} - {entry.type} - {entry.default && ( - - default {entry.default} - - )} -
    -

    - {entry.description} - {entry.values && ( - - {entry.values.map((value) => ( - {value} - ))} - - )} -

    -
  • - ))} -
-
- ))} - - -
- - - - diff --git a/website/src/components/DocsVersionSelect.astro b/website/src/components/DocsVersionSelect.astro deleted file mode 100644 index 5ccd856c..00000000 --- a/website/src/components/DocsVersionSelect.astro +++ /dev/null @@ -1,84 +0,0 @@ ---- -import versions from '../data/docs-versions.json'; -import { docsRoute, docsTargetHref } from '../docs-path'; - -const route = docsRoute(Astro.url.pathname); -const locale = route.locale ?? 'root'; -const labels = { - root: { accessible: 'Documentation version', latest: 'Latest', preview: 'Preview' }, - ja: { accessible: 'ドキュメントのバージョン', latest: '最新', preview: 'プレビュー' }, - 'zh-cn': { accessible: '文档版本', latest: '最新', preview: '预览版' }, -}[locale]; -const scopes = versions.scopes; ---- - -{route.isDocs && ( - -)} - - - - diff --git a/website/src/components/Head.astro b/website/src/components/Head.astro deleted file mode 100644 index dac83b81..00000000 --- a/website/src/components/Head.astro +++ /dev/null @@ -1,67 +0,0 @@ ---- -import { docsVersion } from '../docs-path'; - -const { head } = Astro.locals.starlightRoute; -const version = docsVersion(Astro.url.pathname); ---- - -{head.map(({ tag: Tag, attrs, content }) => )} - -{version !== 'stable' && } - - diff --git a/website/src/components/Header.astro b/website/src/components/Header.astro deleted file mode 100644 index cfa3d759..00000000 --- a/website/src/components/Header.astro +++ /dev/null @@ -1,99 +0,0 @@ ---- -import config from 'virtual:starlight/user-config'; - -import LanguageSelect from 'virtual:starlight/components/LanguageSelect'; -import Search from 'virtual:starlight/components/Search'; -import SiteTitle from 'virtual:starlight/components/SiteTitle'; -import SocialIcons from 'virtual:starlight/components/SocialIcons'; -import ThemeSelect from 'virtual:starlight/components/ThemeSelect'; -import DocsVersionSelect from './DocsVersionSelect.astro'; -import { docsRoute } from '../docs-path'; - -const shouldRenderSearch = - config.pagefind || config.components.Search !== '@astrojs/starlight/components/Search.astro'; -const isDocs = docsRoute(Astro.url.pathname).isDocs; ---- - -
-
- -
-
- {isDocs && } - {shouldRenderSearch && } -
-
- - - -
-
- - diff --git a/website/src/components/MarketingLayout.astro b/website/src/components/MarketingLayout.astro deleted file mode 100644 index 6db7e00d..00000000 --- a/website/src/components/MarketingLayout.astro +++ /dev/null @@ -1,274 +0,0 @@ ---- -interface Props { - title: string; - description: string; - canonicalPath: string; - ogType?: 'website' | 'article'; - ogImage?: string; - ogImageAlt?: string; -} - -const { - title, - description, - canonicalPath, - ogType = 'website', - ogImage = '/assets/og-card-v9.png', - ogImageAlt = 'Herdr — run them anywhere, leave them running.', -} = Astro.props; -const canonicalUrl = new URL(canonicalPath, 'https://herdr.dev').toString(); -const ogImageUrl = new URL(ogImage, 'https://herdr.dev').toString(); ---- - - - - - - - {title} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - light - [/] -
- - - - - - diff --git a/website/src/components/Search.astro b/website/src/components/Search.astro deleted file mode 100644 index cceeed34..00000000 --- a/website/src/components/Search.astro +++ /dev/null @@ -1,52 +0,0 @@ ---- -import StarlightSearch from '@astrojs/starlight/components/Search.astro'; -import { docsVersion } from '../docs-path'; - -const version = docsVersion(Astro.url.pathname); ---- - - - - - - - - diff --git a/website/src/components/Sidebar.astro b/website/src/components/Sidebar.astro deleted file mode 100644 index 08d31f79..00000000 --- a/website/src/components/Sidebar.astro +++ /dev/null @@ -1,53 +0,0 @@ ---- -import MobileMenuFooter from 'virtual:starlight/components/MobileMenuFooter'; -import SidebarPersister from '@astrojs/starlight/components/SidebarPersister.astro'; -import SidebarSublist from '@astrojs/starlight/components/SidebarSublist.astro'; -import versions from '../data/docs-versions.json'; -import { docsRoute, docsTargetHref } from '../docs-path'; - -const { sidebar } = Astro.locals.starlightRoute; -const pathname = Astro.url.pathname; -const route = docsRoute(pathname); -const scopedSidebar = route.target === 'stable' ? sidebar : rewriteSidebar(sidebar); - -function rewriteSidebar(entries) { - return entries.flatMap((entry) => { - if (entry.type === 'link') { - const linkRoute = docsRoute(entry.href); - if (!linkRoute.isDocs) return [entry]; - if (linkRoute.target !== 'stable') { - return linkRoute.target === route.target - ? [{ ...entry, isCurrent: samePath(entry.href, pathname) }] - : []; - } - - const localeKey = route.locale ?? 'root'; - const availablePages = versions.scopes[route.target]?.locales[localeKey] ?? []; - if (!availablePages.includes(linkRoute.page)) return []; - - const href = docsTargetHref({ ...linkRoute, locale: route.locale }, route.target, versions.scopes); - return [{ ...entry, href, isCurrent: samePath(href, pathname) }]; - } - - const rewrittenEntries = rewriteSidebar(entry.entries); - if (rewrittenEntries.length === 0) return []; - return [{ ...entry, entries: rewrittenEntries }]; - }); -} - -function samePath(left, right) { - return stripTrailingSlash(left) === stripTrailingSlash(right); -} - -function stripTrailingSlash(path) { - return path.length > 1 ? path.replace(/\/$/, '') : path; -} ---- - - - - - -
- -
diff --git a/website/src/components/SiteLayout.astro b/website/src/components/SiteLayout.astro deleted file mode 100644 index f056458c..00000000 --- a/website/src/components/SiteLayout.astro +++ /dev/null @@ -1,223 +0,0 @@ ---- -/* The chassis every non-docs page shares: one dark ground, the framed grid, - the same nav and footer as the homepage. Pages supply their own
. - Docs keep Starlight's shell and are themed through src/styles/starlight.css. */ -interface Props { - title: string; - description: string; - canonicalPath: string; - ogType?: 'website' | 'article'; - ogImage?: string; - ogImageAlt?: string; -} - -const { - title, - description, - canonicalPath, - ogType = 'website', - ogImage = '/assets/og-card-v9.png', - ogImageAlt = 'Herdr — run them anywhere, leave them running.', -} = Astro.props; - -import { fmt, releaseVersion, siteStats } from '../site-data'; - -const canonicalUrl = new URL(canonicalPath, 'https://herdr.dev').toString(); -const ogImageUrl = new URL(ogImage, 'https://herdr.dev').toString(); -const year = new Date().getFullYear(); - -/* Same build-time source the homepage uses, so the nav count and the footer - version agree across every page without being written down twice. */ -const { starCount } = await siteStats(); -const version = await releaseVersion(); -const facts = version ? `v${version} · Apache 2.0` : 'Apache 2.0'; ---- - - - - - - - {title} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
- - - - diff --git a/website/src/components/SiteTitle.astro b/website/src/components/SiteTitle.astro deleted file mode 100644 index 3e5af0a3..00000000 --- a/website/src/components/SiteTitle.astro +++ /dev/null @@ -1,95 +0,0 @@ ---- -import { docsRoute } from '../docs-path'; - -const { siteTitle, siteTitleHref, locale } = Astro.locals.starlightRoute; -const route = docsRoute(Astro.url.pathname); -const localePrefix = locale ? `/${locale}` : ''; -const targetSegment = route.target === 'stable' ? '' : `/${route.target}`; -const docsHref = `${localePrefix}/docs${targetSegment}/`; ---- - - - - -- cgit v1.2.3