init
24
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# build output
|
||||
dist/
|
||||
# generated types
|
||||
.astro/
|
||||
|
||||
# dependencies
|
||||
node_modules/
|
||||
|
||||
# logs
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
|
||||
|
||||
# environment variables
|
||||
.env
|
||||
.env.production
|
||||
|
||||
# macOS-specific files
|
||||
.DS_Store
|
||||
|
||||
# jetbrains setting folder
|
||||
.idea/
|
||||
4
.vscode/extensions.json
vendored
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"recommendations": ["astro-build.astro-vscode", "unifiedjs.vscode-mdx"],
|
||||
"unwantedRecommendations": []
|
||||
}
|
||||
11
.vscode/launch.json
vendored
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"command": "./node_modules/.bin/astro dev",
|
||||
"name": "Development server",
|
||||
"request": "launch",
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
45
CLAUDE.md
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Commands
|
||||
|
||||
- `npm run dev` — local dev server at `localhost:4321`
|
||||
- `npm run build` — production build to `./dist/`
|
||||
- `npm run preview` — preview production build
|
||||
- `npm run astro -- --help` — Astro CLI (e.g. `astro check` for type-checking)
|
||||
|
||||
Node >= 22.12.0 required.
|
||||
|
||||
## Path aliases
|
||||
|
||||
[tsconfig.json](tsconfig.json) defines a single `~/*` → `src/*` alias. Prefer it over relative imports (`~/components/Foo.astro` instead of `../../components/Foo.astro`) in `.astro`, `.ts`, `.js`, `.mjs`, and MDX files. Frontmatter `heroImage` paths and inline markdown `` image refs stay relative — Astro's image resolver expects those relative to the content file.
|
||||
|
||||
## Architecture
|
||||
|
||||
Astro 6 static site, based on the `blog` starter template. No tests, no linter configured. Site URL: `https://adrian-altner.de`.
|
||||
|
||||
### Internationalisation (de default, en secondary)
|
||||
|
||||
- Astro i18n is configured in [astro.config.mjs](astro.config.mjs) with `defaultLocale: 'de'`, `locales: ['de', 'en']`, `prefixDefaultLocale: false`. German lives at `/`, English at `/en/`.
|
||||
- Posts are organised per locale under `src/content/posts/<locale>/…`. Post `id` is `<locale>/<slug>`; helpers in [src/i18n/posts.ts](src/i18n/posts.ts) (`entryLocale`, `entrySlug`, `getPostsByLocale`, `getCategoriesByLocale`, `getPostsByCategory`, `categoryHref`, `categorySegment`) split and filter them. The content schema in [src/content.config.ts](src/content.config.ts) globs `{de,en}/**/*.{md,mdx}`. Collection name is `posts` — access via `getCollection('posts')` / `CollectionEntry<'posts'>`.
|
||||
- A second collection `categories` lives under `src/content/categories/<locale>/*.md` (schema: `name`, optional `description`, optional `translationKey`). Blog posts reference a category via `category: reference('categories')` in the schema; frontmatter values are fully-qualified entry ids, e.g. `category: de/technik` or `category: en/tech`. Resolve with `getEntry(post.data.category)`.
|
||||
- **Translation linking**: both collections support an optional `translationKey` string. Entries in different locales that represent the same logical content share one key (e.g. `de/technik` and `en/tech` both set `translationKey: tech`). The language switcher resolves this via `findTranslation(entry, target)` ([src/i18n/posts.ts](src/i18n/posts.ts)) to produce the correct target-locale URL. Pages that render a specific content entry should pass it to `Header` as `entry={…}` (see [src/pages/[...slug].astro](src/pages/[...slug].astro), [CategoryDetailPage](src/components/CategoryDetailPage.astro)); the `BlogPost` layout forwards an `entry` prop. When an entry has no translation, the switcher falls back to the other locale's home rather than producing a 404.
|
||||
- Category routes are localised in the URL: `/kategorie/<slug>` (de) and `/en/category/<slug>` (en), driven by [src/pages/kategorie/[slug].astro](src/pages/kategorie/[slug].astro) and [src/pages/en/category/[slug].astro](src/pages/en/category/[slug].astro). Both use shared UI components ([CategoryIndexPage](src/components/CategoryIndexPage.astro), [CategoryDetailPage](src/components/CategoryDetailPage.astro)). `categorySegment(locale)` returns the right URL segment.
|
||||
- Because posts sit two levels deep, hero images and component imports inside MD/MDX use `../../../assets/…` / `../../../components/…` relative paths.
|
||||
- UI strings and path helpers live in [src/i18n/ui.ts](src/i18n/ui.ts). `t(locale, key)` for translations; `localizePath(path, locale)` prefixes `/en` when needed; `switchLocalePath(pathname, target)` rewrites the current URL to the other locale (used by the header language switcher and hreflang alternates in [BaseHead.astro](src/components/BaseHead.astro)).
|
||||
- Site titles/descriptions per locale live in [src/consts.ts](src/consts.ts) (`SITE.de`, `SITE.en`). The `SITE[locale]` map is the single source of truth — update when rebranding.
|
||||
- Pages: German under `src/pages/` (`index.astro`, `about.astro`, `[...slug].astro`, `rss.xml.js`), English mirrors under `src/pages/en/`. The shared home UI lives in [src/components/HomePage.astro](src/components/HomePage.astro); both `index.astro` files are thin wrappers that pass `locale="de"` / `locale="en"`.
|
||||
- Layouts: [BaseLayout.astro](src/layouts/BaseLayout.astro) is the common skeleton (`<html>` / `<head>` with `BaseHead` / `<body>` with `Header` + `main` + `Footer`). Accepts `title`, `description`, `locale`, optional `image`, optional `entry` (for the language-switch translation lookup), optional `bodyClass`, and a `head` named slot for per-page `<link>`/`<meta>` extras. All page templates compose via this layout — don't re-assemble head/header/footer by hand. [Post.astro](src/layouts/Post.astro) wraps `BaseLayout` to add hero image + title block + category line for single posts. `Header`, `BaseHead`, and `FormattedDate` also accept `locale` directly and fall back to `getLocaleFromUrl(Astro.url)`.
|
||||
- Separate RSS feeds per locale: `/rss.xml` (de) and `/en/rss.xml`. The sitemap integration is configured with `i18n: { defaultLocale: 'de', locales: { de: 'de-DE', en: 'en-US' } }`.
|
||||
|
||||
### Routing and data flow
|
||||
|
||||
- [src/pages/[...slug].astro](src/pages/[...slug].astro) and [src/pages/en/[...slug].astro](src/pages/en/[...slug].astro) generate post pages via `getStaticPaths` + `getPostsByLocale(locale)`, rendering through [BlogPost.astro](src/layouts/BlogPost.astro).
|
||||
- `@astrojs/sitemap` generates the sitemap index; `<link rel="alternate" hreflang="…">` tags are emitted in `BaseHead.astro` for both locales plus `x-default`.
|
||||
- **Fonts**: Atkinson is loaded as a local font via Astro's `fonts` API in `astro.config.mjs`, exposed as CSS variable `--font-atkinson`. Files in `src/assets/fonts/`.
|
||||
- **MDX** is enabled via `@astrojs/mdx`; posts can mix Markdown and components.
|
||||
|
||||
## Hero image workflow
|
||||
|
||||
Per user convention: hero image templates live under `src/assets/heros/*`. Workflow uses Maple Mono font, headless Brave to render, then `sharp` to export JPG at 1020×510.
|
||||
63
README.md
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
# Astro Starter Kit: Blog
|
||||
|
||||
```sh
|
||||
npm create astro@latest -- --template blog
|
||||
```
|
||||
|
||||
> 🧑🚀 **Seasoned astronaut?** Delete this file. Have fun!
|
||||
|
||||
Features:
|
||||
|
||||
- ✅ Minimal styling (make it your own!)
|
||||
- ✅ 100/100 Lighthouse performance
|
||||
- ✅ SEO-friendly with canonical URLs and Open Graph data
|
||||
- ✅ Sitemap support
|
||||
- ✅ RSS Feed support
|
||||
- ✅ Markdown & MDX support
|
||||
|
||||
## 🚀 Project Structure
|
||||
|
||||
Inside of your Astro project, you'll see the following folders and files:
|
||||
|
||||
```text
|
||||
├── public/
|
||||
├── src/
|
||||
│ ├── assets/
|
||||
│ ├── components/
|
||||
│ ├── content/
|
||||
│ ├── layouts/
|
||||
│ └── pages/
|
||||
├── astro.config.mjs
|
||||
├── README.md
|
||||
├── package.json
|
||||
└── tsconfig.json
|
||||
```
|
||||
|
||||
Astro looks for `.astro` or `.md` files in the `src/pages/` directory. Each page is exposed as a route based on its file name.
|
||||
|
||||
There's nothing special about `src/components/`, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
|
||||
|
||||
The `src/content/` directory contains "collections" of related Markdown and MDX documents. Use `getCollection()` to retrieve posts from `src/content/blog/`, and type-check your frontmatter using an optional schema. See [Astro's Content Collections docs](https://docs.astro.build/en/guides/content-collections/) to learn more.
|
||||
|
||||
Any static assets, like images, can be placed in the `public/` directory.
|
||||
|
||||
## 🧞 Commands
|
||||
|
||||
All commands are run from the root of the project, from a terminal:
|
||||
|
||||
| Command | Action |
|
||||
| :------------------------ | :----------------------------------------------- |
|
||||
| `npm install` | Installs dependencies |
|
||||
| `npm run dev` | Starts local dev server at `localhost:4321` |
|
||||
| `npm run build` | Build your production site to `./dist/` |
|
||||
| `npm run preview` | Preview your build locally, before deploying |
|
||||
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
|
||||
| `npm run astro -- --help` | Get help using the Astro CLI |
|
||||
|
||||
## 👀 Want to learn more?
|
||||
|
||||
Check out [our documentation](https://docs.astro.build) or jump into our [Discord server](https://astro.build/chat).
|
||||
|
||||
## Credit
|
||||
|
||||
This theme is based off of the lovely [Bear Blog](https://github.com/HermanMartinus/bearblog/).
|
||||
51
astro.config.mjs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
// @ts-check
|
||||
|
||||
import mdx from '@astrojs/mdx';
|
||||
import sitemap from '@astrojs/sitemap';
|
||||
import { defineConfig, fontProviders } from 'astro/config';
|
||||
|
||||
// https://astro.build/config
|
||||
export default defineConfig({
|
||||
site: 'https://adrian-altner.de',
|
||||
i18n: {
|
||||
defaultLocale: 'de',
|
||||
locales: ['de', 'en'],
|
||||
routing: {
|
||||
prefixDefaultLocale: false,
|
||||
redirectToDefaultLocale: false,
|
||||
},
|
||||
},
|
||||
integrations: [
|
||||
mdx(),
|
||||
sitemap({
|
||||
i18n: {
|
||||
defaultLocale: 'de',
|
||||
locales: { de: 'de-DE', en: 'en-US' },
|
||||
},
|
||||
}),
|
||||
],
|
||||
fonts: [
|
||||
{
|
||||
provider: fontProviders.local(),
|
||||
name: 'Atkinson',
|
||||
cssVariable: '--font-atkinson',
|
||||
fallbacks: ['sans-serif'],
|
||||
options: {
|
||||
variants: [
|
||||
{
|
||||
src: ['./src/assets/fonts/atkinson-regular.woff'],
|
||||
weight: 400,
|
||||
style: 'normal',
|
||||
display: 'swap',
|
||||
},
|
||||
{
|
||||
src: ['./src/assets/fonts/atkinson-bold.woff'],
|
||||
weight: 700,
|
||||
style: 'normal',
|
||||
display: 'swap',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
5737
package-lock.json
generated
Normal file
21
package.json
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
{
|
||||
"name": "adrian-altner.de",
|
||||
"type": "module",
|
||||
"version": "0.0.1",
|
||||
"engines": {
|
||||
"node": ">=22.12.0"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "astro dev",
|
||||
"build": "astro build",
|
||||
"preview": "astro preview",
|
||||
"astro": "astro"
|
||||
},
|
||||
"dependencies": {
|
||||
"@astrojs/mdx": "^5.0.3",
|
||||
"@astrojs/rss": "^4.0.18",
|
||||
"@astrojs/sitemap": "^3.7.2",
|
||||
"astro": "^6.1.8",
|
||||
"sharp": "^0.34.3"
|
||||
}
|
||||
}
|
||||
BIN
public/favicon.ico
Normal file
|
After Width: | Height: | Size: 655 B |
9
public/favicon.svg
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 128 128">
|
||||
<path d="M50.4 78.5a75.1 75.1 0 0 0-28.5 6.9l24.2-65.7c.7-2 1.9-3.2 3.4-3.2h29c1.5 0 2.7 1.2 3.4 3.2l24.2 65.7s-11.6-7-28.5-7L67 45.5c-.4-1.7-1.6-2.8-2.9-2.8-1.3 0-2.5 1.1-2.9 2.7L50.4 78.5Zm-1.1 28.2Zm-4.2-20.2c-2 6.6-.6 15.8 4.2 20.2a17.5 17.5 0 0 1 .2-.7 5.5 5.5 0 0 1 5.7-4.5c2.8.1 4.3 1.5 4.7 4.7.2 1.1.2 2.3.2 3.5v.4c0 2.7.7 5.2 2.2 7.4a13 13 0 0 0 5.7 4.9v-.3l-.2-.3c-1.8-5.6-.5-9.5 4.4-12.8l1.5-1a73 73 0 0 0 3.2-2.2 16 16 0 0 0 6.8-11.4c.3-2 .1-4-.6-6l-.8.6-1.6 1a37 37 0 0 1-22.4 2.7c-5-.7-9.7-2-13.2-6.2Z" />
|
||||
<style>
|
||||
path { fill: #000; }
|
||||
@media (prefers-color-scheme: dark) {
|
||||
path { fill: #FFF; }
|
||||
}
|
||||
</style>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 749 B |
BIN
src/assets/blog-placeholder-1.jpg
Normal file
|
After Width: | Height: | Size: 31 KiB |
BIN
src/assets/blog-placeholder-2.jpg
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
src/assets/blog-placeholder-3.jpg
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
src/assets/blog-placeholder-4.jpg
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
src/assets/blog-placeholder-5.jpg
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
src/assets/blog-placeholder-about.jpg
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
src/assets/fonts/atkinson-bold.woff
Normal file
BIN
src/assets/fonts/atkinson-regular.woff
Normal file
66
src/components/BaseHead.astro
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
---
|
||||
// Import the global.css file here so that it is included on
|
||||
// all pages through the use of the <BaseHead /> component.
|
||||
import '~/styles/global.css';
|
||||
import type { ImageMetadata } from 'astro';
|
||||
import FallbackImage from '~/assets/blog-placeholder-1.jpg';
|
||||
import { DEFAULT_LOCALE, type Locale, SITE } from '~/consts';
|
||||
import { getLocaleFromUrl, switchLocalePath } from '~/i18n/ui';
|
||||
import { Font } from 'astro:assets';
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
description: string;
|
||||
image?: ImageMetadata;
|
||||
locale?: Locale;
|
||||
}
|
||||
|
||||
const canonicalURL = new URL(Astro.url.pathname, Astro.site);
|
||||
const {
|
||||
title,
|
||||
description,
|
||||
image = FallbackImage,
|
||||
locale = getLocaleFromUrl(Astro.url) ?? DEFAULT_LOCALE,
|
||||
} = Astro.props;
|
||||
|
||||
const otherLocale: Locale = locale === 'de' ? 'en' : 'de';
|
||||
const alternateHref = new URL(switchLocalePath(Astro.url.pathname, otherLocale), Astro.site);
|
||||
const rssHref = new URL(locale === 'de' ? 'rss.xml' : 'en/rss.xml', Astro.site);
|
||||
---
|
||||
|
||||
<!-- Global Metadata -->
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1" />
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
<link rel="sitemap" href="/sitemap-index.xml" />
|
||||
<link rel="alternate" type="application/rss+xml" title={SITE[locale].title} href={rssHref} />
|
||||
<link rel="alternate" hreflang={locale} href={canonicalURL} />
|
||||
<link rel="alternate" hreflang={otherLocale} href={alternateHref} />
|
||||
<link rel="alternate" hreflang="x-default" href={new URL('/', Astro.site)} />
|
||||
<meta name="generator" content={Astro.generator} />
|
||||
|
||||
<Font cssVariable="--font-atkinson" preload />
|
||||
|
||||
<!-- Canonical URL -->
|
||||
<link rel="canonical" href={canonicalURL} />
|
||||
|
||||
<!-- Primary Meta Tags -->
|
||||
<title>{title}</title>
|
||||
<meta name="title" content={title} />
|
||||
<meta name="description" content={description} />
|
||||
|
||||
<!-- Open Graph / Facebook -->
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:locale" content={locale === 'de' ? 'de_DE' : 'en_US'} />
|
||||
<meta property="og:url" content={Astro.url} />
|
||||
<meta property="og:title" content={title} />
|
||||
<meta property="og:description" content={description} />
|
||||
<meta property="og:image" content={new URL(image.src, Astro.url)} />
|
||||
|
||||
<!-- Twitter -->
|
||||
<meta property="twitter:card" content="summary_large_image" />
|
||||
<meta property="twitter:url" content={Astro.url} />
|
||||
<meta property="twitter:title" content={title} />
|
||||
<meta property="twitter:description" content={description} />
|
||||
<meta property="twitter:image" content={new URL(image.src, Astro.url)} />
|
||||
62
src/components/CategoriesPage.astro
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
---
|
||||
import BaseLayout from '~/layouts/BaseLayout.astro';
|
||||
import { type Locale, SITE } from '~/consts';
|
||||
import { categoryHref, getCategoriesByLocale, getPostsByCategory } from '~/i18n/posts';
|
||||
import { t } from '~/i18n/ui';
|
||||
|
||||
interface Props {
|
||||
locale: Locale;
|
||||
}
|
||||
|
||||
const { locale } = Astro.props;
|
||||
const categories = await getCategoriesByLocale(locale);
|
||||
const withCounts = await Promise.all(
|
||||
categories.map(async (c) => ({ category: c, count: (await getPostsByCategory(c)).length })),
|
||||
);
|
||||
|
||||
const pageTitle = `${t(locale, 'categories.title')} — ${SITE[locale].title}`;
|
||||
const pageDescription = t(locale, 'categories.description');
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title={pageTitle}
|
||||
description={pageDescription}
|
||||
locale={locale}
|
||||
bodyClass="category-index"
|
||||
>
|
||||
<article class="prose">
|
||||
<h1>{t(locale, 'categories.title')}</h1>
|
||||
<p>{pageDescription}</p>
|
||||
<ul>
|
||||
{
|
||||
withCounts.map(({ category, count }) => (
|
||||
<li>
|
||||
<a href={categoryHref(category)}>
|
||||
<strong>{category.data.name}</strong>
|
||||
</a>
|
||||
<span class="count"> ({count})</span>
|
||||
{category.data.description && <p>{category.data.description}</p>}
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</article>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
body.category-index main {
|
||||
width: 720px;
|
||||
max-width: calc(100% - 2em);
|
||||
margin: 2em auto;
|
||||
}
|
||||
body.category-index ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
body.category-index li {
|
||||
margin-bottom: 1.25em;
|
||||
}
|
||||
body.category-index .count {
|
||||
color: rgb(var(--gray));
|
||||
}
|
||||
</style>
|
||||
88
src/components/CategoryDetailPage.astro
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
---
|
||||
import { Image } from 'astro:assets';
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import FormattedDate from '~/components/FormattedDate.astro';
|
||||
import BaseLayout from '~/layouts/BaseLayout.astro';
|
||||
import { type Locale, SITE } from '~/consts';
|
||||
import { getPostsByCategory, postSlug } from '~/i18n/posts';
|
||||
import { localizePath, t } from '~/i18n/ui';
|
||||
|
||||
interface Props {
|
||||
locale: Locale;
|
||||
category: CollectionEntry<'categories'>;
|
||||
}
|
||||
|
||||
const { locale, category } = Astro.props;
|
||||
const posts = await getPostsByCategory(category);
|
||||
const pageTitle = `${category.data.name} — ${SITE[locale].title}`;
|
||||
const pageDescription =
|
||||
category.data.description ?? `${t(locale, 'category.postsIn')} ${category.data.name}`;
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title={pageTitle}
|
||||
description={pageDescription}
|
||||
locale={locale}
|
||||
entry={category}
|
||||
bodyClass="category-detail"
|
||||
>
|
||||
<article class="prose">
|
||||
<h1>{category.data.name}</h1>
|
||||
{category.data.description && <p class="lead">{category.data.description}</p>}
|
||||
<h2>{t(locale, 'category.postsIn')} {category.data.name}</h2>
|
||||
{
|
||||
posts.length === 0 ? (
|
||||
<p>{t(locale, 'category.noPosts')}</p>
|
||||
) : (
|
||||
<ul>
|
||||
{posts.map((post) => (
|
||||
<li>
|
||||
<a href={localizePath(`/${postSlug(post)}/`, locale)}>
|
||||
{post.data.heroImage && (
|
||||
<Image
|
||||
width={320}
|
||||
height={160}
|
||||
src={post.data.heroImage}
|
||||
alt=""
|
||||
transition:name={`hero-${post.id}`}
|
||||
/>
|
||||
)}
|
||||
<h3>{post.data.title}</h3>
|
||||
<p class="date">
|
||||
<FormattedDate date={post.data.pubDate} locale={locale} />
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
</article>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
body.category-detail main {
|
||||
width: 720px;
|
||||
max-width: calc(100% - 2em);
|
||||
margin: 2em auto;
|
||||
}
|
||||
body.category-detail ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
body.category-detail li {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
body.category-detail li a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
body.category-detail li img {
|
||||
border-radius: 8px;
|
||||
}
|
||||
body.category-detail .date {
|
||||
color: rgb(var(--gray));
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
15
src/components/Footer.astro
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
const today = new Date();
|
||||
---
|
||||
|
||||
<footer>
|
||||
© {today.getFullYear()} Adrian Altner
|
||||
</footer>
|
||||
<style>
|
||||
footer {
|
||||
padding: 2em 1em 6em 1em;
|
||||
background: linear-gradient(var(--gray-gradient)) no-repeat;
|
||||
color: rgb(var(--gray));
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
22
src/components/FormattedDate.astro
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
import { DEFAULT_LOCALE, type Locale } from '~/consts';
|
||||
import { getLocaleFromUrl } from '~/i18n/ui';
|
||||
|
||||
interface Props {
|
||||
date: Date;
|
||||
locale?: Locale;
|
||||
}
|
||||
|
||||
const { date, locale = getLocaleFromUrl(Astro.url) ?? DEFAULT_LOCALE } = Astro.props;
|
||||
const tag = locale === 'de' ? 'de-DE' : 'en-US';
|
||||
---
|
||||
|
||||
<time datetime={date.toISOString()}>
|
||||
{
|
||||
date.toLocaleDateString(tag, {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
})
|
||||
}
|
||||
</time>
|
||||
181
src/components/Header.astro
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
---
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import { DEFAULT_LOCALE, type Locale, SITE } from '~/consts';
|
||||
import {
|
||||
aboutSegment,
|
||||
categoryIndexSegment,
|
||||
entryHref,
|
||||
findTagBySlug,
|
||||
findTranslation,
|
||||
tagHref,
|
||||
tagIndexSegment,
|
||||
tagSegment,
|
||||
} from '~/i18n/posts';
|
||||
import { getLocaleFromUrl, localizePath, switchLocalePath, t } from '~/i18n/ui';
|
||||
import HeaderLink from '~/components/HeaderLink.astro';
|
||||
|
||||
interface Props {
|
||||
locale?: Locale;
|
||||
/** The current page's content entry, if any — used to resolve a translated language-switch link. */
|
||||
entry?: CollectionEntry<'posts' | 'categories'>;
|
||||
}
|
||||
|
||||
const { entry } = Astro.props;
|
||||
const locale: Locale = Astro.props.locale ?? getLocaleFromUrl(Astro.url);
|
||||
const otherLocale: Locale = locale === 'de' ? 'en' : 'de';
|
||||
const homeHref = localizePath('/', locale);
|
||||
const aboutHref = localizePath(`/${aboutSegment(locale)}`, locale);
|
||||
const categoriesHref = localizePath(`/${categoryIndexSegment(locale)}`, locale);
|
||||
const tagsHref = localizePath(`/${tagIndexSegment(locale)}`, locale);
|
||||
|
||||
const translated = entry ? await findTranslation(entry, otherLocale) : undefined;
|
||||
|
||||
// If we're on a tag detail page, verify the tag exists in the target locale —
|
||||
// otherwise the switched URL would 404. Fall back to the target tags index.
|
||||
async function resolveSwitchHref(): Promise<string> {
|
||||
if (translated) return entryHref(translated);
|
||||
if (entry) return localizePath('/', otherLocale);
|
||||
const parts = Astro.url.pathname.split('/').filter(Boolean);
|
||||
const localePrefix = parts[0] === locale ? 1 : 0;
|
||||
const first = parts[localePrefix];
|
||||
const slug = parts[localePrefix + 1];
|
||||
if (first === tagSegment(locale) && slug) {
|
||||
const target = await findTagBySlug(otherLocale, slug);
|
||||
return target
|
||||
? tagHref(otherLocale, target)
|
||||
: localizePath(`/${tagIndexSegment(otherLocale)}`, otherLocale);
|
||||
}
|
||||
return switchLocalePath(Astro.url.pathname, otherLocale);
|
||||
}
|
||||
const switchHref = await resolveSwitchHref();
|
||||
---
|
||||
|
||||
<header>
|
||||
<nav>
|
||||
<h2><a href={homeHref}>{SITE[locale].title}</a></h2>
|
||||
<div class="internal-links">
|
||||
<HeaderLink href={homeHref}>{t(locale, 'nav.home')}</HeaderLink>
|
||||
<HeaderLink href={aboutHref}>{t(locale, 'nav.about')}</HeaderLink>
|
||||
<HeaderLink href={categoriesHref}>{t(locale, 'nav.categories')}</HeaderLink>
|
||||
<HeaderLink href={tagsHref}>{t(locale, 'nav.tags')}</HeaderLink>
|
||||
</div>
|
||||
<a
|
||||
class={`lang-toggle lang-toggle--${locale}`}
|
||||
href={switchHref}
|
||||
hreflang={otherLocale}
|
||||
lang={otherLocale}
|
||||
aria-label={t(locale, `lang.${otherLocale}`)}
|
||||
>
|
||||
<span class="lang-toggle__thumb" aria-hidden="true"></span>
|
||||
<span class={`lang-toggle__label${locale === 'de' ? ' is-active' : ''}`}>DE</span>
|
||||
<span class={`lang-toggle__label${locale === 'en' ? ' is-active' : ''}`}>EN</span>
|
||||
</a>
|
||||
</nav>
|
||||
</header>
|
||||
|
||||
<script>
|
||||
function wireLangToggle() {
|
||||
const toggle = document.querySelector<HTMLAnchorElement>('.lang-toggle');
|
||||
toggle?.addEventListener('click', () => toggle.classList.add('is-switching'), { once: true });
|
||||
}
|
||||
wireLangToggle();
|
||||
document.addEventListener('astro:page-load', wireLangToggle);
|
||||
</script>
|
||||
<style>
|
||||
header {
|
||||
margin: 0;
|
||||
padding: 0 1em;
|
||||
background: white;
|
||||
box-shadow: 0 2px 8px rgba(var(--black), 5%);
|
||||
}
|
||||
h2 {
|
||||
margin: 0;
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
h2 a,
|
||||
h2 a.active {
|
||||
text-decoration: none;
|
||||
}
|
||||
nav {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1em;
|
||||
}
|
||||
nav a {
|
||||
padding: 1em 0.5em;
|
||||
color: var(--black);
|
||||
border-bottom: 4px solid transparent;
|
||||
text-decoration: none;
|
||||
}
|
||||
nav a.active {
|
||||
text-decoration: none;
|
||||
border-bottom-color: var(--accent);
|
||||
}
|
||||
nav a.lang-toggle {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: stretch;
|
||||
padding: 3px;
|
||||
margin: 0;
|
||||
background: rgba(var(--gray-light), 0.7);
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
font-size: 0.75em;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
font-variant-numeric: tabular-nums;
|
||||
font-feature-settings: 'tnum';
|
||||
user-select: none;
|
||||
}
|
||||
nav a.lang-toggle:hover {
|
||||
background: rgba(var(--gray-light), 1);
|
||||
}
|
||||
.lang-toggle__thumb {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
bottom: 3px;
|
||||
left: 3px;
|
||||
width: calc(50% - 3px);
|
||||
border-radius: 999px;
|
||||
background: var(--accent);
|
||||
box-shadow: 0 1px 3px rgba(var(--black), 0.18);
|
||||
transition: transform 280ms cubic-bezier(0.4, 0, 0.2, 1);
|
||||
}
|
||||
.lang-toggle--en .lang-toggle__thumb {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
.lang-toggle--de.is-switching .lang-toggle__thumb {
|
||||
transform: translateX(100%);
|
||||
}
|
||||
.lang-toggle--en.is-switching .lang-toggle__thumb {
|
||||
transform: translateX(0);
|
||||
}
|
||||
.lang-toggle__label {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
display: block;
|
||||
flex: 1;
|
||||
width: 2.2em;
|
||||
padding: 0.6em 0 0.5em;
|
||||
text-align: center;
|
||||
color: rgb(var(--gray));
|
||||
transition: color 280ms ease;
|
||||
}
|
||||
.lang-toggle__label.is-active {
|
||||
color: white;
|
||||
}
|
||||
.lang-toggle.is-switching .lang-toggle__label.is-active {
|
||||
color: rgb(var(--gray));
|
||||
}
|
||||
.lang-toggle.is-switching .lang-toggle__label:not(.is-active) {
|
||||
color: white;
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.lang-toggle__thumb,
|
||||
.lang-toggle__label {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
42
src/components/HeaderLink.astro
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
import type { HTMLAttributes } from 'astro/types';
|
||||
import { LOCALES } from '~/consts';
|
||||
|
||||
type Props = HTMLAttributes<'a'>;
|
||||
|
||||
const { href, class: className, ...props } = Astro.props;
|
||||
|
||||
function stripTrailing(p: string) {
|
||||
return p.length > 1 && p.endsWith('/') ? p.slice(0, -1) : p;
|
||||
}
|
||||
|
||||
function stripBase(p: string) {
|
||||
const base = import.meta.env.BASE_URL;
|
||||
if (base && base !== '/' && p.startsWith(base)) return p.slice(base.length - 1) || '/';
|
||||
return p;
|
||||
}
|
||||
|
||||
const pathname = stripTrailing(stripBase(Astro.url.pathname));
|
||||
const target = stripTrailing(String(href ?? ''));
|
||||
|
||||
// Locale home URLs (`/`, `/en`) should only activate on exact match; deeper
|
||||
// routes activate when the pathname equals or is nested under the href.
|
||||
const localeHomes = new Set(['/', ...LOCALES.map((l) => `/${l}`)]);
|
||||
const isActive = localeHomes.has(target)
|
||||
? pathname === target
|
||||
: pathname === target || pathname.startsWith(target + '/');
|
||||
---
|
||||
|
||||
<a href={href} class:list={[className, { active: isActive }]} {...props}>
|
||||
<slot />
|
||||
</a>
|
||||
<style>
|
||||
a {
|
||||
display: inline-block;
|
||||
text-decoration: none;
|
||||
}
|
||||
a.active {
|
||||
font-weight: bolder;
|
||||
text-decoration: underline;
|
||||
}
|
||||
</style>
|
||||
118
src/components/HomePage.astro
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
---
|
||||
import { Image } from 'astro:assets';
|
||||
import FormattedDate from '~/components/FormattedDate.astro';
|
||||
import BaseLayout from '~/layouts/BaseLayout.astro';
|
||||
import { type Locale, SITE } from '~/consts';
|
||||
import { getPostsByLocale, postSlug } from '~/i18n/posts';
|
||||
import { localizePath } from '~/i18n/ui';
|
||||
|
||||
interface Props {
|
||||
locale: Locale;
|
||||
}
|
||||
|
||||
const { locale } = Astro.props;
|
||||
const posts = await getPostsByLocale(locale);
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title={SITE[locale].title}
|
||||
description={SITE[locale].description}
|
||||
locale={locale}
|
||||
bodyClass="home"
|
||||
>
|
||||
<section>
|
||||
<ul>
|
||||
{
|
||||
posts.map((post) => (
|
||||
<li>
|
||||
<a href={localizePath(`/${postSlug(post)}/`, locale)}>
|
||||
{post.data.heroImage && (
|
||||
<Image
|
||||
width={720}
|
||||
height={360}
|
||||
src={post.data.heroImage}
|
||||
alt=""
|
||||
transition:name={`hero-${post.id}`}
|
||||
/>
|
||||
)}
|
||||
<h4 class="title">{post.data.title}</h4>
|
||||
<p class="date">
|
||||
<FormattedDate date={post.data.pubDate} locale={locale} />
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</section>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
body.home main {
|
||||
width: 960px;
|
||||
}
|
||||
ul {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 2rem;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
ul li {
|
||||
width: calc(50% - 1rem);
|
||||
}
|
||||
ul li * {
|
||||
text-decoration: none;
|
||||
transition: 0.2s ease;
|
||||
}
|
||||
ul li:first-child {
|
||||
width: 100%;
|
||||
margin-bottom: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
ul li:first-child img {
|
||||
width: 100%;
|
||||
}
|
||||
ul li:first-child .title {
|
||||
font-size: 2.369rem;
|
||||
}
|
||||
ul li img {
|
||||
margin-bottom: 0.5rem;
|
||||
border-radius: 12px;
|
||||
}
|
||||
ul li a {
|
||||
display: block;
|
||||
}
|
||||
.title {
|
||||
margin: 0;
|
||||
color: rgb(var(--black));
|
||||
line-height: 1;
|
||||
}
|
||||
.date {
|
||||
margin: 0;
|
||||
color: rgb(var(--gray));
|
||||
}
|
||||
ul li a:hover h4,
|
||||
ul li a:hover .date {
|
||||
color: rgb(var(--accent));
|
||||
}
|
||||
ul a:hover img {
|
||||
box-shadow: var(--box-shadow);
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
ul {
|
||||
gap: 0.5em;
|
||||
}
|
||||
ul li {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
ul li:first-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
ul li:first-child .title {
|
||||
font-size: 1.563em;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
84
src/components/TagDetailPage.astro
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
---
|
||||
import { Image } from 'astro:assets';
|
||||
import FormattedDate from '~/components/FormattedDate.astro';
|
||||
import BaseLayout from '~/layouts/BaseLayout.astro';
|
||||
import { type Locale, SITE } from '~/consts';
|
||||
import { type TagEntry, getPostsByTag, postSlug } from '~/i18n/posts';
|
||||
import { localizePath, t } from '~/i18n/ui';
|
||||
|
||||
interface Props {
|
||||
locale: Locale;
|
||||
tag: TagEntry;
|
||||
}
|
||||
|
||||
const { locale, tag } = Astro.props;
|
||||
const posts = await getPostsByTag(locale, tag.slug);
|
||||
const pageTitle = `${tag.name} — ${SITE[locale].title}`;
|
||||
const pageDescription = `${t(locale, 'tag.postsTagged')} ${tag.name}`;
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title={pageTitle}
|
||||
description={pageDescription}
|
||||
locale={locale}
|
||||
bodyClass="tag-detail"
|
||||
>
|
||||
<article class="prose">
|
||||
<h1>{tag.name}</h1>
|
||||
<h2>{t(locale, 'tag.postsTagged')} {tag.name}</h2>
|
||||
{
|
||||
posts.length === 0 ? (
|
||||
<p>{t(locale, 'tag.noPosts')}</p>
|
||||
) : (
|
||||
<ul>
|
||||
{posts.map((post) => (
|
||||
<li>
|
||||
<a href={localizePath(`/${postSlug(post)}/`, locale)}>
|
||||
{post.data.heroImage && (
|
||||
<Image
|
||||
width={320}
|
||||
height={160}
|
||||
src={post.data.heroImage}
|
||||
alt=""
|
||||
transition:name={`hero-${post.id}`}
|
||||
/>
|
||||
)}
|
||||
<h3>{post.data.title}</h3>
|
||||
<p class="date">
|
||||
<FormattedDate date={post.data.pubDate} locale={locale} />
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
}
|
||||
</article>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
body.tag-detail main {
|
||||
width: 720px;
|
||||
max-width: calc(100% - 2em);
|
||||
margin: 2em auto;
|
||||
}
|
||||
body.tag-detail ul {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
body.tag-detail li {
|
||||
margin-bottom: 1.5em;
|
||||
}
|
||||
body.tag-detail li a {
|
||||
display: block;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
body.tag-detail li img {
|
||||
border-radius: 8px;
|
||||
}
|
||||
body.tag-detail .date {
|
||||
color: rgb(var(--gray));
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
57
src/components/TagsPage.astro
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
---
|
||||
import BaseLayout from '~/layouts/BaseLayout.astro';
|
||||
import { type Locale, SITE } from '~/consts';
|
||||
import { getTagsByLocale, tagHref } from '~/i18n/posts';
|
||||
import { t } from '~/i18n/ui';
|
||||
|
||||
interface Props {
|
||||
locale: Locale;
|
||||
}
|
||||
|
||||
const { locale } = Astro.props;
|
||||
const tags = await getTagsByLocale(locale);
|
||||
const pageTitle = `${t(locale, 'tags.title')} — ${SITE[locale].title}`;
|
||||
const pageDescription = t(locale, 'tags.description');
|
||||
---
|
||||
|
||||
<BaseLayout
|
||||
title={pageTitle}
|
||||
description={pageDescription}
|
||||
locale={locale}
|
||||
bodyClass="tag-index"
|
||||
>
|
||||
<article class="prose">
|
||||
<h1>{t(locale, 'tags.title')}</h1>
|
||||
<p>{pageDescription}</p>
|
||||
<ul class="tag-cloud">
|
||||
{
|
||||
tags.map((tag) => (
|
||||
<li>
|
||||
<a href={tagHref(locale, tag)}>
|
||||
<strong>{tag.name}</strong>
|
||||
</a>
|
||||
<span class="count"> ({tag.count})</span>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
</article>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
body.tag-index main {
|
||||
width: 720px;
|
||||
max-width: calc(100% - 2em);
|
||||
margin: 2em auto;
|
||||
}
|
||||
body.tag-index .tag-cloud {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5em 1em;
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
body.tag-index .count {
|
||||
color: rgb(var(--gray));
|
||||
}
|
||||
</style>
|
||||
14
src/consts.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
export const LOCALES = ['de', 'en'] as const;
|
||||
export type Locale = (typeof LOCALES)[number];
|
||||
export const DEFAULT_LOCALE: Locale = 'de';
|
||||
|
||||
export const SITE: Record<Locale, { title: string; description: string }> = {
|
||||
de: {
|
||||
title: 'Adrian Altner',
|
||||
description: 'Willkommen auf meiner Website!',
|
||||
},
|
||||
en: {
|
||||
title: 'Adrian Altner',
|
||||
description: 'Welcome to my website!',
|
||||
},
|
||||
};
|
||||
42
src/content.config.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { defineCollection, reference } from 'astro:content';
|
||||
import { glob } from 'astro/loaders';
|
||||
import { z } from 'astro/zod';
|
||||
|
||||
// Shared per-locale layout:
|
||||
// src/content/posts/<locale>/… — posts
|
||||
// src/content/categories/<locale>/… — categories
|
||||
// Entry `id` is always `<locale>/<slug>`. A blog post's `category` references a
|
||||
// category by that id (e.g. "de/technik" or "en/tech").
|
||||
|
||||
// Optional `translationKey`: entries in different locales that represent the
|
||||
// same logical piece of content share one key. Used to wire up the language
|
||||
// switcher so it points at the translated URL instead of 404-ing.
|
||||
|
||||
const posts = defineCollection({
|
||||
loader: glob({ base: './src/content/posts', pattern: '{de,en}/**/*.{md,mdx}' }),
|
||||
schema: ({ image }) =>
|
||||
z.object({
|
||||
title: z.string(),
|
||||
description: z.string(),
|
||||
pubDate: z.coerce.date(),
|
||||
updatedDate: z.coerce.date().optional(),
|
||||
heroImage: z.optional(image()),
|
||||
category: z.optional(reference('categories')),
|
||||
// Free-form tags (aka Stichwörter). Plain strings kept inline on each
|
||||
// post; no separate collection. The tag listing pages aggregate them
|
||||
// across posts per locale.
|
||||
tags: z.array(z.string()).optional(),
|
||||
translationKey: z.string().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
const categories = defineCollection({
|
||||
loader: glob({ base: './src/content/categories', pattern: '{de,en}/**/*.md' }),
|
||||
schema: z.object({
|
||||
name: z.string(),
|
||||
description: z.string().optional(),
|
||||
translationKey: z.string().optional(),
|
||||
}),
|
||||
});
|
||||
|
||||
export const collections = { posts, categories };
|
||||
5
src/content/categories/de/allgemein.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
name: Allgemein
|
||||
description: Sammelkategorie für alles andere.
|
||||
translationKey: general
|
||||
---
|
||||
5
src/content/categories/de/technik.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
name: Technik
|
||||
description: Beiträge rund um Technik, Entwicklung und Tools.
|
||||
translationKey: tech
|
||||
---
|
||||
5
src/content/categories/en/general.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
name: General
|
||||
description: Catch-all category.
|
||||
translationKey: general
|
||||
---
|
||||
5
src/content/categories/en/tech.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
name: Tech
|
||||
description: Posts about technology, development and tools.
|
||||
translationKey: tech
|
||||
---
|
||||
18
src/content/posts/de/first-post.md
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
title: 'First post'
|
||||
description: 'Lorem ipsum dolor sit amet'
|
||||
pubDate: 'Jul 08 2022'
|
||||
heroImage: '../../../assets/blog-placeholder-3.jpg'
|
||||
category: de/allgemein
|
||||
translationKey: hello-world
|
||||
---
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae ultricies leo integer malesuada nunc vel risus commodo viverra. Adipiscing enim eu turpis egestas pretium. Euismod elementum nisi quis eleifend quam adipiscing. In hac habitasse platea dictumst vestibulum. Sagittis purus sit amet volutpat. Netus et malesuada fames ac turpis egestas. Eget magna fermentum iaculis eu non diam phasellus vestibulum lorem. Varius sit amet mattis vulputate enim. Habitasse platea dictumst quisque sagittis. Integer quis auctor elit sed vulputate mi. Dictumst quisque sagittis purus sit amet.
|
||||
|
||||
Morbi tristique senectus et netus. Id semper risus in hendrerit gravida rutrum quisque non tellus. Habitasse platea dictumst quisque sagittis purus sit amet. Tellus molestie nunc non blandit massa. Cursus vitae congue mauris rhoncus. Accumsan tortor posuere ac ut. Fringilla urna porttitor rhoncus dolor. Elit ullamcorper dignissim cras tincidunt lobortis. In cursus turpis massa tincidunt dui ut ornare lectus. Integer feugiat scelerisque varius morbi enim nunc. Bibendum neque egestas congue quisque egestas diam. Cras ornare arcu dui vivamus arcu felis bibendum. Dignissim suspendisse in est ante in nibh mauris. Sed tempus urna et pharetra pharetra massa massa ultricies mi.
|
||||
|
||||
Mollis nunc sed id semper risus in. Convallis a cras semper auctor neque. Diam sit amet nisl suscipit. Lacus viverra vitae congue eu consequat ac felis donec. Egestas integer eget aliquet nibh praesent tristique magna sit amet. Eget magna fermentum iaculis eu non diam. In vitae turpis massa sed elementum. Tristique et egestas quis ipsum suspendisse ultrices. Eget lorem dolor sed viverra ipsum. Vel turpis nunc eget lorem dolor sed viverra. Posuere ac ut consequat semper viverra nam. Laoreet suspendisse interdum consectetur libero id faucibus. Diam phasellus vestibulum lorem sed risus ultricies tristique. Rhoncus dolor purus non enim praesent elementum facilisis. Ultrices tincidunt arcu non sodales neque. Tempus egestas sed sed risus pretium quam vulputate. Viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare. Fringilla urna porttitor rhoncus dolor purus non. Amet dictum sit amet justo donec enim.
|
||||
|
||||
Mattis ullamcorper velit sed ullamcorper morbi tincidunt. Tortor posuere ac ut consequat semper viverra. Tellus mauris a diam maecenas sed enim ut sem viverra. Venenatis urna cursus eget nunc scelerisque viverra mauris in. Arcu ac tortor dignissim convallis aenean et tortor at. Curabitur gravida arcu ac tortor dignissim convallis aenean et tortor. Egestas tellus rutrum tellus pellentesque eu. Fusce ut placerat orci nulla pellentesque dignissim enim sit amet. Ut enim blandit volutpat maecenas volutpat blandit aliquam etiam. Id donec ultrices tincidunt arcu. Id cursus metus aliquam eleifend mi.
|
||||
|
||||
Tempus quam pellentesque nec nam aliquam sem. Risus at ultrices mi tempus imperdiet. Id porta nibh venenatis cras sed felis eget velit. Ipsum a arcu cursus vitae. Facilisis magna etiam tempor orci eu lobortis elementum. Tincidunt dui ut ornare lectus sit. Quisque non tellus orci ac. Blandit libero volutpat sed cras. Nec tincidunt praesent semper feugiat nibh sed pulvinar proin gravida. Egestas integer eget aliquet nibh praesent tristique magna.
|
||||
218
src/content/posts/de/markdown-style-guide.md
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
---
|
||||
title: 'Markdown Style Guide'
|
||||
description: 'Here is a sample of some basic Markdown syntax that can be used when writing Markdown content in Astro.'
|
||||
pubDate: 'Jun 19 2024'
|
||||
heroImage: '../../../assets/blog-placeholder-1.jpg'
|
||||
category: de/technik
|
||||
tags:
|
||||
- markdown
|
||||
- astro
|
||||
---
|
||||
|
||||
Here is a sample of some basic Markdown syntax that can be used when writing Markdown content in Astro.
|
||||
|
||||
## Headings
|
||||
|
||||
The following HTML `<h1>`—`<h6>` elements represent six levels of section headings. `<h1>` is the highest section level while `<h6>` is the lowest.
|
||||
|
||||
# H1
|
||||
|
||||
## H2
|
||||
|
||||
### H3
|
||||
|
||||
#### H4
|
||||
|
||||
##### H5
|
||||
|
||||
###### H6
|
||||
|
||||
## Paragraph
|
||||
|
||||
Xerum, quo qui aut unt expliquam qui dolut labo. Aque venitatiusda cum, voluptionse latur sitiae dolessi aut parist aut dollo enim qui voluptate ma dolestendit peritin re plis aut quas inctum laceat est volestemque commosa as cus endigna tectur, offic to cor sequas etum rerum idem sintibus eiur? Quianimin porecus evelectur, cum que nis nust voloribus ratem aut omnimi, sitatur? Quiatem. Nam, omnis sum am facea corem alique molestrunt et eos evelece arcillit ut aut eos eos nus, sin conecerem erum fuga. Ri oditatquam, ad quibus unda veliamenimin cusam et facea ipsamus es exerum sitate dolores editium rerore eost, temped molorro ratiae volorro te reribus dolorer sperchicium faceata tiustia prat.
|
||||
|
||||
Itatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sapicia is sinveli squiatum, core et que aut hariosam ex eat.
|
||||
|
||||
## Images
|
||||
|
||||
### Syntax
|
||||
|
||||
```markdown
|
||||

|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||

|
||||
|
||||
## Blockquotes
|
||||
|
||||
The blockquote element represents content that is quoted from another source, optionally with a citation which must be within a `footer` or `cite` element, and optionally with in-line changes such as annotations and abbreviations.
|
||||
|
||||
### Blockquote without attribution
|
||||
|
||||
#### Syntax
|
||||
|
||||
```markdown
|
||||
> Tiam, ad mint andaepu dandae nostion secatur sequo quae.
|
||||
> **Note** that you can use _Markdown syntax_ within a blockquote.
|
||||
```
|
||||
|
||||
#### Output
|
||||
|
||||
> Tiam, ad mint andaepu dandae nostion secatur sequo quae.
|
||||
> **Note** that you can use _Markdown syntax_ within a blockquote.
|
||||
|
||||
### Blockquote with attribution
|
||||
|
||||
#### Syntax
|
||||
|
||||
```markdown
|
||||
> Don't communicate by sharing memory, share memory by communicating.<br>
|
||||
> — <cite>Rob Pike[^1]</cite>
|
||||
```
|
||||
|
||||
#### Output
|
||||
|
||||
> Don't communicate by sharing memory, share memory by communicating.<br>
|
||||
> — <cite>Rob Pike[^1]</cite>
|
||||
|
||||
[^1]: The above quote is excerpted from Rob Pike's [talk](https://www.youtube.com/watch?v=PAAkCSZUG1c) during Gopherfest, November 18, 2015.
|
||||
|
||||
## Tables
|
||||
|
||||
### Syntax
|
||||
|
||||
```markdown
|
||||
| Italics | Bold | Code |
|
||||
| --------- | -------- | ------ |
|
||||
| _italics_ | **bold** | `code` |
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
| Italics | Bold | Code |
|
||||
| --------- | -------- | ------ |
|
||||
| _italics_ | **bold** | `code` |
|
||||
|
||||
## Code Blocks
|
||||
|
||||
### Syntax
|
||||
|
||||
we can use 3 backticks ``` in new line and write snippet and close with 3 backticks on new line and to highlight language specific syntax, write one word of language name after first 3 backticks, for eg. html, javascript, css, markdown, typescript, txt, bash
|
||||
|
||||
````markdown
|
||||
```html
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Example HTML5 Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Test</p>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
````
|
||||
|
||||
### Output
|
||||
|
||||
```html
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Example HTML5 Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Test</p>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
## List Types
|
||||
|
||||
### Ordered List
|
||||
|
||||
#### Syntax
|
||||
|
||||
```markdown
|
||||
1. First item
|
||||
2. Second item
|
||||
3. Third item
|
||||
```
|
||||
|
||||
#### Output
|
||||
|
||||
1. First item
|
||||
2. Second item
|
||||
3. Third item
|
||||
|
||||
### Unordered List
|
||||
|
||||
#### Syntax
|
||||
|
||||
```markdown
|
||||
- List item
|
||||
- Another item
|
||||
- And another item
|
||||
```
|
||||
|
||||
#### Output
|
||||
|
||||
- List item
|
||||
- Another item
|
||||
- And another item
|
||||
|
||||
### Nested list
|
||||
|
||||
#### Syntax
|
||||
|
||||
```markdown
|
||||
- Fruit
|
||||
- Apple
|
||||
- Orange
|
||||
- Banana
|
||||
- Dairy
|
||||
- Milk
|
||||
- Cheese
|
||||
```
|
||||
|
||||
#### Output
|
||||
|
||||
- Fruit
|
||||
- Apple
|
||||
- Orange
|
||||
- Banana
|
||||
- Dairy
|
||||
- Milk
|
||||
- Cheese
|
||||
|
||||
## Other Elements — abbr, sub, sup, kbd, mark
|
||||
|
||||
### Syntax
|
||||
|
||||
```markdown
|
||||
<abbr title="Graphics Interchange Format">GIF</abbr> is a bitmap image format.
|
||||
|
||||
H<sub>2</sub>O
|
||||
|
||||
X<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>
|
||||
|
||||
Press <kbd>CTRL</kbd> + <kbd>ALT</kbd> + <kbd>Delete</kbd> to end the session.
|
||||
|
||||
Most <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.
|
||||
```
|
||||
|
||||
### Output
|
||||
|
||||
<abbr title="Graphics Interchange Format">GIF</abbr> is a bitmap image format.
|
||||
|
||||
H<sub>2</sub>O
|
||||
|
||||
X<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>
|
||||
|
||||
Press <kbd>CTRL</kbd> + <kbd>ALT</kbd> + <kbd>Delete</kbd> to end the session.
|
||||
|
||||
Most <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.
|
||||
17
src/content/posts/de/second-post.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
title: 'Second post'
|
||||
description: 'Lorem ipsum dolor sit amet'
|
||||
pubDate: 'Jul 15 2022'
|
||||
heroImage: '../../../assets/blog-placeholder-4.jpg'
|
||||
category: de/allgemein
|
||||
---
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae ultricies leo integer malesuada nunc vel risus commodo viverra. Adipiscing enim eu turpis egestas pretium. Euismod elementum nisi quis eleifend quam adipiscing. In hac habitasse platea dictumst vestibulum. Sagittis purus sit amet volutpat. Netus et malesuada fames ac turpis egestas. Eget magna fermentum iaculis eu non diam phasellus vestibulum lorem. Varius sit amet mattis vulputate enim. Habitasse platea dictumst quisque sagittis. Integer quis auctor elit sed vulputate mi. Dictumst quisque sagittis purus sit amet.
|
||||
|
||||
Morbi tristique senectus et netus. Id semper risus in hendrerit gravida rutrum quisque non tellus. Habitasse platea dictumst quisque sagittis purus sit amet. Tellus molestie nunc non blandit massa. Cursus vitae congue mauris rhoncus. Accumsan tortor posuere ac ut. Fringilla urna porttitor rhoncus dolor. Elit ullamcorper dignissim cras tincidunt lobortis. In cursus turpis massa tincidunt dui ut ornare lectus. Integer feugiat scelerisque varius morbi enim nunc. Bibendum neque egestas congue quisque egestas diam. Cras ornare arcu dui vivamus arcu felis bibendum. Dignissim suspendisse in est ante in nibh mauris. Sed tempus urna et pharetra pharetra massa massa ultricies mi.
|
||||
|
||||
Mollis nunc sed id semper risus in. Convallis a cras semper auctor neque. Diam sit amet nisl suscipit. Lacus viverra vitae congue eu consequat ac felis donec. Egestas integer eget aliquet nibh praesent tristique magna sit amet. Eget magna fermentum iaculis eu non diam. In vitae turpis massa sed elementum. Tristique et egestas quis ipsum suspendisse ultrices. Eget lorem dolor sed viverra ipsum. Vel turpis nunc eget lorem dolor sed viverra. Posuere ac ut consequat semper viverra nam. Laoreet suspendisse interdum consectetur libero id faucibus. Diam phasellus vestibulum lorem sed risus ultricies tristique. Rhoncus dolor purus non enim praesent elementum facilisis. Ultrices tincidunt arcu non sodales neque. Tempus egestas sed sed risus pretium quam vulputate. Viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare. Fringilla urna porttitor rhoncus dolor purus non. Amet dictum sit amet justo donec enim.
|
||||
|
||||
Mattis ullamcorper velit sed ullamcorper morbi tincidunt. Tortor posuere ac ut consequat semper viverra. Tellus mauris a diam maecenas sed enim ut sem viverra. Venenatis urna cursus eget nunc scelerisque viverra mauris in. Arcu ac tortor dignissim convallis aenean et tortor at. Curabitur gravida arcu ac tortor dignissim convallis aenean et tortor. Egestas tellus rutrum tellus pellentesque eu. Fusce ut placerat orci nulla pellentesque dignissim enim sit amet. Ut enim blandit volutpat maecenas volutpat blandit aliquam etiam. Id donec ultrices tincidunt arcu. Id cursus metus aliquam eleifend mi.
|
||||
|
||||
Tempus quam pellentesque nec nam aliquam sem. Risus at ultrices mi tempus imperdiet. Id porta nibh venenatis cras sed felis eget velit. Ipsum a arcu cursus vitae. Facilisis magna etiam tempor orci eu lobortis elementum. Tincidunt dui ut ornare lectus sit. Quisque non tellus orci ac. Blandit libero volutpat sed cras. Nec tincidunt praesent semper feugiat nibh sed pulvinar proin gravida. Egestas integer eget aliquet nibh praesent tristique magna.
|
||||
17
src/content/posts/de/third-post.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
title: 'Third post'
|
||||
description: 'Lorem ipsum dolor sit amet'
|
||||
pubDate: 'Jul 22 2022'
|
||||
heroImage: '../../../assets/blog-placeholder-2.jpg'
|
||||
category: de/allgemein
|
||||
---
|
||||
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Vitae ultricies leo integer malesuada nunc vel risus commodo viverra. Adipiscing enim eu turpis egestas pretium. Euismod elementum nisi quis eleifend quam adipiscing. In hac habitasse platea dictumst vestibulum. Sagittis purus sit amet volutpat. Netus et malesuada fames ac turpis egestas. Eget magna fermentum iaculis eu non diam phasellus vestibulum lorem. Varius sit amet mattis vulputate enim. Habitasse platea dictumst quisque sagittis. Integer quis auctor elit sed vulputate mi. Dictumst quisque sagittis purus sit amet.
|
||||
|
||||
Morbi tristique senectus et netus. Id semper risus in hendrerit gravida rutrum quisque non tellus. Habitasse platea dictumst quisque sagittis purus sit amet. Tellus molestie nunc non blandit massa. Cursus vitae congue mauris rhoncus. Accumsan tortor posuere ac ut. Fringilla urna porttitor rhoncus dolor. Elit ullamcorper dignissim cras tincidunt lobortis. In cursus turpis massa tincidunt dui ut ornare lectus. Integer feugiat scelerisque varius morbi enim nunc. Bibendum neque egestas congue quisque egestas diam. Cras ornare arcu dui vivamus arcu felis bibendum. Dignissim suspendisse in est ante in nibh mauris. Sed tempus urna et pharetra pharetra massa massa ultricies mi.
|
||||
|
||||
Mollis nunc sed id semper risus in. Convallis a cras semper auctor neque. Diam sit amet nisl suscipit. Lacus viverra vitae congue eu consequat ac felis donec. Egestas integer eget aliquet nibh praesent tristique magna sit amet. Eget magna fermentum iaculis eu non diam. In vitae turpis massa sed elementum. Tristique et egestas quis ipsum suspendisse ultrices. Eget lorem dolor sed viverra ipsum. Vel turpis nunc eget lorem dolor sed viverra. Posuere ac ut consequat semper viverra nam. Laoreet suspendisse interdum consectetur libero id faucibus. Diam phasellus vestibulum lorem sed risus ultricies tristique. Rhoncus dolor purus non enim praesent elementum facilisis. Ultrices tincidunt arcu non sodales neque. Tempus egestas sed sed risus pretium quam vulputate. Viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare. Fringilla urna porttitor rhoncus dolor purus non. Amet dictum sit amet justo donec enim.
|
||||
|
||||
Mattis ullamcorper velit sed ullamcorper morbi tincidunt. Tortor posuere ac ut consequat semper viverra. Tellus mauris a diam maecenas sed enim ut sem viverra. Venenatis urna cursus eget nunc scelerisque viverra mauris in. Arcu ac tortor dignissim convallis aenean et tortor at. Curabitur gravida arcu ac tortor dignissim convallis aenean et tortor. Egestas tellus rutrum tellus pellentesque eu. Fusce ut placerat orci nulla pellentesque dignissim enim sit amet. Ut enim blandit volutpat maecenas volutpat blandit aliquam etiam. Id donec ultrices tincidunt arcu. Id cursus metus aliquam eleifend mi.
|
||||
|
||||
Tempus quam pellentesque nec nam aliquam sem. Risus at ultrices mi tempus imperdiet. Id porta nibh venenatis cras sed felis eget velit. Ipsum a arcu cursus vitae. Facilisis magna etiam tempor orci eu lobortis elementum. Tincidunt dui ut ornare lectus sit. Quisque non tellus orci ac. Blandit libero volutpat sed cras. Nec tincidunt praesent semper feugiat nibh sed pulvinar proin gravida. Egestas integer eget aliquet nibh praesent tristique magna.
|
||||
35
src/content/posts/de/using-mdx.mdx
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
title: 'Using MDX'
|
||||
description: 'Lorem ipsum dolor sit amet'
|
||||
pubDate: 'Jun 01 2024'
|
||||
heroImage: '../../../assets/blog-placeholder-5.jpg'
|
||||
category: de/technik
|
||||
tags:
|
||||
- markdown
|
||||
- astro
|
||||
---
|
||||
|
||||
This theme comes with the [@astrojs/mdx](https://docs.astro.build/en/guides/integrations-guide/mdx/) integration installed and configured in your `astro.config.mjs` config file. If you prefer not to use MDX, you can disable support by removing the integration from your config file.
|
||||
|
||||
## Why MDX?
|
||||
|
||||
MDX is a special flavor of Markdown that supports embedded JavaScript & JSX syntax. This unlocks the ability to [mix JavaScript and UI Components into your Markdown content](https://docs.astro.build/en/guides/integrations-guide/mdx/#mdx-in-astro) for things like interactive charts or alerts.
|
||||
|
||||
If you have existing content authored in MDX, this integration will hopefully make migrating to Astro a breeze.
|
||||
|
||||
## Example
|
||||
|
||||
Here is how you import and use a UI component inside of MDX.
|
||||
When you open this page in the browser, you should see the clickable button below.
|
||||
|
||||
import HeaderLink from '~/components/HeaderLink.astro';
|
||||
|
||||
<HeaderLink href="#" onclick="alert('clicked!')">
|
||||
Embedded component in MDX
|
||||
</HeaderLink>
|
||||
|
||||
## More Links
|
||||
|
||||
- [MDX Syntax Documentation](https://mdxjs.com/docs/what-is-mdx)
|
||||
- [Astro Usage Documentation](https://docs.astro.build/en/basics/astro-pages/#markdownmdx-pages)
|
||||
- **Note:** [Client Directives](https://docs.astro.build/en/reference/directives-reference/#client-directives) are still required to create interactive components. Otherwise, all components in your MDX will render as static HTML (no JavaScript) by default.
|
||||
12
src/content/posts/en/hello-world.md
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
title: 'Hello World'
|
||||
description: 'First English post.'
|
||||
pubDate: 'Apr 20 2026'
|
||||
heroImage: '../../../assets/blog-placeholder-1.jpg'
|
||||
category: en/general
|
||||
tags:
|
||||
- markdown
|
||||
translationKey: hello-world
|
||||
---
|
||||
|
||||
This is the first English post.
|
||||
152
src/i18n/posts.ts
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
import { type CollectionEntry, getCollection, getEntry } from 'astro:content';
|
||||
import { type Locale } from '~/consts';
|
||||
import { isLocale, localizePath } from '~/i18n/ui';
|
||||
|
||||
export function entryLocale(entry: { id: string }): Locale {
|
||||
const first = entry.id.split('/')[0];
|
||||
if (!isLocale(first)) {
|
||||
throw new Error(`Content entry "${entry.id}" is not under a locale folder (de/ or en/).`);
|
||||
}
|
||||
return first;
|
||||
}
|
||||
|
||||
export function entrySlug(entry: { id: string }): string {
|
||||
return entry.id.split('/').slice(1).join('/');
|
||||
}
|
||||
|
||||
// Back-compat aliases used across the codebase.
|
||||
export const postLocale = entryLocale;
|
||||
export const postSlug = entrySlug;
|
||||
|
||||
export async function getPostsByLocale(locale: Locale) {
|
||||
const posts = await getCollection('posts', (p) => entryLocale(p) === locale);
|
||||
return posts.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
|
||||
}
|
||||
|
||||
export async function getCategoriesByLocale(locale: Locale) {
|
||||
const categories = await getCollection('categories', (c) => entryLocale(c) === locale);
|
||||
return categories.sort((a, b) => a.data.name.localeCompare(b.data.name));
|
||||
}
|
||||
|
||||
export async function getPostsByCategory(category: CollectionEntry<'categories'>) {
|
||||
const locale = entryLocale(category);
|
||||
const posts = await getCollection(
|
||||
'posts',
|
||||
(p) => entryLocale(p) === locale && p.data.category?.id === category.id,
|
||||
);
|
||||
return posts.sort((a, b) => b.data.pubDate.valueOf() - a.data.pubDate.valueOf());
|
||||
}
|
||||
|
||||
/** Convert a tag name into a URL-safe slug. */
|
||||
export function tagSlug(tag: string): string {
|
||||
return tag
|
||||
.toLowerCase()
|
||||
.trim()
|
||||
.normalize('NFKD')
|
||||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.replace(/ß/g, 'ss')
|
||||
.replace(/ä/g, 'ae')
|
||||
.replace(/ö/g, 'oe')
|
||||
.replace(/ü/g, 'ue')
|
||||
.replace(/[^a-z0-9]+/g, '-')
|
||||
.replace(/^-+|-+$/g, '');
|
||||
}
|
||||
|
||||
/** Aggregated tag info across posts in one locale. */
|
||||
export interface TagEntry {
|
||||
name: string;
|
||||
slug: string;
|
||||
count: number;
|
||||
}
|
||||
|
||||
export async function getTagsByLocale(locale: Locale): Promise<TagEntry[]> {
|
||||
const posts = await getPostsByLocale(locale);
|
||||
const byName = new Map<string, TagEntry>();
|
||||
for (const post of posts) {
|
||||
for (const raw of post.data.tags ?? []) {
|
||||
const name = raw.trim();
|
||||
if (!name) continue;
|
||||
const existing = byName.get(name);
|
||||
if (existing) existing.count++;
|
||||
else byName.set(name, { name, slug: tagSlug(name), count: 1 });
|
||||
}
|
||||
}
|
||||
return [...byName.values()].sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
|
||||
/** Resolve a tag slug for a locale back to its canonical TagEntry. */
|
||||
export async function findTagBySlug(locale: Locale, slug: string): Promise<TagEntry | undefined> {
|
||||
const tags = await getTagsByLocale(locale);
|
||||
return tags.find((t) => t.slug === slug);
|
||||
}
|
||||
|
||||
export async function getPostsByTag(locale: Locale, slug: string) {
|
||||
const posts = await getPostsByLocale(locale);
|
||||
return posts.filter((p) => (p.data.tags ?? []).some((name) => tagSlug(name) === slug));
|
||||
}
|
||||
|
||||
export async function resolveCategory(post: CollectionEntry<'posts'>) {
|
||||
if (!post.data.category) return undefined;
|
||||
return await getEntry(post.data.category);
|
||||
}
|
||||
|
||||
/** URL segment used for category detail pages per locale. */
|
||||
export function categorySegment(locale: Locale): string {
|
||||
return locale === 'de' ? 'kategorie' : 'category';
|
||||
}
|
||||
|
||||
/** URL segment used for the category listing page per locale. */
|
||||
export function categoryIndexSegment(locale: Locale): string {
|
||||
return locale === 'de' ? 'kategorien' : 'categories';
|
||||
}
|
||||
|
||||
/** URL segment used for the about page per locale. */
|
||||
export function aboutSegment(locale: Locale): string {
|
||||
return locale === 'de' ? 'ueber-mich' : 'about';
|
||||
}
|
||||
|
||||
/** URL segment used for tag detail pages per locale. */
|
||||
export function tagSegment(locale: Locale): string {
|
||||
return locale === 'de' ? 'schlagwort' : 'tag';
|
||||
}
|
||||
|
||||
/** URL segment used for the tag listing page per locale. */
|
||||
export function tagIndexSegment(locale: Locale): string {
|
||||
return locale === 'de' ? 'schlagwoerter' : 'tags';
|
||||
}
|
||||
|
||||
export function categoryHref(category: CollectionEntry<'categories'>): string {
|
||||
const locale = entryLocale(category);
|
||||
return localizePath(`/${categorySegment(locale)}/${entrySlug(category)}/`, locale);
|
||||
}
|
||||
|
||||
export function postHref(post: CollectionEntry<'posts'>): string {
|
||||
const locale = entryLocale(post);
|
||||
return localizePath(`/${entrySlug(post)}/`, locale);
|
||||
}
|
||||
|
||||
export function tagHref(locale: Locale, tag: string | TagEntry): string {
|
||||
const slug = typeof tag === 'string' ? tagSlug(tag) : tag.slug;
|
||||
return localizePath(`/${tagSegment(locale)}/${slug}/`, locale);
|
||||
}
|
||||
|
||||
/** Canonical URL for any translatable entry. */
|
||||
export function entryHref(entry: CollectionEntry<'posts' | 'categories'>): string {
|
||||
return entry.collection === 'categories' ? categoryHref(entry) : postHref(entry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the translation of an entry in the target locale, matched via the
|
||||
* shared `translationKey` frontmatter field. Returns `undefined` when no
|
||||
* matching translation exists.
|
||||
*/
|
||||
export async function findTranslation(
|
||||
entry: CollectionEntry<'posts' | 'categories'>,
|
||||
target: Locale,
|
||||
): Promise<CollectionEntry<'posts' | 'categories'> | undefined> {
|
||||
const key = entry.data.translationKey;
|
||||
if (!key) return undefined;
|
||||
const collection = entry.collection;
|
||||
const all = await getCollection(collection, (e) => entryLocale(e) === target);
|
||||
return all.find((e) => e.data.translationKey === key);
|
||||
}
|
||||
108
src/i18n/ui.ts
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
import { DEFAULT_LOCALE, type Locale, LOCALES } from '~/consts';
|
||||
|
||||
export const ui = {
|
||||
de: {
|
||||
'nav.home': 'Start',
|
||||
'nav.about': 'Über mich',
|
||||
'nav.categories': 'Kategorien',
|
||||
'nav.tags': 'Schlagwörter',
|
||||
'post.lastUpdated': 'Zuletzt aktualisiert am',
|
||||
'post.category': 'Kategorie',
|
||||
'post.tags': 'Schlagwörter',
|
||||
'post.translationAvailable': 'Dieser Beitrag ist auch auf Englisch verfügbar:',
|
||||
'post.translationLink': 'Englische Version lesen',
|
||||
'categories.title': 'Kategorien',
|
||||
'categories.description': 'Alle Kategorien im Überblick.',
|
||||
'category.postsIn': 'Beiträge in',
|
||||
'category.noPosts': 'Noch keine Beiträge in dieser Kategorie.',
|
||||
'tags.title': 'Schlagwörter',
|
||||
'tags.description': 'Alle Schlagwörter im Überblick.',
|
||||
'tag.postsTagged': 'Beiträge mit',
|
||||
'tag.noPosts': 'Noch keine Beiträge mit diesem Stichwort.',
|
||||
'lang.de': 'Deutsch',
|
||||
'lang.en': 'English',
|
||||
},
|
||||
en: {
|
||||
'nav.home': 'Home',
|
||||
'nav.about': 'About',
|
||||
'nav.categories': 'Categories',
|
||||
'nav.tags': 'Tags',
|
||||
'post.lastUpdated': 'Last updated on',
|
||||
'post.category': 'Category',
|
||||
'post.tags': 'Tags',
|
||||
'post.translationAvailable': 'This post is also available in German:',
|
||||
'post.translationLink': 'Read the German version',
|
||||
'categories.title': 'Categories',
|
||||
'categories.description': 'All categories at a glance.',
|
||||
'category.postsIn': 'Posts in',
|
||||
'category.noPosts': 'No posts in this category yet.',
|
||||
'tags.title': 'Tags',
|
||||
'tags.description': 'All tags at a glance.',
|
||||
'tag.postsTagged': 'Posts tagged',
|
||||
'tag.noPosts': 'No posts with this tag yet.',
|
||||
'lang.de': 'Deutsch',
|
||||
'lang.en': 'English',
|
||||
},
|
||||
} as const satisfies Record<Locale, Record<string, string>>;
|
||||
|
||||
export type UIKey = keyof (typeof ui)['de'];
|
||||
|
||||
export function t(locale: Locale, key: UIKey): string {
|
||||
return ui[locale][key];
|
||||
}
|
||||
|
||||
export function isLocale(value: string | undefined): value is Locale {
|
||||
return !!value && (LOCALES as readonly string[]).includes(value);
|
||||
}
|
||||
|
||||
export function getLocaleFromUrl(url: URL): Locale {
|
||||
const seg = url.pathname.split('/').filter(Boolean)[0];
|
||||
return isLocale(seg) ? seg : DEFAULT_LOCALE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a URL for a route within a given locale. `path` is the route without
|
||||
* any language prefix, e.g. "/" or "/about".
|
||||
*/
|
||||
export function localizePath(path: string, locale: Locale): string {
|
||||
const normalized = path.startsWith('/') ? path : `/${path}`;
|
||||
if (locale === DEFAULT_LOCALE) return normalized;
|
||||
if (normalized === '/') return `/${locale}/`;
|
||||
return `/${locale}${normalized}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Segments whose URL slug differs per locale. The first segment of any
|
||||
* non-prefixed pathname is translated through this map when switching.
|
||||
*/
|
||||
const LOCALIZED_SEGMENTS: Record<Locale, Record<string, string>> = {
|
||||
de: {
|
||||
category: 'kategorie',
|
||||
categories: 'kategorien',
|
||||
about: 'ueber-mich',
|
||||
tag: 'schlagwort',
|
||||
tags: 'schlagwoerter',
|
||||
},
|
||||
en: {
|
||||
kategorie: 'category',
|
||||
kategorien: 'categories',
|
||||
'ueber-mich': 'about',
|
||||
schlagwort: 'tag',
|
||||
schlagwoerter: 'tags',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Swap the locale of the current pathname, preserving the rest of the route
|
||||
* and translating known per-locale URL segments (e.g. `kategorie` ↔ `category`).
|
||||
*/
|
||||
export function switchLocalePath(pathname: string, target: Locale): string {
|
||||
const parts = pathname.split('/').filter(Boolean);
|
||||
if (parts.length > 0 && isLocale(parts[0])) parts.shift();
|
||||
if (parts.length > 0) {
|
||||
const translated = LOCALIZED_SEGMENTS[target][parts[0]];
|
||||
if (translated) parts[0] = translated;
|
||||
}
|
||||
const rest = parts.length ? `/${parts.join('/')}` : '/';
|
||||
return localizePath(rest === '/' ? '/' : rest, target);
|
||||
}
|
||||
46
src/layouts/BaseLayout.astro
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
---
|
||||
import type { ImageMetadata } from 'astro';
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import { ClientRouter } from 'astro:transitions';
|
||||
import BaseHead from '~/components/BaseHead.astro';
|
||||
import Footer from '~/components/Footer.astro';
|
||||
import Header from '~/components/Header.astro';
|
||||
import { DEFAULT_LOCALE, type Locale } from '~/consts';
|
||||
import { getLocaleFromUrl } from '~/i18n/ui';
|
||||
|
||||
interface Props {
|
||||
title: string;
|
||||
description: string;
|
||||
locale?: Locale;
|
||||
image?: ImageMetadata;
|
||||
/** Current content entry, used for the language switcher's translation lookup. */
|
||||
entry?: CollectionEntry<'posts' | 'categories'>;
|
||||
/** Optional extra class on `<body>` for per-page styling hooks. */
|
||||
bodyClass?: string;
|
||||
}
|
||||
|
||||
const {
|
||||
title,
|
||||
description,
|
||||
image,
|
||||
entry,
|
||||
bodyClass,
|
||||
locale = getLocaleFromUrl(Astro.url) ?? DEFAULT_LOCALE,
|
||||
} = Astro.props;
|
||||
---
|
||||
|
||||
<!doctype html>
|
||||
<html lang={locale}>
|
||||
<head>
|
||||
<BaseHead title={title} description={description} image={image} locale={locale} />
|
||||
<ClientRouter />
|
||||
<slot name="head" />
|
||||
</head>
|
||||
<body class={bodyClass}>
|
||||
<Header locale={locale} entry={entry} transition:persist />
|
||||
<main transition:animate="fade">
|
||||
<slot />
|
||||
</main>
|
||||
<Footer transition:persist />
|
||||
</body>
|
||||
</html>
|
||||
149
src/layouts/Post.astro
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
---
|
||||
import { Image } from 'astro:assets';
|
||||
import { getEntry } from 'astro:content';
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import FormattedDate from '~/components/FormattedDate.astro';
|
||||
import BaseLayout from '~/layouts/BaseLayout.astro';
|
||||
import { DEFAULT_LOCALE, type Locale } from '~/consts';
|
||||
import { categoryHref, entryHref, findTranslation, tagHref } from '~/i18n/posts';
|
||||
import { getLocaleFromUrl, t } from '~/i18n/ui';
|
||||
|
||||
type Props = CollectionEntry<'posts'>['data'] & {
|
||||
locale?: Locale;
|
||||
entry?: CollectionEntry<'posts'>;
|
||||
};
|
||||
|
||||
const {
|
||||
title,
|
||||
description,
|
||||
pubDate,
|
||||
updatedDate,
|
||||
heroImage,
|
||||
category,
|
||||
tags,
|
||||
entry,
|
||||
locale = getLocaleFromUrl(Astro.url) ?? DEFAULT_LOCALE,
|
||||
} = Astro.props;
|
||||
|
||||
const categoryEntry = category ? await getEntry(category) : undefined;
|
||||
const otherLocale: Locale = locale === 'de' ? 'en' : 'de';
|
||||
const translation = entry ? await findTranslation(entry, otherLocale) : undefined;
|
||||
---
|
||||
|
||||
<BaseLayout title={title} description={description} image={heroImage} locale={locale} entry={entry}>
|
||||
<article>
|
||||
<div class="hero-image">
|
||||
{
|
||||
heroImage && (
|
||||
<Image
|
||||
width={1020}
|
||||
height={510}
|
||||
src={heroImage}
|
||||
alt=""
|
||||
transition:name={entry ? `hero-${entry.id}` : undefined}
|
||||
/>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
<div class="prose">
|
||||
<div class="title">
|
||||
<div class="date">
|
||||
<FormattedDate date={pubDate} locale={locale} />
|
||||
{
|
||||
updatedDate && (
|
||||
<div class="last-updated-on">
|
||||
{t(locale, 'post.lastUpdated')} <FormattedDate date={updatedDate} locale={locale} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
<h1>{title}</h1>
|
||||
{
|
||||
categoryEntry && (
|
||||
<p class="category">
|
||||
{t(locale, 'post.category')}:{' '}
|
||||
<a href={categoryHref(categoryEntry)}>{categoryEntry.data.name}</a>
|
||||
</p>
|
||||
)
|
||||
}
|
||||
{
|
||||
tags && tags.length > 0 && (
|
||||
<p class="tags">
|
||||
{t(locale, 'post.tags')}:{' '}
|
||||
{tags.map((name, i) => (
|
||||
<>
|
||||
{i > 0 && ', '}
|
||||
<a href={tagHref(locale, name)}>{name}</a>
|
||||
</>
|
||||
))}
|
||||
</p>
|
||||
)
|
||||
}
|
||||
<hr />
|
||||
</div>
|
||||
{
|
||||
translation && (
|
||||
<aside class="translation-notice" lang={otherLocale}>
|
||||
<span>{t(locale, 'post.translationAvailable')}</span>{' '}
|
||||
<a href={entryHref(translation)} hreflang={otherLocale}>
|
||||
{t(locale, 'post.translationLink')}
|
||||
</a>
|
||||
</aside>
|
||||
)
|
||||
}
|
||||
<slot />
|
||||
</div>
|
||||
</article>
|
||||
</BaseLayout>
|
||||
|
||||
<style>
|
||||
main {
|
||||
width: calc(100% - 2em);
|
||||
max-width: 100%;
|
||||
margin: 0;
|
||||
}
|
||||
.hero-image {
|
||||
width: 100%;
|
||||
}
|
||||
.hero-image img {
|
||||
display: block;
|
||||
margin: 0 auto;
|
||||
border-radius: 12px;
|
||||
box-shadow: var(--box-shadow);
|
||||
}
|
||||
.prose {
|
||||
width: 720px;
|
||||
max-width: calc(100% - 2em);
|
||||
margin: auto;
|
||||
padding: 1em;
|
||||
color: rgb(var(--gray-dark));
|
||||
}
|
||||
.title {
|
||||
margin-bottom: 1em;
|
||||
padding: 1em 0;
|
||||
text-align: center;
|
||||
line-height: 1;
|
||||
}
|
||||
.title h1 {
|
||||
margin: 0 0 0.5em 0;
|
||||
}
|
||||
.date {
|
||||
margin-bottom: 0.5em;
|
||||
color: rgb(var(--gray));
|
||||
}
|
||||
.last-updated-on {
|
||||
font-style: italic;
|
||||
}
|
||||
.translation-notice {
|
||||
margin: 0 0 2em 0;
|
||||
padding: 0.75em 1em;
|
||||
background: rgba(var(--gray-light), 0.6);
|
||||
border-left: 3px solid var(--accent);
|
||||
border-radius: 4px;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
.translation-notice a {
|
||||
color: var(--accent);
|
||||
font-weight: 600;
|
||||
}
|
||||
</style>
|
||||
21
src/pages/[...slug].astro
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
import { type CollectionEntry, render } from 'astro:content';
|
||||
import Post from '~/layouts/Post.astro';
|
||||
import { getPostsByLocale, postSlug } from '~/i18n/posts';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getPostsByLocale('de');
|
||||
return posts.map((post) => ({
|
||||
params: { slug: postSlug(post) },
|
||||
props: post,
|
||||
}));
|
||||
}
|
||||
type Props = CollectionEntry<'posts'>;
|
||||
|
||||
const post = Astro.props;
|
||||
const { Content } = await render(post);
|
||||
---
|
||||
|
||||
<Post {...post.data} locale="de" entry={post}>
|
||||
<Content />
|
||||
</Post>
|
||||
21
src/pages/en/[...slug].astro
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
---
|
||||
import { type CollectionEntry, render } from 'astro:content';
|
||||
import Post from '~/layouts/Post.astro';
|
||||
import { getPostsByLocale, postSlug } from '~/i18n/posts';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getPostsByLocale('en');
|
||||
return posts.map((post) => ({
|
||||
params: { slug: postSlug(post) },
|
||||
props: post,
|
||||
}));
|
||||
}
|
||||
type Props = CollectionEntry<'posts'>;
|
||||
|
||||
const post = Astro.props;
|
||||
const { Content } = await render(post);
|
||||
---
|
||||
|
||||
<Post {...post.data} locale="en" entry={post}>
|
||||
<Content />
|
||||
</Post>
|
||||
14
src/pages/en/about.astro
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
import AboutHeroImage from '~/assets/blog-placeholder-about.jpg';
|
||||
import Layout from '~/layouts/Post.astro';
|
||||
---
|
||||
|
||||
<Layout
|
||||
title="About Me"
|
||||
description="Short introduction."
|
||||
pubDate={new Date('August 08 2021')}
|
||||
heroImage={AboutHeroImage}
|
||||
locale="en"
|
||||
>
|
||||
<p>This is the English version of the about page.</p>
|
||||
</Layout>
|
||||
5
src/pages/en/categories.astro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
import CategoriesPage from '~/components/CategoriesPage.astro';
|
||||
---
|
||||
|
||||
<CategoriesPage locale="en" />
|
||||
18
src/pages/en/category/[slug].astro
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import CategoryDetailPage from '~/components/CategoryDetailPage.astro';
|
||||
import { entrySlug, getCategoriesByLocale } from '~/i18n/posts';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const categories = await getCategoriesByLocale('en');
|
||||
return categories.map((category) => ({
|
||||
params: { slug: entrySlug(category) },
|
||||
props: { category },
|
||||
}));
|
||||
}
|
||||
|
||||
type Props = { category: CollectionEntry<'categories'> };
|
||||
const { category } = Astro.props;
|
||||
---
|
||||
|
||||
<CategoryDetailPage locale="en" category={category} />
|
||||
5
src/pages/en/index.astro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
import HomePage from '~/components/HomePage.astro';
|
||||
---
|
||||
|
||||
<HomePage locale="en" />
|
||||
16
src/pages/en/rss.xml.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import rss from '@astrojs/rss';
|
||||
import { SITE } from '~/consts';
|
||||
import { getPostsByLocale, postSlug } from '~/i18n/posts';
|
||||
|
||||
export async function GET(context) {
|
||||
const posts = await getPostsByLocale('en');
|
||||
return rss({
|
||||
title: SITE.en.title,
|
||||
description: SITE.en.description,
|
||||
site: context.site,
|
||||
items: posts.map((post) => ({
|
||||
...post.data,
|
||||
link: `/en/${postSlug(post)}/`,
|
||||
})),
|
||||
});
|
||||
}
|
||||
13
src/pages/en/tag/[slug].astro
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
import TagDetailPage from '~/components/TagDetailPage.astro';
|
||||
import { getTagsByLocale } from '~/i18n/posts';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const tags = await getTagsByLocale('en');
|
||||
return tags.map((tag) => ({ params: { slug: tag.slug }, props: { tag } }));
|
||||
}
|
||||
|
||||
const { tag } = Astro.props;
|
||||
---
|
||||
|
||||
<TagDetailPage locale="en" tag={tag} />
|
||||
5
src/pages/en/tags.astro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
import TagsPage from '~/components/TagsPage.astro';
|
||||
---
|
||||
|
||||
<TagsPage locale="en" />
|
||||
5
src/pages/index.astro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
import HomePage from '~/components/HomePage.astro';
|
||||
---
|
||||
|
||||
<HomePage locale="de" />
|
||||
18
src/pages/kategorie/[slug].astro
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
---
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import CategoryDetailPage from '~/components/CategoryDetailPage.astro';
|
||||
import { entrySlug, getCategoriesByLocale } from '~/i18n/posts';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const categories = await getCategoriesByLocale('de');
|
||||
return categories.map((category) => ({
|
||||
params: { slug: entrySlug(category) },
|
||||
props: { category },
|
||||
}));
|
||||
}
|
||||
|
||||
type Props = { category: CollectionEntry<'categories'> };
|
||||
const { category } = Astro.props;
|
||||
---
|
||||
|
||||
<CategoryDetailPage locale="de" category={category} />
|
||||
5
src/pages/kategorien.astro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
import CategoriesPage from '~/components/CategoriesPage.astro';
|
||||
---
|
||||
|
||||
<CategoriesPage locale="de" />
|
||||
16
src/pages/rss.xml.js
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import rss from '@astrojs/rss';
|
||||
import { SITE } from '~/consts';
|
||||
import { getPostsByLocale, postSlug } from '~/i18n/posts';
|
||||
|
||||
export async function GET(context) {
|
||||
const posts = await getPostsByLocale('de');
|
||||
return rss({
|
||||
title: SITE.de.title,
|
||||
description: SITE.de.description,
|
||||
site: context.site,
|
||||
items: posts.map((post) => ({
|
||||
...post.data,
|
||||
link: `/${postSlug(post)}/`,
|
||||
})),
|
||||
});
|
||||
}
|
||||
5
src/pages/schlagwoerter.astro
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
import TagsPage from '~/components/TagsPage.astro';
|
||||
---
|
||||
|
||||
<TagsPage locale="de" />
|
||||
13
src/pages/schlagwort/[slug].astro
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
import TagDetailPage from '~/components/TagDetailPage.astro';
|
||||
import { getTagsByLocale } from '~/i18n/posts';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const tags = await getTagsByLocale('de');
|
||||
return tags.map((tag) => ({ params: { slug: tag.slug }, props: { tag } }));
|
||||
}
|
||||
|
||||
const { tag } = Astro.props;
|
||||
---
|
||||
|
||||
<TagDetailPage locale="de" tag={tag} />
|
||||
14
src/pages/ueber-mich.astro
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
import AboutHeroImage from '~/assets/blog-placeholder-about.jpg';
|
||||
import Layout from '~/layouts/Post.astro';
|
||||
---
|
||||
|
||||
<Layout
|
||||
title="Über mich"
|
||||
description="Kurze Vorstellung."
|
||||
pubDate={new Date('August 08 2021')}
|
||||
heroImage={AboutHeroImage}
|
||||
locale="de"
|
||||
>
|
||||
<p>Hier steht die deutsche Version der Über-mich-Seite.</p>
|
||||
</Layout>
|
||||
141
src/styles/global.css
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
/*
|
||||
The CSS in this style tag is based off of Bear Blog's default CSS.
|
||||
https://github.com/HermanMartinus/bearblog/blob/297026a877bc2ab2b3bdfbd6b9f7961c350917dd/templates/styles/blog/default.css
|
||||
License MIT: https://github.com/HermanMartinus/bearblog/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
:root {
|
||||
--accent: #2337ff;
|
||||
--accent-dark: #000d8a;
|
||||
--black: 15, 18, 25;
|
||||
--gray: 96, 115, 159;
|
||||
--gray-light: 229, 233, 240;
|
||||
--gray-dark: 34, 41, 57;
|
||||
--gray-gradient: rgba(var(--gray-light), 50%), #fff;
|
||||
--box-shadow:
|
||||
0 2px 6px rgba(var(--gray), 25%), 0 8px 24px rgba(var(--gray), 33%),
|
||||
0 16px 32px rgba(var(--gray), 33%);
|
||||
}
|
||||
body {
|
||||
font-family: var(--font-atkinson);
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: left;
|
||||
background: linear-gradient(var(--gray-gradient)) no-repeat;
|
||||
background-size: 100% 600px;
|
||||
word-wrap: break-word;
|
||||
overflow-wrap: break-word;
|
||||
color: rgb(var(--gray-dark));
|
||||
font-size: 20px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
main {
|
||||
width: 720px;
|
||||
max-width: calc(100% - 2em);
|
||||
margin: auto;
|
||||
padding: 3em 1em;
|
||||
}
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
margin: 0 0 0.5rem 0;
|
||||
color: rgb(var(--black));
|
||||
line-height: 1.2;
|
||||
}
|
||||
h1 {
|
||||
font-size: 3.052em;
|
||||
}
|
||||
h2 {
|
||||
font-size: 2.441em;
|
||||
}
|
||||
h3 {
|
||||
font-size: 1.953em;
|
||||
}
|
||||
h4 {
|
||||
font-size: 1.563em;
|
||||
}
|
||||
h5 {
|
||||
font-size: 1.25em;
|
||||
}
|
||||
strong,
|
||||
b {
|
||||
font-weight: 700;
|
||||
}
|
||||
a {
|
||||
color: var(--accent);
|
||||
}
|
||||
a:hover {
|
||||
color: var(--accent);
|
||||
}
|
||||
p {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
.prose p {
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
textarea {
|
||||
width: 100%;
|
||||
font-size: 16px;
|
||||
}
|
||||
input {
|
||||
font-size: 16px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
border-radius: 8px;
|
||||
}
|
||||
code {
|
||||
padding: 2px 5px;
|
||||
background-color: rgb(var(--gray-light));
|
||||
border-radius: 2px;
|
||||
}
|
||||
pre {
|
||||
padding: 1.5em;
|
||||
border-radius: 8px;
|
||||
}
|
||||
pre > code {
|
||||
all: unset;
|
||||
}
|
||||
blockquote {
|
||||
border-left: 4px solid var(--accent);
|
||||
padding: 0 0 0 20px;
|
||||
margin: 0;
|
||||
font-size: 1.333em;
|
||||
}
|
||||
hr {
|
||||
border: none;
|
||||
border-top: 1px solid rgb(var(--gray-light));
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
body {
|
||||
font-size: 18px;
|
||||
}
|
||||
main {
|
||||
padding: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
.sr-only {
|
||||
border: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
position: absolute !important;
|
||||
height: 1px;
|
||||
width: 1px;
|
||||
overflow: hidden;
|
||||
/* IE6, IE7 - a 0 height clip, off to the bottom right of the visible 1px box */
|
||||
clip: rect(1px 1px 1px 1px);
|
||||
/* maybe deprecated but we need to support legacy browsers */
|
||||
clip: rect(1px, 1px, 1px, 1px);
|
||||
/* modern browsers, clip-path works inwards from each corner */
|
||||
clip-path: inset(50%);
|
||||
/* added line to stop words getting smushed together (as they go onto separate lines and some screen readers do not understand line feeds as a space */
|
||||
white-space: nowrap;
|
||||
}
|
||||
11
tsconfig.json
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"extends": "astro/tsconfigs/strict",
|
||||
"include": [".astro/types.d.ts", "**/*"],
|
||||
"exclude": ["dist"],
|
||||
"compilerOptions": {
|
||||
"strictNullChecks": true,
|
||||
"paths": {
|
||||
"~/*": ["./src/*"]
|
||||
}
|
||||
}
|
||||
}
|
||||