Use history.replaceState ageVerified query and improve export-story script
This commit is contained in:
parent
21a77ed254
commit
fb30f1b416
16 changed files with 96 additions and 83 deletions
|
|
@ -53,7 +53,6 @@ import { IconTriangleExclamation } from "./icons";
|
|||
<AgeRestrictedScriptInline />
|
||||
|
||||
<script>
|
||||
const ENABLE_VIEW_TRANSITIONS = false;
|
||||
type AgeVerified = "true" | undefined;
|
||||
|
||||
const ageRestrictedModalSetup = () => {
|
||||
|
|
@ -97,9 +96,6 @@ import { IconTriangleExclamation } from "./icons";
|
|||
rejectButton.focus();
|
||||
}
|
||||
};
|
||||
if (ENABLE_VIEW_TRANSITIONS) {
|
||||
document.addEventListener("astro:page-load", ageRestrictedModalSetup);
|
||||
} else {
|
||||
ageRestrictedModalSetup();
|
||||
}
|
||||
|
||||
ageRestrictedModalSetup();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
---
|
||||
---
|
||||
|
||||
<script is:inline>function a(){let b=document,c="#modal-age-restricted",d="true",e=b.querySelector("body > "+c),f="ageVerified",g="searchParams",h=localStorage;new URL(b.location)[g].get(f)===d&&(h[f]=d);e&&(h[f]===d?b.querySelectorAll("a[href][data-age-restricted]").forEach(x=>{let y=new URL(x.href);y[g].set(f,d);x.href=y.href}):((b.body.style.overflow="hidden"),b.querySelectorAll("body > :not("+c+")").forEach(x=>x.setAttribute("inert",d)),(e.style.display="block")))};document.addEventListener("astro:after-swap",a);a()</script>
|
||||
<script is:inline>(function (){let b=document,c="#modal-age-restricted",d="true",e=b.querySelector("body > "+c),f="ageVerified",g="searchParams",h=localStorage,i=new URL(b.location),j=history;i[g].get(f)===d&&(h[f]=d,j&&(i[g].delete(f),j.replaceState({},"",i)));e&&(h[f]===d?b.querySelectorAll("a[href][data-age-restricted]").forEach(x=>{let y=new URL(x.href);y[g].set(f,d);x.href=y.href}):((b.body.style.overflow="hidden"),b.querySelectorAll("body > :not("+c+")").forEach(x=>x.setAttribute("inert",d)),(e.style.display="block")))})()</script>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import DarkModeScriptInline from "./DarkModeScriptInline.astro";
|
|||
<DarkModeScriptInline />
|
||||
|
||||
<script>
|
||||
const ENABLE_VIEW_TRANSITIONS = false;
|
||||
type ColorScheme = "auto" | "dark" | "light" | undefined;
|
||||
|
||||
const colorSchemeSetup = () => {
|
||||
|
|
@ -31,9 +30,6 @@ import DarkModeScriptInline from "./DarkModeScriptInline.astro";
|
|||
button.setAttribute("aria-hidden", "false");
|
||||
});
|
||||
};
|
||||
if (ENABLE_VIEW_TRANSITIONS) {
|
||||
document.addEventListener("astro:page-load", colorSchemeSetup);
|
||||
} else {
|
||||
colorSchemeSetup();
|
||||
}
|
||||
|
||||
colorSchemeSetup();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
---
|
||||
---
|
||||
|
||||
<script is:inline>function a(){var b="dark",c="auto",d="colorScheme",e=document.body.classList,f=localStorage,g=f&&f[d];g&&g!==c?g===b&&e.add(b):(f&&(f[d]=c),matchMedia("(prefers-color-scheme: dark)").matches&&e.add(b))};document.addEventListener("astro:after-swap",a);a()</script>
|
||||
<script is:inline>(function (){var b="dark",c="auto",d="colorScheme",e=document.body.classList,f=localStorage,g=f&&f[d];g&&g!==c?g===b&&e.add(b):(f&&(f[d]=c),matchMedia("(prefers-color-scheme: dark)").matches&&e.add(b))})()</script>
|
||||
|
|
|
|||
|
|
@ -123,8 +123,6 @@ const { link, instance, user, postId } = Astro.props;
|
|||
</template>
|
||||
|
||||
<script>
|
||||
const ENABLE_VIEW_TRANSITIONS = false;
|
||||
|
||||
interface MastodonPost {
|
||||
link: string;
|
||||
instance: string;
|
||||
|
|
@ -322,9 +320,5 @@ const { link, instance, user, postId } = Astro.props;
|
|||
loadCommentsButton.style.removeProperty("display");
|
||||
}
|
||||
|
||||
if (ENABLE_VIEW_TRANSITIONS) {
|
||||
document.addEventListener("astro:page-load", initCommentSection);
|
||||
} else {
|
||||
initCommentSection();
|
||||
}
|
||||
initCommentSection();
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -93,9 +93,7 @@ const thumbnail =
|
|||
|
||||
<BaseLayout pageTitle={props.title} lang={props.lang}>
|
||||
<Fragment slot="head">
|
||||
{ props.isDraft ? (
|
||||
<meta name="robots" content="noindex" />
|
||||
) : null }
|
||||
{props.isDraft ? <meta name="robots" content="noindex" /> : null}
|
||||
<meta property="og:title" content={props.title} data-pagefind-meta="title[content]" />
|
||||
<meta property="og:url" content={Astro.url} data-pagefind-meta="url[content]" />
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 – 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>
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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" },
|
||||
});
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
interface ParsedHTMLTag {
|
||||
tag: string;
|
||||
type: "open" | "close" | "both";
|
||||
attributes?: Record<string, string|null>;
|
||||
attributes?: Record<string, string | null>;
|
||||
}
|
||||
|
||||
const OPEN_TAG_START_REGEX = /^<\s*([a-z-]+)\s*/;
|
||||
|
|
@ -46,8 +46,8 @@ export function parsePartialHTMLTag(text: string): ParsedHTMLTag {
|
|||
return {
|
||||
tag: closeTag[1],
|
||||
type: "close",
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
throw new Error(`Unable to parse partial HTML tag: ${text}`);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue