- Improved schema validation - Move username parsing and other validators to schema types - Fix astro check command - Add JSON/YAML schema validation for data collections - Update licenses - Remove deployment script in favor of rsync - Prevent unsanitized input in export-story script - Change "eng" language to "en", per BCP47 - Clean up i18n keys and add aria attributes - Improve MastodonComments behavior on no-JS browsers
35 lines
1 KiB
Text
35 lines
1 KiB
Text
---
|
|
import type { GetStaticPaths } from "astro";
|
|
import { type CollectionEntry, getCollection } from "astro:content";
|
|
import getReadingTime from "reading-time";
|
|
import StoryLayout from "../../layouts/StoryLayout.astro";
|
|
|
|
type Props = CollectionEntry<"stories">;
|
|
|
|
type Params = {
|
|
slug: CollectionEntry<"stories">["slug"];
|
|
};
|
|
|
|
export const getStaticPaths: GetStaticPaths = async () => {
|
|
const stories = await getCollection("stories");
|
|
return stories.map((story) => ({
|
|
params: { slug: story.slug } satisfies Params,
|
|
props: story satisfies Props,
|
|
}));
|
|
};
|
|
|
|
const story = Astro.props;
|
|
const readingTime = getReadingTime(story.body);
|
|
if (story.data.wordCount && Math.abs(story.data.wordCount - readingTime.words) >= 150) {
|
|
console.warn(
|
|
`"wordCount" differs greatly from actual word count for published story ${story.data.title} ("${story.slug}") ` +
|
|
`(expected ~${story.data.wordCount}, found ${readingTime.words})`,
|
|
);
|
|
}
|
|
|
|
const { Content } = await story.render();
|
|
---
|
|
|
|
<StoryLayout {...story.data}>
|
|
<Content />
|
|
</StoryLayout>
|