feat: каркас v2 — Astro 5 + миграция 50 постов из WP + RSS для IPB Importer
- Astro 5 (6.3.6) minimal scaffold с Content Collections для posts/pages - Тёмная палитра в духе старой темы darkness-10 (тонкая типографика Inter+Lora) - Layout с шапкой/футером, главной-лентой, страницами категорий и одиночными постами - RSS (общий + per-category) под IPB RSS Importer: RFC-822 pubDate, <guid isPermaLink="true">, <content:encoded> с CDATA, <lastBuildDate> - RSS_CUTOFF фильтр: архив 2009-2015 на сайте остаётся, в RSS — только новые - 50 постов и 6 страниц мигрированы из WP (anotherreflctions_ru @ db.hhivp.com) через scripts/migrate-wp.mjs (HTML→md без внешних зависимостей) - sitemap.xml автоматически через @astrojs/sitemap
This commit is contained in:
51
src/pages/[slug].astro
Normal file
51
src/pages/[slug].astro
Normal file
@@ -0,0 +1,51 @@
|
||||
---
|
||||
import { getCollection, render } from 'astro:content';
|
||||
import BaseLayout from '../layouts/BaseLayout.astro';
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getCollection('posts');
|
||||
const pages = await getCollection('pages');
|
||||
return [
|
||||
...posts.map((p) => ({ params: { slug: p.data.slug }, props: { entry: p, kind: 'post' as const } })),
|
||||
...pages.map((p) => ({ params: { slug: p.data.slug }, props: { entry: p, kind: 'page' as const } })),
|
||||
];
|
||||
}
|
||||
|
||||
const { entry, kind } = Astro.props;
|
||||
const { Content } = await render(entry);
|
||||
|
||||
const fmtDate = (d: Date) =>
|
||||
d.toLocaleDateString('ru-RU', { year: 'numeric', month: 'long', day: 'numeric' });
|
||||
---
|
||||
<BaseLayout title={entry.data.title} description={kind === 'post' ? entry.data.description : undefined} ogType={kind === 'post' ? 'article' : 'website'}>
|
||||
<article class="post">
|
||||
<header>
|
||||
<h1>{entry.data.title}</h1>
|
||||
{kind === 'post' && (
|
||||
<div class="post-meta">
|
||||
<time datetime={entry.data.pubDate.toISOString()}>{fmtDate(entry.data.pubDate)}</time>
|
||||
{entry.data.categories.length > 0 && (
|
||||
<>
|
||||
{' · '}
|
||||
{entry.data.categories.map((cat, i) => (
|
||||
<>
|
||||
{i > 0 && ', '}
|
||||
<a href={`/category/${entry.data.categorySlugs[i]}/`}>{cat}</a>
|
||||
</>
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
<div class="post-body">
|
||||
<Content />
|
||||
</div>
|
||||
</article>
|
||||
|
||||
{kind === 'post' && (
|
||||
<nav class="pagination">
|
||||
<a href="/">← Все новости</a>
|
||||
</nav>
|
||||
)}
|
||||
</BaseLayout>
|
||||
Reference in New Issue
Block a user