Fix up first version and add Prettier and Docker

This commit is contained in:
Bad Manners 2024-03-20 11:34:09 -03:00
parent 09a1919d36
commit 324050ee38
87 changed files with 2210 additions and 822 deletions

View file

@ -1,37 +1,56 @@
---
import { type Lang, type User } from '../content/config'
import UserComponent from './UserComponent.astro'
import { type Lang, type User } from "../content/config";
import UserComponent from "./UserComponent.astro";
type Props = {
authors: User | User[]
lang: Lang
}
authors: User | User[];
lang: Lang;
};
const { authors, lang } = Astro.props
const authorsArray = [authors].flat()
const { authors, lang } = Astro.props;
const authorsArray = [authors].flat();
---
{authorsArray.length > 0 && <p class="font-light">
{lang === 'eng' && (
(authorsArray.length > 2) ?
<span>
by {authorsArray.slice(0, authorsArray.length - 1).map(author => (<UserComponent user={author} /><span>, </span>))}and <UserComponent user={authorsArray[authorsArray.length - 1]} />
</span> :
(authorsArray.length > 1) ?
<span>
by <UserComponent user={authorsArray[0]} /> and <UserComponent user={authorsArray[1]} />
</span> :
<span>
by <UserComponent user={authorsArray[0]} />
</span>
)}
{lang === 'tok' && (
(authorsArray.length > 1) ?
<span>
lipu nu li tan ni: {authorsArray.slice(0, authorsArray.length - 1).map(author => <UserComponent user={author} /><span> en </span>)}<UserComponent user={authorsArray[authorsArray.length - 1]} />
</span> :
<span>
lipu nu li tan <UserComponent user={authorsArray[0]} />
</span>
)}
</p>}
{
authorsArray.length > 0 ? (
<p class="font-light">
{lang === "eng" &&
(authorsArray.length > 2 ? (
<span>
by{" "}
{authorsArray.slice(0, authorsArray.length - 1).map((author) => (
<Fragment>
<UserComponent user={author} />,
</Fragment>
))}
and <UserComponent user={authorsArray[authorsArray.length - 1]} />
</span>
) : authorsArray.length > 1 ? (
<span>
by <UserComponent user={authorsArray[0]} /> and <UserComponent user={authorsArray[1]} />
</span>
) : (
<span>
by <UserComponent user={authorsArray[0]} />
</span>
))}
{lang === "tok" &&
(authorsArray.length > 1 ? (
<span>
lipu ni li tan ni:{" "}
{authorsArray.slice(0, authorsArray.length - 1).map((author) => (
<Fragment>
<UserComponent user={author} />
{" en "}
</Fragment>
))}
<UserComponent user={authorsArray[authorsArray.length - 1]} />
</span>
) : (
<span>
lipu ni li tan <UserComponent user={authorsArray[0]} />
</span>
))}
</p>
) : null
}

View file

@ -1,25 +1,27 @@
---
import { type Lang, type User } from '../content/config'
import UserComponent from './UserComponent.astro'
import { type Lang, type User } from "../content/config";
import UserComponent from "./UserComponent.astro";
type Props = {
copyrightedCharacters?: Record<string, User>
lang: Lang
}
copyrightedCharacters?: Record<string, User>;
lang: Lang;
};
const { copyrightedCharacters, lang } = Astro.props
const { copyrightedCharacters, lang } = Astro.props;
---
{copyrightedCharacters &&
<section id="copyrighted-characters">
{lang === 'eng' && (
<ul>
{Object.entries(copyrightedCharacters).map(([character, user]) =>
<li>
{character} is &copy; <UserComponent user={user} />
</li>
)}
</ul>
)}
</section>
{
copyrightedCharacters ? (
<section id="copyrighted-characters">
{lang === "eng" && (
<ul>
{Object.entries(copyrightedCharacters).map(([character, user]) => (
<li>
{character} is &copy; <UserComponent user={user} />
</li>
))}
</ul>
)}
</section>
) : null
}

View file

@ -1,11 +1,32 @@
---
---
<nav>
<ul>
<li><a class="hover:underline focus:underline hover:text-green-800 focus:text-green-800 dark:hover:text-bm-300 dark:focus:text-bm-300" href="/">Home</a></li>
<li><a class="hover:underline focus:underline hover:text-green-800 focus:text-green-800 dark:hover:text-bm-300 dark:focus:text-bm-300" href="/stories">Stories</a></li>
<li><a class="hover:underline focus:underline hover:text-green-800 focus:text-green-800 dark:hover:text-bm-300 dark:focus:text-bm-300" href="/games">Games</a></li>
<li><a class="hover:underline focus:underline hover:text-green-800 focus:text-green-800 dark:hover:text-bm-300 dark:focus:text-bm-300" href="/tags">Tags</a></li>
<li>
<a
class="hover:text-green-800 hover:underline focus:text-green-800 focus:underline dark:hover:text-bm-300 dark:focus:text-bm-300"
href="/">Home</a
>
</li>
<li>
<a
class="hover:text-green-800 hover:underline focus:text-green-800 focus:underline dark:hover:text-bm-300 dark:focus:text-bm-300"
href="/stories">Stories</a
>
</li>
<li>
<a
class="hover:text-green-800 hover:underline focus:text-green-800 focus:underline dark:hover:text-bm-300 dark:focus:text-bm-300"
href="/games">Games</a
>
</li>
<li>
<a
class="hover:text-green-800 hover:underline focus:text-green-800 focus:underline dark:hover:text-bm-300 dark:focus:text-bm-300"
href="/tags">Tags</a
>
</li>
</ul>
</nav>

View file

@ -1,5 +1,7 @@
---
---
<div class="prose prose-story max-w-none dark:prose-invert">
<div class="prose-a:text-link prose prose-story max-w-none dark:prose-invert">
<slot />
</div>
</div>

View file

@ -0,0 +1,56 @@
---
---
<script is:inline>
/* Color scheme toggle */
(() => {
var colorScheme = localStorage.getItem("colorScheme");
if (colorScheme == null) {
localStorage.setItem("colorScheme", "auto");
} else if (colorScheme == "auto") {
colorScheme = matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
}
const bodyClassList = document.querySelector("body").classList;
if (colorScheme === "dark") {
bodyClassList.add("dark");
}
function toggleColorScheme() {
if (colorScheme === "dark") {
colorScheme = "light";
bodyClassList.remove("dark");
} else {
colorScheme = "dark";
bodyClassList.add("dark");
}
localStorage.setItem("colorScheme", colorScheme);
}
const buttonDarkMode = document.querySelector("#button-dark-mode");
if (buttonDarkMode) {
buttonDarkMode.addEventListener("click", toggleColorScheme);
}
})();
/* Age verification */
(() => {
if (window.location.pathname === "/age-verification") {
document.querySelector("#age-verification-reject").addEventListener("click", () => {
window.location.href = "about:blank";
});
document.querySelector("#age-verification-accept").addEventListener("click", () => {
localStorage.setItem("ageVerified", "true");
const params = new URLSearchParams(window.location.search);
window.location.href = decodeURIComponent(params.get("redirect") || "/");
});
} else {
const ageVerified = localStorage.getItem("ageVerified");
if (ageVerified !== "true") {
localStorage.setItem("ageVerified", "false");
window.location.href = `/age-verification?redirect=${encodeURIComponent(window.location.href)}`;
}
}
})();
</script>

View file

@ -1,11 +1,21 @@
---
import { type User } from '../content/config'
import { type User } from "../content/config";
type Props = {
user: User
}
user: User;
};
const { user } = Astro.props
const { user } = Astro.props;
---
{typeof user === 'string' ? <span>{user}</span> : Object.entries(user).map(([k, v]) => <a href={v} class="text-link underline" target="_blank"><span>{k}</span></a>)[0]}
{
typeof user === "string" ? (
<span>{user}</span>
) : (
Object.entries(user).map(([k, v]) => (
<a href={v} class="text-link underline" target="_blank">
<span>{k}</span>
</a>
))[0]
)
}