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: 3 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Full history: Starlight dates "Last updated" (and dateModified) from each file's last commit
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 24
Expand Down
2 changes: 2 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export default defineConfig({
editLink: { baseUrl: 'https://github.com/BazarPro/docs/edit/main/' },
lastUpdated: true,
customCss: ['./src/styles/theme.css'],
// Preview image and structured data for search engines (src/routeData.ts)
routeMiddleware: './src/routeData.ts',
// Plausible (data.bazarpro.de): cookie-free page views; options are set per site in Plausible
head: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/en/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: BazarPro Docs
title: Help and guides for children's bazaars, bike sales and flea markets
description: Guides for children's clothing bazaars, bike sales and flea markets with BazarPro – for organizers, sellers and visitors.
template: splash
hero:
Expand Down
2 changes: 1 addition & 1 deletion src/content/docs/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: BazarPro Docs
title: Hilfe und Ratgeber für Kinderbasar, Fahrradbörse und Flohmarkt
description: Anleitungen und Ratgeber für Kinderkleiderbasar, Fahrradbörse und Flohmarkt mit BazarPro – für Veranstalter, Verkäufer und Besucher.
template: splash
hero:
Expand Down
81 changes: 81 additions & 0 deletions src/routeData.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { defineRouteMiddleware } from '@astrojs/starlight/route-data';

/**
* SEO additions to Starlight's head tags: a preview image for shared links and
* structured data (schema.org) for search engines.
*/

// Same picture as on bazarpro.de; 1200 × 630 as social networks expect
const PREVIEW_IMAGE = 'https://bazarpro.de/og-image.png';

const PUBLISHER = {
'@type': 'Organization',
name: 'BazarPro',
url: 'https://bazarpro.de',
logo: 'https://bazarpro.de/logo.png',
};

function jsonLd(data: Record<string, unknown>) {
return {
tag: 'script' as const,
attrs: { type: 'application/ld+json' },
content: JSON.stringify(data).replace(/</g, '\\u003c'),
};
}

export const onRequest = defineRouteMiddleware((context) => {
const route = context.locals.starlightRoute;
const { title, description, template } = route.entry.data;
const site = context.site ?? new URL('https://docs.bazarpro.de');
const url = new URL(context.url.pathname, site).href;
const home = new URL(route.locale ? `/${route.locale}/` : '/', site).href;

route.head.push(
{ tag: 'meta', attrs: { property: 'og:image', content: PREVIEW_IMAGE } },
{ tag: 'meta', attrs: { property: 'og:image:width', content: '1200' } },
{ tag: 'meta', attrs: { property: 'og:image:height', content: '630' } },
{ tag: 'meta', attrs: { name: 'twitter:image', content: PREVIEW_IMAGE } }
);

if (route.id === '404' || route.id.endsWith('/404')) return;

if (template === 'splash' && url === home) {
route.head.push(
jsonLd({
'@context': 'https://schema.org',
'@type': 'WebSite',
name: route.siteTitle,
url: home,
inLanguage: route.lang,
description,
publisher: PUBLISHER,
})
);
return;
}

route.head.push(
jsonLd({
'@context': 'https://schema.org',
'@type': 'Article',
headline: title,
description,
url,
mainEntityOfPage: url,
inLanguage: route.lang,
...(route.lastUpdated ? { dateModified: route.lastUpdated.toISOString() } : {}),
image: PREVIEW_IMAGE,
author: PUBLISHER,
publisher: PUBLISHER,
}),
jsonLd({
'@context': 'https://schema.org',
'@type': 'BreadcrumbList',
// Sidebar groups have no page of their own, Google wants a URL for each level
itemListElement: [
{ '@type': 'ListItem', position: 1, name: route.siteTitle, item: home },
{ '@type': 'ListItem', position: 2, name: title, item: url },
],
})
);
});
Loading