Initial commit: Astro 6 static blog site
All checks were successful
Deploy / deploy (push) Successful in 49s
All checks were successful
Deploy / deploy (push) Successful in 49s
- German (default) and English i18n support - Categories and tags - Blog posts with hero images - Dark/light theme switcher - View Transitions removed to fix reload ghost images - Webmentions integration - RSS feeds per locale Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
commit
5bb63bacf5
95 changed files with 12199 additions and 0 deletions
163
src/layouts/Post.astro
Normal file
163
src/layouts/Post.astro
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
---
|
||||
import { Image } from 'astro:assets';
|
||||
import { getEntry } from 'astro:content';
|
||||
import type { CollectionEntry } from 'astro:content';
|
||||
import FormattedDate from '~/components/FormattedDate.astro';
|
||||
import Webmentions from '~/components/Webmentions.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 class="h-entry">
|
||||
<a href={Astro.url.pathname} class="u-url" hidden></a>
|
||||
<div class="hero-image">
|
||||
{
|
||||
heroImage && (
|
||||
<Image
|
||||
class="u-photo"
|
||||
width={1020}
|
||||
height={510}
|
||||
src={heroImage}
|
||||
alt=""
|
||||
/>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
<div class="prose">
|
||||
<div class="title">
|
||||
<div class="date">
|
||||
<FormattedDate date={pubDate} locale={locale} class="dt-published" />
|
||||
{
|
||||
updatedDate && (
|
||||
<div class="last-updated-on">
|
||||
{t(locale, 'post.lastUpdated')}{' '}
|
||||
<FormattedDate date={updatedDate} locale={locale} class="dt-updated" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
<h1 class="p-name">{title}</h1>
|
||||
<p class="p-summary" hidden>{description}</p>
|
||||
<p class="p-author h-card" hidden>
|
||||
<a class="u-url p-name" href={new URL('/', Astro.site)}>Adrian Altner</a>
|
||||
</p>
|
||||
{
|
||||
categoryEntry && (
|
||||
<p class="category">
|
||||
{t(locale, 'post.category')}:{' '}
|
||||
<a href={categoryHref(categoryEntry)} class="p-category">
|
||||
{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)} class="p-category">
|
||||
{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>
|
||||
)
|
||||
}
|
||||
<div class="e-content">
|
||||
<slot />
|
||||
</div>
|
||||
<Webmentions target={new URL(Astro.url.pathname, Astro.site)} locale={locale} />
|
||||
</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>
|
||||
Loading…
Add table
Add a link
Reference in a new issue