Move ToS to content collection
This commit is contained in:
parent
a97ea99c75
commit
776d1a0bca
11 changed files with 47 additions and 38 deletions
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
|
@ -2,6 +2,9 @@
|
||||||
"files.associations": {
|
"files.associations": {
|
||||||
"*.css": "tailwindcss"
|
"*.css": "tailwindcss"
|
||||||
},
|
},
|
||||||
|
"yaml.schemas": {
|
||||||
|
"./.astro/collections/tos.schema.json": "/src/data/tos/**"
|
||||||
|
},
|
||||||
"[astro]": {
|
"[astro]": {
|
||||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
15
package-lock.json
generated
15
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "badmanners.xyz",
|
"name": "badmanners.xyz",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "badmanners.xyz",
|
"name": "badmanners.xyz",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@astrojs/alpinejs": "^0.4.0",
|
"@astrojs/alpinejs": "^0.4.0",
|
||||||
|
|
@ -16,12 +16,13 @@
|
||||||
"@types/alpinejs": "^3.13.10",
|
"@types/alpinejs": "^3.13.10",
|
||||||
"alpinejs": "^3.14.1",
|
"alpinejs": "^3.14.1",
|
||||||
"astro": "^5.0.1",
|
"astro": "^5.0.1",
|
||||||
"astro-htaccess": "^0.2.2",
|
"astro-htaccess": "^0.2.3",
|
||||||
"date-fns": "^3.6.0",
|
"date-fns": "^3.6.0",
|
||||||
"tailwindcss": "^3.4.11",
|
"tailwindcss": "^3.4.11",
|
||||||
"tippy.js": "^6.3.7",
|
"tippy.js": "^6.3.7",
|
||||||
"toml": "^3.0.0",
|
"toml": "^3.0.0",
|
||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2",
|
||||||
|
"yaml": "^2.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^22.10.1",
|
"@types/node": "^22.10.1",
|
||||||
|
|
@ -2005,9 +2006,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/astro-htaccess": {
|
"node_modules/astro-htaccess": {
|
||||||
"version": "0.2.2",
|
"version": "0.2.3",
|
||||||
"resolved": "https://registry.npmjs.org/astro-htaccess/-/astro-htaccess-0.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/astro-htaccess/-/astro-htaccess-0.2.3.tgz",
|
||||||
"integrity": "sha512-xBtEQIhK5NzQ72YKfpPkzfTYvXz4SNDi1+SmHXObvfsEN5MS/FeWQCcnIYb+f0KrGAr5DVtV0VOTu3sLQZsM5Q==",
|
"integrity": "sha512-9Rraech/5sZi+3V7SsPdhNzoVdh4iLN/nQ0RACylqPs1+s6k025MKnYHuO7AUjXD0gD9iZcpDX/N3r54N15Zeg==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"astro": ">= 4.0.0 < 6"
|
"astro": ">= 4.0.0 < 6"
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "badmanners.xyz",
|
"name": "badmanners.xyz",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "2.3.0",
|
"version": "2.3.1",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "astro sync",
|
"postinstall": "astro sync",
|
||||||
"dev": "astro dev",
|
"dev": "astro dev",
|
||||||
|
|
@ -21,12 +21,13 @@
|
||||||
"@types/alpinejs": "^3.13.10",
|
"@types/alpinejs": "^3.13.10",
|
||||||
"alpinejs": "^3.14.1",
|
"alpinejs": "^3.14.1",
|
||||||
"astro": "^5.0.1",
|
"astro": "^5.0.1",
|
||||||
"astro-htaccess": "^0.2.2",
|
"astro-htaccess": "^0.2.3",
|
||||||
"date-fns": "^3.6.0",
|
"date-fns": "^3.6.0",
|
||||||
"tailwindcss": "^3.4.11",
|
"tailwindcss": "^3.4.11",
|
||||||
"tippy.js": "^6.3.7",
|
"tippy.js": "^6.3.7",
|
||||||
"toml": "^3.0.0",
|
"toml": "^3.0.0",
|
||||||
"typescript": "^5.6.2"
|
"typescript": "^5.6.2",
|
||||||
|
"yaml": "^2.6.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^22.10.1",
|
"@types/node": "^22.10.1",
|
||||||
|
|
|
||||||
12
src/content.config.ts
Normal file
12
src/content.config.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { defineCollection, z } from "astro:content";
|
||||||
|
import { glob } from "astro/loaders";
|
||||||
|
|
||||||
|
const tos = defineCollection({
|
||||||
|
loader: glob({ pattern: "*.{yml,yaml}", base: "./src/data/tos" }),
|
||||||
|
schema: z.object({
|
||||||
|
status: z.enum(["CLOSED", "OPEN", "SEMI_OPEN", "PRIVATE"]),
|
||||||
|
updatedAt: z.date(),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|
||||||
|
export const collections = { tos };
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
import { parse } from "date-fns";
|
|
||||||
|
|
||||||
type CommissionStatus = "CLOSED" | "OPEN" | "SEMI_OPEN" | "PRIVATE";
|
|
||||||
|
|
||||||
interface TosFeedItem {
|
|
||||||
status: CommissionStatus;
|
|
||||||
updatedAt: Date;
|
|
||||||
}
|
|
||||||
|
|
||||||
const d = (date: string) => parse(date, "yyyy-MM-dd", 0);
|
|
||||||
|
|
||||||
export const TOS_FEED: TosFeedItem[] = (
|
|
||||||
[
|
|
||||||
{ status: "CLOSED", updatedAt: d("2024-08-25") },
|
|
||||||
{ status: "OPEN", updatedAt: d("2024-07-11") },
|
|
||||||
] satisfies TosFeedItem[]
|
|
||||||
)
|
|
||||||
.sort((a, b) => b.updatedAt.getTime() - a.updatedAt.getTime())
|
|
||||||
.slice(0, 5);
|
|
||||||
|
|
||||||
export const { status: TOS_COMMISSION_STATUS, updatedAt: TOS_UPDATED_AT } = TOS_FEED[0];
|
|
||||||
2
src/data/tos/2024-07-11.yaml
Normal file
2
src/data/tos/2024-07-11.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
updatedAt: 2024-07-11
|
||||||
|
status: OPEN
|
||||||
2
src/data/tos/2024-08-25.yaml
Normal file
2
src/data/tos/2024-08-25.yaml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
updatedAt: 2024-08-25
|
||||||
|
status: CLOSED
|
||||||
5
src/data/tos_status.ts
Normal file
5
src/data/tos_status.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { getCollection } from "astro:content";
|
||||||
|
|
||||||
|
export const { status: TOS_COMMISSION_STATUS, updatedAt: TOS_UPDATED_AT } = (await getCollection("tos")).sort(
|
||||||
|
(a, b) => b.data.updatedAt.getTime() - a.data.updatedAt.getTime(),
|
||||||
|
)[0].data;
|
||||||
|
|
@ -1,7 +1,11 @@
|
||||||
import rss from "@astrojs/rss";
|
import rss from "@astrojs/rss";
|
||||||
import type { APIRoute } from "astro";
|
import type { APIRoute } from "astro";
|
||||||
import { set as dateSet, subMinutes } from "date-fns";
|
import { getCollection } from "astro:content";
|
||||||
import { TOS_FEED } from "@data/tos";
|
import { addHours } from "date-fns";
|
||||||
|
|
||||||
|
const TOS_FEED = (await getCollection("tos"))
|
||||||
|
.sort((a, b) => b.data.updatedAt.getTime() - a.data.updatedAt.getTime())
|
||||||
|
.slice(0, 5);
|
||||||
|
|
||||||
export const GET: APIRoute = ({ site }) => {
|
export const GET: APIRoute = ({ site }) => {
|
||||||
if (!site) {
|
if (!site) {
|
||||||
|
|
@ -13,7 +17,7 @@ export const GET: APIRoute = ({ site }) => {
|
||||||
site,
|
site,
|
||||||
xmlns: { atom: "http://www.w3.org/2005/Atom" },
|
xmlns: { atom: "http://www.w3.org/2005/Atom" },
|
||||||
customData: `<link href="${site}" rel="alternate" type="text/html" /><atom:link href="${new URL("feed.xml", site)}" rel="self" type="application/rss+xml" />`,
|
customData: `<link href="${site}" rel="alternate" type="text/html" /><atom:link href="${new URL("feed.xml", site)}" rel="self" type="application/rss+xml" />`,
|
||||||
items: TOS_FEED.map(({ status, updatedAt }) => ({
|
items: TOS_FEED.map(({ data: { status, updatedAt } }) => ({
|
||||||
title: {
|
title: {
|
||||||
CLOSED: "Story commissions are closed.",
|
CLOSED: "Story commissions are closed.",
|
||||||
OPEN: "Story commissions are open!",
|
OPEN: "Story commissions are open!",
|
||||||
|
|
@ -21,7 +25,7 @@ export const GET: APIRoute = ({ site }) => {
|
||||||
PRIVATE: "Story commissions are private; they are only open to select commissioners.",
|
PRIVATE: "Story commissions are private; they are only open to select commissioners.",
|
||||||
}[status],
|
}[status],
|
||||||
link: new URL("terms_of_service", site).toString(),
|
link: new URL("terms_of_service", site).toString(),
|
||||||
pubDate: subMinutes(dateSet(updatedAt, { hours: 12, minutes: 0, seconds: 0 }), updatedAt.getTimezoneOffset()),
|
pubDate: addHours(updatedAt, 12),
|
||||||
})),
|
})),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
import BaseLayout from "@layouts/BaseLayout.astro";
|
import BaseLayout from "@layouts/BaseLayout.astro";
|
||||||
import { IconSquareRSS } from "@components/icons";
|
import { IconSquareRSS } from "@components/icons";
|
||||||
|
|
||||||
import { TOS_COMMISSION_STATUS, TOS_UPDATED_AT } from "@data/tos";
|
import { TOS_COMMISSION_STATUS, TOS_UPDATED_AT } from "@data/tos_status";
|
||||||
---
|
---
|
||||||
|
|
||||||
<BaseLayout pageTitle="Terms of Service">
|
<BaseLayout pageTitle="Terms of Service">
|
||||||
|
|
@ -20,7 +20,7 @@ import { TOS_COMMISSION_STATUS, TOS_UPDATED_AT } from "@data/tos";
|
||||||
<div class="my-2 flex items-center justify-end">
|
<div class="my-2 flex items-center justify-end">
|
||||||
<p class="mr-1 text-sm font-medium italic">
|
<p class="mr-1 text-sm font-medium italic">
|
||||||
Last update: <time datetime={TOS_UPDATED_AT.toISOString().slice(0, 10)}
|
Last update: <time datetime={TOS_UPDATED_AT.toISOString().slice(0, 10)}
|
||||||
>{TOS_UPDATED_AT.toLocaleDateString("en-US", { dateStyle: "long" })}</time
|
>{TOS_UPDATED_AT.toLocaleDateString("en-US", { dateStyle: "long", timeZone: "GMT" })}</time
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
<a
|
<a
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ import {
|
||||||
IconWeasyl,
|
IconWeasyl,
|
||||||
} from "@components/icons/brands";
|
} from "@components/icons/brands";
|
||||||
|
|
||||||
import { TOS_COMMISSION_STATUS } from "@data/tos";
|
import { TOS_COMMISSION_STATUS } from "@data/tos_status";
|
||||||
import { SUBSCRIBESTAR_ENABLED } from "@data/subscribestar";
|
import { SUBSCRIBESTAR_ENABLED } from "@data/subscribestar";
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue