Fix NavHeader for production and improve AgeRestrictedModal script
This commit is contained in:
parent
eccd4d8bfe
commit
e2527064db
7 changed files with 58 additions and 54 deletions
13
package-lock.json
generated
13
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "badmanners.xyz",
|
||||
"version": "2.1.1",
|
||||
"version": "2.1.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "badmanners.xyz",
|
||||
"version": "2.1.1",
|
||||
"version": "2.1.2",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@astrojs/check": "^0.9.2",
|
||||
|
|
@ -4809,11 +4809,12 @@
|
|||
]
|
||||
},
|
||||
"node_modules/micromatch": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
|
||||
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
||||
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"braces": "^3.0.2",
|
||||
"braces": "^3.0.3",
|
||||
"picomatch": "^2.3.1"
|
||||
},
|
||||
"engines": {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "badmanners.xyz",
|
||||
"type": "module",
|
||||
"version": "2.1.1",
|
||||
"version": "2.1.2",
|
||||
"scripts": {
|
||||
"postinstall": "astro sync",
|
||||
"dev": "astro dev",
|
||||
|
|
|
|||
|
|
@ -54,13 +54,18 @@ import IconTriangleExclamation from "./icons/IconTriangleExclamation.astro";
|
|||
|
||||
<script>
|
||||
import { ENABLE_VIEW_TRANSITIONS } from "astro:env/client";
|
||||
type AgeVerified = "true" | undefined;
|
||||
|
||||
const ageRestrictedModalSetup = () => {
|
||||
const modal = document.querySelector<HTMLElementTagNameMap["div"]>("body > div#modal-age-restricted");
|
||||
const modal = document.querySelector<HTMLElementTagNameMap["div"]>("div#modal-age-restricted");
|
||||
// Not an age-restricted page
|
||||
if (!modal) {
|
||||
throw new Error("Missing #modal-age-restricted element! Make sure that it's a direct child of body.");
|
||||
return;
|
||||
}
|
||||
let ageVerified: "true" | undefined = localStorage.ageVerified;
|
||||
if (modal !== document.querySelector("body > div#modal-age-restricted")) {
|
||||
throw new Error("#modal-age-restricted must be a direct child of the body element!");
|
||||
}
|
||||
let ageVerified: AgeVerified = localStorage.ageVerified;
|
||||
if (ageVerified !== "true") {
|
||||
const rejectButton = modal.querySelector<HTMLElementTagNameMap["button"]>("button[data-modal-reject]")!;
|
||||
const onRejectButtonClick = (e: MouseEvent) => {
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
---
|
||||
---
|
||||
|
||||
<script is:inline>function a(){let b=document,c="#modal-age-restricted",d="true";localStorage.ageVerified!==d&&((b.body.style.overflow="hidden"),b.querySelectorAll("body > :not("+c+")").forEach(e=>e.setAttribute("inert",d)),(b.querySelector("body > "+c).style.display="block"));}document.addEventListener("astro:after-swap",a);a()</script>
|
||||
<script is:inline>function a(){let b=document,c="#modal-age-restricted",d="true",e=b.querySelector("body > "+c);e&&localStorage.ageVerified!==d&&((b.body.style.overflow="hidden"),b.querySelectorAll("body > :not("+c+")").forEach(f=>f.setAttribute("inert",d)),(e.style.display="block"))};document.addEventListener("astro:after-swap",a);a()</script>
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@ import DarkModeScriptInline from "./DarkModeScriptInline.astro";
|
|||
|
||||
<script>
|
||||
import { ENABLE_VIEW_TRANSITIONS } from "astro:env/client";
|
||||
type ColorScheme = "auto" | "dark" | "light";
|
||||
type ColorScheme = "auto" | "dark" | "light" | undefined;
|
||||
|
||||
const colorSchemeSetup = () => {
|
||||
let colorScheme: ColorScheme | undefined = localStorage.colorScheme;
|
||||
let colorScheme: ColorScheme = localStorage.colorScheme;
|
||||
if (!colorScheme || colorScheme === "auto") {
|
||||
colorScheme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
||||
}
|
||||
|
|
@ -25,10 +25,10 @@ import DarkModeScriptInline from "./DarkModeScriptInline.astro";
|
|||
localStorage.colorScheme = colorScheme;
|
||||
};
|
||||
document.querySelectorAll<HTMLElementTagNameMap["button"]>("button[data-dark-mode]").forEach((button) => {
|
||||
button.addEventListener("click", toggleColorScheme);
|
||||
button.classList.remove("hidden");
|
||||
button.style.removeProperty("display");
|
||||
button.setAttribute("aria-hidden", "false");
|
||||
button.addEventListener("click", toggleColorScheme);
|
||||
});
|
||||
};
|
||||
if (ENABLE_VIEW_TRANSITIONS) {
|
||||
|
|
|
|||
|
|
@ -1,16 +1,14 @@
|
|||
---
|
||||
interface NavRoute {
|
||||
path: string;
|
||||
name: string;
|
||||
}
|
||||
|
||||
const navRoutes: NavRoute[] = [
|
||||
const navRoutes = [
|
||||
{ path: "/", name: "Home" },
|
||||
{ path: "/about", name: "About me" },
|
||||
{ path: "/work", name: "My work" },
|
||||
];
|
||||
] as const satisfies { path: string; name: string }[];
|
||||
|
||||
const isCurrentRoute = (navRoute: NavRoute) => Astro.url.pathname == navRoute.path;
|
||||
type NavRoute = typeof navRoutes extends (infer R)[] ? R : never;
|
||||
|
||||
const isCurrentRoute = ({ path }: NavRoute) =>
|
||||
Astro.url.pathname === path || (path !== "/" && Astro.url.pathname === `${path}/`);
|
||||
---
|
||||
|
||||
<nav class="text-md pb-6 pt-2 sm:text-lg print:hidden">
|
||||
|
|
|
|||
|
|
@ -3,38 +3,38 @@ import { APACHE_CONFIG } from "astro:env/server";
|
|||
|
||||
const htaccess = `
|
||||
ErrorDocument 404 /404.html
|
||||
RedirectMatch 301 ^/tos(\/(index.html)?)?$ /terms_of_service/
|
||||
RedirectMatch 301 ^/contact(\/(index.html)?)?$ /
|
||||
RedirectMatch 301 ^/@/(aryion|ekas?)\b https://aryion.com/g4/user/BadManners
|
||||
RedirectMatch 301 ^/@/(bluesky|bsky)\b https://bsky.app/profile/badmanners.xyz
|
||||
RedirectMatch 301 ^/@/(buymeacoffee|bmac)\b https://www.buymeacoffee.com/BadMannersXYZ
|
||||
RedirectMatch 301 ^/@/carrd\b https://badmanners.carrd.co
|
||||
RedirectMatch 301 ^/@/codeberg\b https://codeberg.org/BadManners
|
||||
RedirectMatch 301 ^/@/cohost\b https://cohost.org/BadManners
|
||||
RedirectMatch 301 ^/@/(fur[_-]?affinity|fa)\b https://www.furaffinity.net/user/badmanners
|
||||
RedirectMatch 301 ^/@/gallery\b https://gallery.badmanners.xyz
|
||||
RedirectMatch 301 ^/@/(github|gh)\b https://github.com/BadMannersXYZ
|
||||
RedirectMatch 301 ^/@/gitlab\b https://gitlab.com/Bad_Manners
|
||||
RedirectMatch 301 ^/@/gumroad\b https://badmanners.gumroad.com/
|
||||
RedirectMatch 301 ^/@/(inkbunny|ib)\b https://inkbunny.net/BadManners
|
||||
RedirectMatch 301 ^/@/itaku\b https://itaku.ee/profile/badmanners
|
||||
RedirectMatch 301 ^/@/itch\b https://bad-manners.itch.io
|
||||
RedirectMatch 301 ^/@/keybase\b https://keybase.io/badmanners
|
||||
RedirectMatch 301 ^/@/ko[_-]?fi\b https://ko-fi.com/badmanners
|
||||
RedirectMatch 301 ^/@/(mastodon|meow\.social|gulp\.cafe)\b https://meow.social/@BadManners
|
||||
RedirectMatch 301 ^/@/neocities\b https://badmanners.neocities.org/
|
||||
RedirectMatch 301 ^/@/picarto\b https://www.picarto.tv/BadManners
|
||||
RedirectMatch 301 ^/@/pillowfort\b https://www.pillowfort.social/BadManners
|
||||
RedirectMatch 301 ^/@/reddit\b https://www.reddit.com/user/BadManners_/
|
||||
RedirectMatch 301 ^/@/signal\b https://signal.me/#eu/ytt_rk0fFmAB2JAW-x2PbUiJyc_H3kYmfL_Pq4QNh5QIDsiFtjdFHaqFRs1D36tB
|
||||
RedirectMatch 301 ^/@/(sofurry|sf)\b https://bad-manners.sofurry.com/
|
||||
RedirectMatch 301 ^/@/steam\b https://steamcommunity.com/id/badmanners_/
|
||||
RedirectMatch 301 ^/@/subscribestar\b https://subscribestar.adult/bad-manners
|
||||
RedirectMatch 301 ^/@/(telegram|t\.me)\b https://t.me/bad_manners
|
||||
RedirectMatch 301 ^/@/twitch\b https://www.twitch.tv/bad__manners
|
||||
RedirectMatch 301 ^/@/weasyl\b https://www.weasyl.com/~badmanners
|
||||
RedirectMatch 301 ^/@/(x|twitter)\b https://x.com/BadManners__
|
||||
RedirectMatch 301 ^/@/(youtu\.?be|yt)\b https://www.youtube.com/@BadMannersXYZ
|
||||
RedirectMatch 301 ^/tos(/(index.html)?)?$ /terms_of_service/
|
||||
RedirectMatch 301 ^/contact(/(index.html)?)?$ /
|
||||
RedirectMatch 301 ^/@/(aryion|ekas?)\\b https://aryion.com/g4/user/BadManners
|
||||
RedirectMatch 301 ^/@/(bluesky|bsky)\\b https://bsky.app/profile/badmanners.xyz
|
||||
RedirectMatch 301 ^/@/(buymeacoffee|bmac)\\b https://www.buymeacoffee.com/BadMannersXYZ
|
||||
RedirectMatch 301 ^/@/carrd\\b https://badmanners.carrd.co
|
||||
RedirectMatch 301 ^/@/codeberg\\b https://codeberg.org/BadManners
|
||||
RedirectMatch 301 ^/@/cohost\\b https://cohost.org/BadManners
|
||||
RedirectMatch 301 ^/@/(fur[_-]?affinity|fa)\\b https://www.furaffinity.net/user/badmanners
|
||||
RedirectMatch 301 ^/@/gallery\\b https://gallery.badmanners.xyz
|
||||
RedirectMatch 301 ^/@/(github|gh)\\b https://github.com/BadMannersXYZ
|
||||
RedirectMatch 301 ^/@/gitlab\\b https://gitlab.com/Bad_Manners
|
||||
RedirectMatch 301 ^/@/gumroad\\b https://badmanners.gumroad.com/
|
||||
RedirectMatch 301 ^/@/(inkbunny|ib)\\b https://inkbunny.net/BadManners
|
||||
RedirectMatch 301 ^/@/itaku\\b https://itaku.ee/profile/badmanners
|
||||
RedirectMatch 301 ^/@/itch\\b https://bad-manners.itch.io
|
||||
RedirectMatch 301 ^/@/keybase\\b https://keybase.io/badmanners
|
||||
RedirectMatch 301 ^/@/ko[_-]?fi\\b https://ko-fi.com/badmanners
|
||||
RedirectMatch 301 ^/@/(mastodon|meow\\.social|gulp\\.cafe)\\b https://meow.social/@BadManners
|
||||
RedirectMatch 301 ^/@/neocities\\b https://badmanners.neocities.org/
|
||||
RedirectMatch 301 ^/@/picarto\\b https://www.picarto.tv/BadManners
|
||||
RedirectMatch 301 ^/@/pillowfort\\b https://www.pillowfort.social/BadManners
|
||||
RedirectMatch 301 ^/@/reddit\\b https://www.reddit.com/user/BadManners_/
|
||||
RedirectMatch 301 ^/@/signal\\b https://signal.me/#eu/ytt_rk0fFmAB2JAW-x2PbUiJyc_H3kYmfL_Pq4QNh5QIDsiFtjdFHaqFRs1D36tB
|
||||
RedirectMatch 301 ^/@/(sofurry|sf)\\b https://bad-manners.sofurry.com/
|
||||
RedirectMatch 301 ^/@/steam\\b https://steamcommunity.com/id/badmanners_/
|
||||
RedirectMatch 301 ^/@/subscribestar\\b https://subscribestar.adult/bad-manners
|
||||
RedirectMatch 301 ^/@/(telegram|t\\.me)\\b https://t.me/bad_manners
|
||||
RedirectMatch 301 ^/@/twitch\\b https://www.twitch.tv/bad__manners
|
||||
RedirectMatch 301 ^/@/weasyl\\b https://www.weasyl.com/~badmanners
|
||||
RedirectMatch 301 ^/@/(x|twitter)\\b https://x.com/BadManners__
|
||||
RedirectMatch 301 ^/@/(youtu\\.?be|yt)\\b https://www.youtube.com/@BadMannersXYZ
|
||||
`.trim();
|
||||
|
||||
export const getStaticPaths: GetStaticPaths = async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue