From 4aeb6ebe6b69d50dd6dc430e09855a5f5132b823 Mon Sep 17 00:00:00 2001 From: Lio Date: Sun, 30 Jun 2024 21:16:36 +0200 Subject: [PATCH] everything --- src/components/Card.astro | 83 +++++---------- src/components/Image.astro | 58 +++++++++-- src/components/IndexSidebar.astro | 78 ++++++++++++++ src/components/Lightbox.astro | 110 ++++++++++++++++++++ src/components/Sidebar.astro | 61 +++++++++-- src/components/SocialCard.astro | 18 ++++ src/layouts/CharacterList.astro | 39 +++++++ src/layouts/{Layout.astro => Gallery.astro} | 24 +++-- src/layouts/Index.astro | 32 ++++++ src/lib/stores/nsfw.ts | 3 + src/pages/characters/[slug].astro | 71 +++++++++++++ src/pages/characters/index.astro | 29 ++++++ src/pages/index.astro | 44 ++------ 13 files changed, 525 insertions(+), 125 deletions(-) create mode 100644 src/components/IndexSidebar.astro create mode 100644 src/components/Lightbox.astro create mode 100644 src/components/SocialCard.astro create mode 100644 src/layouts/CharacterList.astro rename src/layouts/{Layout.astro => Gallery.astro} (73%) create mode 100644 src/layouts/Index.astro create mode 100644 src/lib/stores/nsfw.ts create mode 100644 src/pages/characters/[slug].astro create mode 100644 src/pages/characters/index.astro diff --git a/src/components/Card.astro b/src/components/Card.astro index bd6d597..ad4929f 100644 --- a/src/components/Card.astro +++ b/src/components/Card.astro @@ -1,61 +1,30 @@ --- -interface Props { - title: string; - body: string; - href: string; +import pb from "../lib/pb"; + +const { href, title, body, image } = Astro.props; +let imageURL; + +if (image) { + imageURL = pb.files.getUrl(image, image.file); } - -const { href, title, body } = Astro.props; --- - - +
+ + { + image && ( + {`Cover + ) + } + +
+
+

{title}

+ {body} +
+
+
diff --git a/src/components/Image.astro b/src/components/Image.astro index 30f3f29..a36a4ef 100644 --- a/src/components/Image.astro +++ b/src/components/Image.astro @@ -1,14 +1,50 @@ --- -import { Image as AstroImage } from "astro:assets"; -const { src, alt } = Astro.props; +import { Picture as AstroPic } from "astro:assets"; +const { src, alt, nsfw } = Astro.props; --- - +
+
+ {alt} + { + alt && ( +
+ {alt} +
+ ) + } +
+
+ + + + diff --git a/src/components/IndexSidebar.astro b/src/components/IndexSidebar.astro new file mode 100644 index 0000000..dbcbd8c --- /dev/null +++ b/src/components/IndexSidebar.astro @@ -0,0 +1,78 @@ +--- +import { Image } from "astro:assets"; +import config from "../../config.yaml"; +import SocialCard from "./SocialCard.astro"; +const {} = Astro.props; +--- + + diff --git a/src/components/Lightbox.astro b/src/components/Lightbox.astro new file mode 100644 index 0000000..c4cecd4 --- /dev/null +++ b/src/components/Lightbox.astro @@ -0,0 +1,110 @@ +
+ +
+
+ + + + diff --git a/src/components/Sidebar.astro b/src/components/Sidebar.astro index 1659a20..fdf4cd1 100644 --- a/src/components/Sidebar.astro +++ b/src/components/Sidebar.astro @@ -1,24 +1,63 @@ --- import { Image } from "astro:assets"; -import config from "../../config.json"; - -const {class} = Astro.props +import config from "../../config.yaml"; +const {} = Astro.props; --- + + diff --git a/src/layouts/Layout.astro b/src/layouts/Gallery.astro similarity index 73% rename from src/layouts/Layout.astro rename to src/layouts/Gallery.astro index 0904e97..f740aaf 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Gallery.astro @@ -1,5 +1,6 @@ --- -import config from "../../config.json"; +import config from "../../config.yaml"; +import Lightbox from "../components/Lightbox.astro"; import Sidebar from "../components/Sidebar.astro"; const { title, background } = config; @@ -16,22 +17,27 @@ const { title, background } = config; {title} +
+ +
+
-
- -
+ diff --git a/src/lib/stores/nsfw.ts b/src/lib/stores/nsfw.ts new file mode 100644 index 0000000..c76e078 --- /dev/null +++ b/src/lib/stores/nsfw.ts @@ -0,0 +1,3 @@ +import { atom } from "nanostores"; + +export const nsfw = atom(false); diff --git a/src/pages/characters/[slug].astro b/src/pages/characters/[slug].astro new file mode 100644 index 0000000..34c0ad0 --- /dev/null +++ b/src/pages/characters/[slug].astro @@ -0,0 +1,71 @@ +--- +import type { GetStaticPaths } from "astro"; +import Gallery from "../../layouts/Gallery.astro"; +import Image from "../../components/Image.astro"; +import pb from "../../lib/pb"; +export const getStaticPaths = (async () => { + const paths = await pb + .collection("characters") + .getFullList({ + sort: "-created", + }) + .then((r) => r); + + // console.log(paths); + + return paths.map(({ slug, name }) => { + return { + params: { slug }, + }; + }); +}) satisfies GetStaticPaths; + +const { slug } = Astro.params; + +const imageCollection = await pb.collection("images").getFullList({ + sort: "-created", + filter: `(character.slug~"${slug}")`, +}); +const characterDetails = await pb + .collection("characters") + .getFirstListItem(`(slug~"${slug}")`); +// console.log(characterDetails); +const images = imageCollection.map((record) => { + const url = pb.files.getUrl(record, record.file); + return { + url: url, + desc: record.description, + nsfw: record.nsfw, + }; +}); +--- + + +
+
+

+ + {characterDetails.name} + +

+ { + characterDetails.description && ( + + ) + } +
+
+ { + images.map((image) => ( + {image.desc} + )) + } +
+
+
+ + diff --git a/src/pages/characters/index.astro b/src/pages/characters/index.astro new file mode 100644 index 0000000..93a4f82 --- /dev/null +++ b/src/pages/characters/index.astro @@ -0,0 +1,29 @@ +--- +import CharacterList from "../../layouts/CharacterList.astro"; +import pb from "../../lib/pb"; +import Card from "../../components/Card.astro"; + +const characters = await pb + .collection("characters") + // @ts-ignore + .getFullList({ expand: ["icon"] }); +--- + + +
+

Characters

+
+ { + characters.map((c) => ( + // @ts-ignore + + )) + } +
+
+
diff --git a/src/pages/index.astro b/src/pages/index.astro index f3d6ff7..ed3b3fb 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,42 +1,12 @@ --- -import Layout from "../layouts/Layout.astro"; -import Image from "../components/Image.astro"; - -const images = [ - "https://randomfox.ca/images/1.jpg", - "https://randomfox.ca/images/2.jpg", - "https://randomfox.ca/images/3.jpg", - "https://randomfox.ca/images/4.jpg", - "https://randomfox.ca/images/5.jpg", - "https://randomfox.ca/images/6.jpg", - "https://randomfox.ca/images/7.jpg", - "https://randomfox.ca/images/8.jpg", - "https://randomfox.ca/images/9.jpg", - "https://randomfox.ca/images/10.jpg", - "https://randomfox.ca/images/11.jpg", - "https://randomfox.ca/images/12.jpg", - "https://randomfox.ca/images/13.jpg", - "https://randomfox.ca/images/14.jpg", - "https://randomfox.ca/images/15.jpg", - "https://randomfox.ca/images/16.jpg", - "https://randomfox.ca/images/17.jpg", - "https://randomfox.ca/images/18.jpg", - "https://randomfox.ca/images/19.jpg", - "https://randomfox.ca/images/20.jpg", -]; +import Sidebar from "../components/IndexSidebar.astro"; +import IndexLayout from "../layouts/Index.astro"; --- - -
- ... album title and description ... - -
- {images.map((image) => )} + +
+
+
- - ... rest of the page ...
- - - +