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

@ -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) {