Use history.replaceState ageVerified query and improve export-story script

This commit is contained in:
Bad Manners 2024-08-26 14:53:09 -03:00
parent 21a77ed254
commit fb30f1b416
16 changed files with 96 additions and 83 deletions

View file

@ -5,5 +5,5 @@ import GalleryLayout from "../layouts/GalleryLayout.astro";
<GalleryLayout pageTitle="404">
<meta slot="head" property="og:description" content="Not found" />
<h1 class="m-2 text-2xl font-semibold text-stone-800 dark:text-stone-100">404 &ndash; Not Found</h1>
<p class="my-4">The requested link couldn't be found. Make sure that the URL is correct.</p>
<p class="my-4">The requested link could not be found. Make sure that the URL is correct.</p>
</GalleryLayout>

View file

@ -25,6 +25,12 @@ const WEBSITE_LIST = [
type ExportWebsiteName = typeof WEBSITE_LIST extends ReadonlyArray<{ website: infer K }> ? K : never;
export type ExportStoryResponse = {
story: string;
description: Record<string, string>;
thumbnail: string | null;
};
type Props = {
story: CollectionEntry<"stories">;
};
@ -98,7 +104,9 @@ export const GET: APIRoute<Props, Params> = async ({ props: { story }, site }) =
case "markdown":
return {
descriptionFilename: `description_${exportWebsite}.md`,
descriptionText: toPlainMarkdown(storyDescription).replaceAll(/\n\n\n+/g, "\n\n").trim(),
descriptionText: toPlainMarkdown(storyDescription)
.replaceAll(/\n\n\n+/g, "\n\n")
.trim(),
};
default:
const unknown: never = exportFormat;
@ -144,7 +152,7 @@ export const GET: APIRoute<Props, Params> = async ({ props: { story }, site }) =
{} as Record<string, string>,
),
thumbnail: story.data.thumbnail ? story.data.thumbnail.src : null,
}),
} satisfies ExportStoryResponse),
{ headers: { "Content-Type": "application/json; charset=utf-8" } },
);
} catch (e) {

View file

@ -1,10 +1,14 @@
import type { APIRoute } from "astro";
export type HealthcheckResponse = {
isAlive: true;
};
export const GET: APIRoute = () => {
if (import.meta.env.PROD) {
return new Response(null, { status: 404 });
}
return new Response(JSON.stringify({ isAlive: true }), {
return new Response(JSON.stringify({ isAlive: !false } satisfies HealthcheckResponse), {
headers: { "Content-Type": "application/json; charset=utf-8" },
});
};

View file

@ -45,6 +45,7 @@ async function storyFeedItem(
" ",
),
categories: ["story"],
commentsUrl: data.posts.mastodon?.link,
content: sanitizeHtml(
`<h1>${data.title}</h1>` +
`<p>${t(
@ -89,6 +90,7 @@ async function gameFeedItem(
" ",
),
categories: ["game"],
commentsUrl: data.posts.mastodon?.link,
content: sanitizeHtml(
`<h1>${data.title}</h1>` +
`<p>${t(

View file

@ -70,11 +70,7 @@ if (uncategorizedTagsSet.size > 0) {
---
<GalleryLayout pageTitle="Tags">
<meta
property="og:description"
slot="head"
content="Bad Manners || Find all content with a specific tag."
/>
<meta property="og:description" slot="head" content="Bad Manners || Find all content with a specific tag." />
<h1 class="m-2 text-2xl font-semibold text-stone-800 dark:text-stone-100">All available tags</h1>
<p class="my-4">You can find all content with a specific tag by selecting it below from the appropriate category.</p>
<section class="my-2" aria-labelledby="category-series">

View file

@ -120,11 +120,7 @@ const totalWorksWithTag = t(
---
<GalleryLayout pageTitle={`Works tagged "${props.tag}"`}>
<meta
slot="head"
content={`Bad Manners || ${totalWorksWithTag || props.tag}`}
property="og:description"
/>
<meta slot="head" content={`Bad Manners || ${totalWorksWithTag || props.tag}`} property="og:description" />
<h1 class="m-2 text-2xl font-semibold text-stone-800 dark:text-stone-100">Works tagged "{props.tag}"</h1>
<div class="my-4">
<Prose>