From bb10ff9cace0e97e8970537fd4cc61ca839d82e6 Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Tue, 23 Jan 2024 00:16:04 +0800 Subject: [PATCH] :lipstick: Optimized navbar --- .idea/codeStyles/Project.xml | 57 +++++++ .idea/codeStyles/codeStyleConfig.xml | 5 + .prettierrc | 5 + content/.keystone/config.js | 199 ++++++++++++------------ content/keystone.ts | 8 +- content/limit.ts | 3 +- content/schema.graphql | 224 +++++++++++++++++++++++---- content/schema/events.ts | 7 +- content/schema/index.ts | 8 +- content/schema/moments.ts | 112 +++++++------- content/schema/posts.ts | 8 +- content/tsconfig.json | 2 +- src/assets/fonts/fonts.css | 21 +-- src/components/Navbar.astro | 43 ++--- src/components/posts/Media.tsx | 15 +- src/pages/projects/index.astro | 24 --- src/scripts/requests.ts | 19 +-- 17 files changed, 468 insertions(+), 292 deletions(-) create mode 100644 .idea/codeStyles/Project.xml create mode 100644 .idea/codeStyles/codeStyleConfig.xml create mode 100644 .prettierrc delete mode 100644 src/pages/projects/index.astro diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..60dc64b --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..de3bd60 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,5 @@ +{ + "tabWidth": 2, + "printWidth": 120, + "singleQuote": false +} diff --git a/content/.keystone/config.js b/content/.keystone/config.js index dfcc597..0feccc7 100644 --- a/content/.keystone/config.js +++ b/content/.keystone/config.js @@ -4,14 +4,16 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { - for (var name in all) - __defProp(target, name, { get: all[name], enumerable: true }); + for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { - if (from && typeof from === "object" || typeof from === "function") { + if ((from && typeof from === "object") || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) - __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + __defProp(to, key, { + get: () => from[key], + enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable, + }); } return to; }; @@ -20,7 +22,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru // keystone.ts var keystone_exports = {}; __export(keystone_exports, { - default: () => keystone_default + default: () => keystone_default, }); module.exports = __toCommonJS(keystone_exports); var import_core8 = require("@keystone-6/core"); @@ -35,24 +37,24 @@ var allowUser = { operation: { create: isUser, update: isUser, - delete: isUser - } + delete: isUser, + }, }; var isEditor = ({ session: session2 }) => session2?.data.isEditor || session2?.data.isAdmin; var allowEditor = { operation: { create: isEditor, update: isEditor, - delete: isEditor - } + delete: isEditor, + }, }; var isAdmin = ({ session: session2 }) => session2?.data.isAdmin; var allowAdmin = { operation: { create: isAdmin, update: isAdmin, - delete: isAdmin - } + delete: isAdmin, + }, }; // schema/assets.ts @@ -64,9 +66,9 @@ var Image = (0, import_core.list)({ caption: (0, import_fields.text)(), image: (0, import_fields.image)({ storage: "localImages" }), createdAt: (0, import_fields.timestamp)({ - defaultValue: { kind: "now" } - }) - } + defaultValue: { kind: "now" }, + }), + }, }); var Asset = (0, import_core.list)({ access: allowEditor, @@ -77,17 +79,17 @@ var Asset = (0, import_core.list)({ type: "enum", options: [ { label: "Video", value: "video" }, - { label: "Audio", value: "audio" } + { label: "Audio", value: "audio" }, ], defaultValue: "video", db: { map: "media_type" }, validation: { isRequired: true }, - ui: { displayMode: "select" } + ui: { displayMode: "select" }, }), createdAt: (0, import_fields.timestamp)({ - defaultValue: { kind: "now" } - }) - } + defaultValue: { kind: "now" }, + }), + }, }); // schema/moments.ts @@ -106,10 +108,10 @@ var Moment = (0, import_core2.list)({ [1, 1, 1], [2, 1], [1, 2], - [1, 2, 1] + [1, 2, 1], ], links: true, - dividers: true + dividers: true, }), author: (0, import_fields2.relationship)({ ref: "User.moments", @@ -118,9 +120,9 @@ var Moment = (0, import_core2.list)({ cardFields: ["name", "email"], inlineEdit: { fields: ["name", "email"] }, linkToItem: true, - inlineConnect: true + inlineConnect: true, }, - many: false + many: false, }), categories: (0, import_fields2.relationship)({ ref: "Category.moments", @@ -131,8 +133,8 @@ var Moment = (0, import_core2.list)({ inlineEdit: { fields: ["name"] }, linkToItem: true, inlineConnect: true, - inlineCreate: { fields: ["name"] } - } + inlineCreate: { fields: ["name"] }, + }, }), tags: (0, import_fields2.relationship)({ ref: "Tag.moments", @@ -143,13 +145,13 @@ var Moment = (0, import_core2.list)({ inlineEdit: { fields: ["name"] }, linkToItem: true, inlineConnect: true, - inlineCreate: { fields: ["name"] } - } + inlineCreate: { fields: ["name"] }, + }, }), createdAt: (0, import_fields2.timestamp)({ - defaultValue: { kind: "now" } - }) - } + defaultValue: { kind: "now" }, + }), + }, }); // schema/categories.ts @@ -160,30 +162,30 @@ var Category = (0, import_core3.list)({ fields: { slug: (0, import_fields3.text)({ validation: { - isRequired: true + isRequired: true, }, - isIndexed: "unique" + isIndexed: "unique", }), name: (0, import_fields3.text)(), posts: (0, import_fields3.relationship)({ ref: "Post.categories", many: true }), moments: (0, import_fields3.relationship)({ ref: "Moment.categories", many: true }), - events: (0, import_fields3.relationship)({ ref: "Event.categories", many: true }) - } + events: (0, import_fields3.relationship)({ ref: "Event.categories", many: true }), + }, }); var Tag = (0, import_core3.list)({ access: allowEditor, fields: { slug: (0, import_fields3.text)({ validation: { - isRequired: true + isRequired: true, }, - isIndexed: "unique" + isIndexed: "unique", }), name: (0, import_fields3.text)(), posts: (0, import_fields3.relationship)({ ref: "Post.tags", many: true }), moments: (0, import_fields3.relationship)({ ref: "Moment.tags", many: true }), - events: (0, import_fields3.relationship)({ ref: "Event.tags", many: true }) - } + events: (0, import_fields3.relationship)({ ref: "Event.tags", many: true }), + }, }); // schema/projects.ts @@ -194,11 +196,10 @@ var Project = (0, import_core4.list)({ ...allowAdmin, filter: { query: ({ session: session2 }) => { - if (session2?.data.isEditor || session2?.data.isAdmin) - return true; + if (session2?.data.isEditor || session2?.data.isAdmin) return true; return { isPublished: { equals: true } }; - } - } + }, + }, }, fields: { icon: (0, import_fields4.relationship)({ ref: "Image" }), @@ -212,18 +213,18 @@ var Project = (0, import_core4.list)({ { label: "Pending", value: "pending" }, { label: "Constructing", value: "constructing" }, { label: "Published", value: "published" }, - { label: "Abandoned", value: "abandoned" } + { label: "Abandoned", value: "abandoned" }, ], defaultValue: "pending", db: { map: "project_status" }, validation: { isRequired: true }, - ui: { displayMode: "select" } + ui: { displayMode: "select" }, }), post: (0, import_fields4.relationship)({ ref: "Post" }), createdAt: (0, import_fields4.timestamp)({ - defaultValue: { kind: "now" } - }) - } + defaultValue: { kind: "now" }, + }), + }, }); // schema/posts.ts @@ -235,18 +236,17 @@ var Post = (0, import_core5.list)({ ...allowEditor, filter: { query: ({ session: session2 }) => { - if (session2?.data.isEditor || session2?.data.isAdmin) - return true; + if (session2?.data.isEditor || session2?.data.isAdmin) return true; return { isPublished: { equals: true } }; - } - } + }, + }, }, fields: { slug: (0, import_fields5.text)({ validation: { - isRequired: true + isRequired: true, }, - isIndexed: "unique" + isIndexed: "unique", }), title: (0, import_fields5.text)({ validation: { isRequired: true } }), cover: (0, import_fields5.relationship)({ ref: "Image" }), @@ -260,21 +260,21 @@ var Post = (0, import_core5.list)({ [1, 1, 1], [2, 1], [1, 2], - [1, 2, 1] + [1, 2, 1], ], links: true, - dividers: true + dividers: true, }), type: (0, import_fields5.select)({ type: "enum", options: [ { label: "Article", value: "article" }, - { label: "Podcast", value: "podcast" } + { label: "Podcast", value: "podcast" }, ], defaultValue: "article", db: { map: "post_type" }, validation: { isRequired: true }, - ui: { displayMode: "select" } + ui: { displayMode: "select" }, }), isPublished: (0, import_fields5.checkbox)(), author: (0, import_fields5.relationship)({ @@ -284,9 +284,9 @@ var Post = (0, import_core5.list)({ cardFields: ["name", "email"], inlineEdit: { fields: ["name", "email"] }, linkToItem: true, - inlineConnect: true + inlineConnect: true, }, - many: false + many: false, }), categories: (0, import_fields5.relationship)({ ref: "Category.posts", @@ -297,8 +297,8 @@ var Post = (0, import_core5.list)({ inlineEdit: { fields: ["name"] }, linkToItem: true, inlineConnect: true, - inlineCreate: { fields: ["name"] } - } + inlineCreate: { fields: ["name"] }, + }, }), tags: (0, import_fields5.relationship)({ ref: "Tag.posts", @@ -309,13 +309,13 @@ var Post = (0, import_core5.list)({ inlineEdit: { fields: ["name"] }, linkToItem: true, inlineConnect: true, - inlineCreate: { fields: ["name"] } - } + inlineCreate: { fields: ["name"] }, + }, }), createdAt: (0, import_fields5.timestamp)({ - defaultValue: { kind: "now" } - }) - } + defaultValue: { kind: "now" }, + }), + }, }); // schema/events.ts @@ -327,18 +327,17 @@ var Event = (0, import_core6.list)({ ...allowEditor, filter: { query: ({ session: session2 }) => { - if (session2?.data.isEditor || session2?.data.isAdmin) - return true; + if (session2?.data.isEditor || session2?.data.isAdmin) return true; return { isPublished: { equals: true } }; - } - } + }, + }, }, fields: { slug: (0, import_fields6.text)({ validation: { - isRequired: true + isRequired: true, }, - isIndexed: "unique" + isIndexed: "unique", }), title: (0, import_fields6.text)({ validation: { isRequired: true } }), description: (0, import_fields6.text)(), @@ -349,10 +348,10 @@ var Event = (0, import_core6.list)({ [1, 1, 1], [2, 1], [1, 2], - [1, 2, 1] + [1, 2, 1], ], links: true, - dividers: true + dividers: true, }), isPublished: (0, import_fields6.checkbox)(), isHistory: (0, import_fields6.checkbox)(), @@ -363,9 +362,9 @@ var Event = (0, import_core6.list)({ cardFields: ["name", "email"], inlineEdit: { fields: ["name", "email"] }, linkToItem: true, - inlineConnect: true + inlineConnect: true, }, - many: false + many: false, }), categories: (0, import_fields6.relationship)({ ref: "Category.events", @@ -376,8 +375,8 @@ var Event = (0, import_core6.list)({ inlineEdit: { fields: ["name"] }, linkToItem: true, inlineConnect: true, - inlineCreate: { fields: ["name"] } - } + inlineCreate: { fields: ["name"] }, + }, }), tags: (0, import_fields6.relationship)({ ref: "Tag.events", @@ -388,13 +387,13 @@ var Event = (0, import_core6.list)({ inlineEdit: { fields: ["name"] }, linkToItem: true, inlineConnect: true, - inlineCreate: { fields: ["name"] } - } + inlineCreate: { fields: ["name"] }, + }, }), createdAt: (0, import_fields6.timestamp)({ - defaultValue: { kind: "now" } - }) - } + defaultValue: { kind: "now" }, + }), + }, }); // schema/index.ts @@ -405,7 +404,7 @@ var lists = { name: (0, import_fields7.text)({ validation: { isRequired: true } }), email: (0, import_fields7.text)({ validation: { isRequired: true }, - isIndexed: "unique" + isIndexed: "unique", }), password: (0, import_fields7.password)({ validation: { isRequired: true } }), posts: (0, import_fields7.relationship)({ ref: "Post.author", many: true }), @@ -414,9 +413,9 @@ var lists = { isAdmin: (0, import_fields7.checkbox)(), isEditor: (0, import_fields7.checkbox)(), createdAt: (0, import_fields7.timestamp)({ - defaultValue: { kind: "now" } - }) - } + defaultValue: { kind: "now" }, + }), + }, }), Image, Asset, @@ -425,7 +424,7 @@ var lists = { Project, Event, Category, - Tag + Tag, }; // auth.ts @@ -442,13 +441,13 @@ var { withAuth } = (0, import_auth.createAuth)({ sessionData: "id name createdAt isAdmin isEditor", secretField: "password", initFirstItem: { - fields: ["name", "email", "password", "isAdmin"] - } + fields: ["name", "email", "password", "isAdmin"], + }, }); var sessionMaxAge = 60 * 60 * 24 * 30; var session = (0, import_session.statelessSessions)({ maxAge: sessionMaxAge, - secret: sessionSecret + secret: sessionSecret, }); // keystone.ts @@ -458,17 +457,17 @@ var databaseProvider = process.env.DATABASE_PROVIDER ?? "postgresql"; var keystone_default = withAuth( (0, import_core8.config)({ ui: { - basePath: "/cms" + basePath: "/cms", }, db: { provider: databaseProvider, - url: databaseUrl + url: databaseUrl, }, server: { cors: { origin: "*", - methods: "GET,HEAD,PUT,PATCH,POST,DELETE" - } + methods: "GET,HEAD,PUT,PATCH,POST,DELETE", + }, }, storage: { localImages: { @@ -476,13 +475,13 @@ var keystone_default = withAuth( type: "image", generateUrl: (path) => `${baseUrl}/images${path}`, serverRoute: { - path: "/images" + path: "/images", }, - storagePath: "public/images" - } + storagePath: "public/images", + }, }, lists, - session - }) + session, + }), ); //# sourceMappingURL=config.js.map diff --git a/content/keystone.ts b/content/keystone.ts index 0b788a1..32ded61 100644 --- a/content/keystone.ts +++ b/content/keystone.ts @@ -6,15 +6,13 @@ import { withAuth, session } from "./auth"; import { DatabaseProvider } from "@keystone-6/core/types"; const baseUrl = process.env.BASE_URL ?? "http://localhost:3000"; -const databaseUrl = - process.env.DATABASE_URL ?? - "postgresql://postgres:password@127.0.0.1:5432/capital"; +const databaseUrl = process.env.DATABASE_URL ?? "postgresql://postgres:password@127.0.0.1:5432/capital"; const databaseProvider = process.env.DATABASE_PROVIDER ?? "postgresql"; export default withAuth( config({ ui: { - basePath: "/cms" + basePath: "/cms", }, db: { provider: databaseProvider as DatabaseProvider, @@ -39,5 +37,5 @@ export default withAuth( }, lists, session, - }) + }), ); diff --git a/content/limit.ts b/content/limit.ts index 44650ac..51cd628 100644 --- a/content/limit.ts +++ b/content/limit.ts @@ -7,8 +7,7 @@ const allowUser: any = { }, }; -const isEditor = ({ session }: { session: any }) => - session?.data.isEditor || session?.data.isAdmin; +const isEditor = ({ session }: { session: any }) => session?.data.isEditor || session?.data.isAdmin; const allowEditor: any = { operation: { create: isEditor, diff --git a/content/schema.graphql b/content/schema.graphql index 1e6747f..ff37f07 100644 --- a/content/schema.graphql +++ b/content/schema.graphql @@ -6,11 +6,29 @@ type User { name: String email: String password: PasswordState - posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!] + posts( + where: PostWhereInput! = {} + orderBy: [PostOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: PostWhereUniqueInput + ): [Post!] postsCount(where: PostWhereInput! = {}): Int - moments(where: MomentWhereInput! = {}, orderBy: [MomentOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: MomentWhereUniqueInput): [Moment!] + moments( + where: MomentWhereInput! = {} + orderBy: [MomentOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: MomentWhereUniqueInput + ): [Moment!] momentsCount(where: MomentWhereInput! = {}): Int - events(where: EventWhereInput! = {}, orderBy: [EventOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: EventWhereUniqueInput): [Event!] + events( + where: EventWhereInput! = {} + orderBy: [EventOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: EventWhereUniqueInput + ): [Event!] eventsCount(where: EventWhereInput! = {}): Int isAdmin: Boolean isEditor: Boolean @@ -253,7 +271,9 @@ input ImageFieldInput { upload: Upload! } -"""The `Upload` scalar type represents a file upload.""" +""" +The `Upload` scalar type represents a file upload. +""" scalar Upload input ImageUpdateArgs { @@ -335,17 +355,41 @@ type Post { title: String cover: Image description: String - assets(where: AssetWhereInput! = {}, orderBy: [AssetOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: AssetWhereUniqueInput): [Asset!] + assets( + where: AssetWhereInput! = {} + orderBy: [AssetOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: AssetWhereUniqueInput + ): [Asset!] assetsCount(where: AssetWhereInput! = {}): Int - images(where: ImageWhereInput! = {}, orderBy: [ImageOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: ImageWhereUniqueInput): [Image!] + images( + where: ImageWhereInput! = {} + orderBy: [ImageOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: ImageWhereUniqueInput + ): [Image!] imagesCount(where: ImageWhereInput! = {}): Int content: Post_content_Document type: PostTypeType isPublished: Boolean author: User - categories(where: CategoryWhereInput! = {}, orderBy: [CategoryOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: CategoryWhereUniqueInput): [Category!] + categories( + where: CategoryWhereInput! = {} + orderBy: [CategoryOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: CategoryWhereUniqueInput + ): [Category!] categoriesCount(where: CategoryWhereInput! = {}): Int - tags(where: TagWhereInput! = {}, orderBy: [TagOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: TagWhereUniqueInput): [Tag!] + tags( + where: TagWhereInput! = {} + orderBy: [TagOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: TagWhereUniqueInput + ): [Tag!] tagsCount(where: TagWhereInput! = {}): Int createdAt: DateTime } @@ -534,13 +578,31 @@ input TagRelateToManyForCreateInput { type Moment { id: ID! title: String - images(where: ImageWhereInput! = {}, orderBy: [ImageOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: ImageWhereUniqueInput): [Image!] + images( + where: ImageWhereInput! = {} + orderBy: [ImageOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: ImageWhereUniqueInput + ): [Image!] imagesCount(where: ImageWhereInput! = {}): Int content: Moment_content_Document author: User - categories(where: CategoryWhereInput! = {}, orderBy: [CategoryOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: CategoryWhereUniqueInput): [Category!] + categories( + where: CategoryWhereInput! = {} + orderBy: [CategoryOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: CategoryWhereUniqueInput + ): [Category!] categoriesCount(where: CategoryWhereInput! = {}): Int - tags(where: TagWhereInput! = {}, orderBy: [TagOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: TagWhereUniqueInput): [Tag!] + tags( + where: TagWhereInput! = {} + orderBy: [TagOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: TagWhereUniqueInput + ): [Tag!] tagsCount(where: TagWhereInput! = {}): Int createdAt: DateTime } @@ -699,9 +761,21 @@ type Event { isPublished: Boolean isHistory: Boolean author: User - categories(where: CategoryWhereInput! = {}, orderBy: [CategoryOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: CategoryWhereUniqueInput): [Category!] + categories( + where: CategoryWhereInput! = {} + orderBy: [CategoryOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: CategoryWhereUniqueInput + ): [Category!] categoriesCount(where: CategoryWhereInput! = {}): Int - tags(where: TagWhereInput! = {}, orderBy: [TagOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: TagWhereUniqueInput): [Tag!] + tags( + where: TagWhereInput! = {} + orderBy: [TagOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: TagWhereUniqueInput + ): [Tag!] tagsCount(where: TagWhereInput! = {}): Int createdAt: DateTime } @@ -776,11 +850,29 @@ type Category { id: ID! slug: String name: String - posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!] + posts( + where: PostWhereInput! = {} + orderBy: [PostOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: PostWhereUniqueInput + ): [Post!] postsCount(where: PostWhereInput! = {}): Int - moments(where: MomentWhereInput! = {}, orderBy: [MomentOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: MomentWhereUniqueInput): [Moment!] + moments( + where: MomentWhereInput! = {} + orderBy: [MomentOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: MomentWhereUniqueInput + ): [Moment!] momentsCount(where: MomentWhereInput! = {}): Int - events(where: EventWhereInput! = {}, orderBy: [EventOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: EventWhereUniqueInput): [Event!] + events( + where: EventWhereInput! = {} + orderBy: [EventOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: EventWhereUniqueInput + ): [Event!] eventsCount(where: EventWhereInput! = {}): Int } @@ -832,11 +924,29 @@ type Tag { id: ID! slug: String name: String - posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!] + posts( + where: PostWhereInput! = {} + orderBy: [PostOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: PostWhereUniqueInput + ): [Post!] postsCount(where: PostWhereInput! = {}): Int - moments(where: MomentWhereInput! = {}, orderBy: [MomentOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: MomentWhereUniqueInput): [Moment!] + moments( + where: MomentWhereInput! = {} + orderBy: [MomentOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: MomentWhereUniqueInput + ): [Moment!] momentsCount(where: MomentWhereInput! = {}): Int - events(where: EventWhereInput! = {}, orderBy: [EventOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: EventWhereUniqueInput): [Event!] + events( + where: EventWhereInput! = {} + orderBy: [EventOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: EventWhereUniqueInput + ): [Event!] eventsCount(where: EventWhereInput! = {}): Int } @@ -949,7 +1059,9 @@ type Mutation { createInitialUser(data: CreateInitialUserInput!): UserAuthenticationWithPasswordSuccess! } -union UserAuthenticationWithPasswordResult = UserAuthenticationWithPasswordSuccess | UserAuthenticationWithPasswordFailure +union UserAuthenticationWithPasswordResult = + | UserAuthenticationWithPasswordSuccess + | UserAuthenticationWithPasswordFailure type UserAuthenticationWithPasswordSuccess { sessionToken: String! @@ -968,31 +1080,85 @@ input CreateInitialUserInput { } type Query { - users(where: UserWhereInput! = {}, orderBy: [UserOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: UserWhereUniqueInput): [User!] + users( + where: UserWhereInput! = {} + orderBy: [UserOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: UserWhereUniqueInput + ): [User!] user(where: UserWhereUniqueInput!): User usersCount(where: UserWhereInput! = {}): Int - images(where: ImageWhereInput! = {}, orderBy: [ImageOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: ImageWhereUniqueInput): [Image!] + images( + where: ImageWhereInput! = {} + orderBy: [ImageOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: ImageWhereUniqueInput + ): [Image!] image(where: ImageWhereUniqueInput!): Image imagesCount(where: ImageWhereInput! = {}): Int - assets(where: AssetWhereInput! = {}, orderBy: [AssetOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: AssetWhereUniqueInput): [Asset!] + assets( + where: AssetWhereInput! = {} + orderBy: [AssetOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: AssetWhereUniqueInput + ): [Asset!] asset(where: AssetWhereUniqueInput!): Asset assetsCount(where: AssetWhereInput! = {}): Int - posts(where: PostWhereInput! = {}, orderBy: [PostOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: PostWhereUniqueInput): [Post!] + posts( + where: PostWhereInput! = {} + orderBy: [PostOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: PostWhereUniqueInput + ): [Post!] post(where: PostWhereUniqueInput!): Post postsCount(where: PostWhereInput! = {}): Int - moments(where: MomentWhereInput! = {}, orderBy: [MomentOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: MomentWhereUniqueInput): [Moment!] + moments( + where: MomentWhereInput! = {} + orderBy: [MomentOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: MomentWhereUniqueInput + ): [Moment!] moment(where: MomentWhereUniqueInput!): Moment momentsCount(where: MomentWhereInput! = {}): Int - projects(where: ProjectWhereInput! = {}, orderBy: [ProjectOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: ProjectWhereUniqueInput): [Project!] + projects( + where: ProjectWhereInput! = {} + orderBy: [ProjectOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: ProjectWhereUniqueInput + ): [Project!] project(where: ProjectWhereUniqueInput!): Project projectsCount(where: ProjectWhereInput! = {}): Int - events(where: EventWhereInput! = {}, orderBy: [EventOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: EventWhereUniqueInput): [Event!] + events( + where: EventWhereInput! = {} + orderBy: [EventOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: EventWhereUniqueInput + ): [Event!] event(where: EventWhereUniqueInput!): Event eventsCount(where: EventWhereInput! = {}): Int - categories(where: CategoryWhereInput! = {}, orderBy: [CategoryOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: CategoryWhereUniqueInput): [Category!] + categories( + where: CategoryWhereInput! = {} + orderBy: [CategoryOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: CategoryWhereUniqueInput + ): [Category!] category(where: CategoryWhereUniqueInput!): Category categoriesCount(where: CategoryWhereInput! = {}): Int - tags(where: TagWhereInput! = {}, orderBy: [TagOrderByInput!]! = [], take: Int, skip: Int! = 0, cursor: TagWhereUniqueInput): [Tag!] + tags( + where: TagWhereInput! = {} + orderBy: [TagOrderByInput!]! = [] + take: Int + skip: Int! = 0 + cursor: TagWhereUniqueInput + ): [Tag!] tag(where: TagWhereUniqueInput!): Tag tagsCount(where: TagWhereInput! = {}): Int keystone: KeystoneMeta! diff --git a/content/schema/events.ts b/content/schema/events.ts index 325f272..25f6cf8 100644 --- a/content/schema/events.ts +++ b/content/schema/events.ts @@ -1,9 +1,4 @@ -import { - checkbox, - relationship, - text, - timestamp, -} from "@keystone-6/core/fields"; +import { checkbox, relationship, text, timestamp } from "@keystone-6/core/fields"; import { document } from "@keystone-6/fields-document"; import { list } from "@keystone-6/core"; import { allowEditor } from "../limit"; diff --git a/content/schema/index.ts b/content/schema/index.ts index 5a69463..9316efc 100644 --- a/content/schema/index.ts +++ b/content/schema/index.ts @@ -1,12 +1,6 @@ import { list } from "@keystone-6/core"; -import { - text, - relationship, - password, - timestamp, - checkbox, -} from "@keystone-6/core/fields"; +import { text, relationship, password, timestamp, checkbox } from "@keystone-6/core/fields"; import { allowAdmin } from "../limit"; diff --git a/content/schema/moments.ts b/content/schema/moments.ts index 1c8bb0a..421a367 100644 --- a/content/schema/moments.ts +++ b/content/schema/moments.ts @@ -4,67 +4,67 @@ import { document } from "@keystone-6/fields-document"; import { relationship, text, timestamp } from "@keystone-6/core/fields"; export const Moment = list({ - access: allowUser, + access: allowUser, - fields: { - title: text({ validation: { isRequired: true } }), - images: relationship({ ref: "Image", many: true }), + fields: { + title: text({ validation: { isRequired: true } }), + images: relationship({ ref: "Image", many: true }), - content: document({ - formatting: true, - layouts: [ - [1, 1], - [1, 1, 1], - [2, 1], - [1, 2], - [1, 2, 1], - ], - links: true, - dividers: true, - }), + content: document({ + formatting: true, + layouts: [ + [1, 1], + [1, 1, 1], + [2, 1], + [1, 2], + [1, 2, 1], + ], + links: true, + dividers: true, + }), - author: relationship({ - ref: "User.moments", + author: relationship({ + ref: "User.moments", - ui: { - displayMode: "cards", - cardFields: ["name", "email"], - inlineEdit: { fields: ["name", "email"] }, - linkToItem: true, - inlineConnect: true, - }, + ui: { + displayMode: "cards", + cardFields: ["name", "email"], + inlineEdit: { fields: ["name", "email"] }, + linkToItem: true, + inlineConnect: true, + }, - many: false, - }), + many: false, + }), - categories: relationship({ - ref: "Category.moments", - many: true, - ui: { - displayMode: "cards", - cardFields: ["name"], - inlineEdit: { fields: ["name"] }, - linkToItem: true, - inlineConnect: true, - inlineCreate: { fields: ["name"] }, - }, - }), + categories: relationship({ + ref: "Category.moments", + many: true, + ui: { + displayMode: "cards", + cardFields: ["name"], + inlineEdit: { fields: ["name"] }, + linkToItem: true, + inlineConnect: true, + inlineCreate: { fields: ["name"] }, + }, + }), - tags: relationship({ - ref: "Tag.moments", - many: true, - ui: { - displayMode: "cards", - cardFields: ["name"], - inlineEdit: { fields: ["name"] }, - linkToItem: true, - inlineConnect: true, - inlineCreate: { fields: ["name"] }, - }, - }), + tags: relationship({ + ref: "Tag.moments", + many: true, + ui: { + displayMode: "cards", + cardFields: ["name"], + inlineEdit: { fields: ["name"] }, + linkToItem: true, + inlineConnect: true, + inlineCreate: { fields: ["name"] }, + }, + }), - createdAt: timestamp({ - defaultValue: { kind: "now" }, - }), - }, - }) \ No newline at end of file + createdAt: timestamp({ + defaultValue: { kind: "now" }, + }), + }, +}); diff --git a/content/schema/posts.ts b/content/schema/posts.ts index b2f4efe..d758810 100644 --- a/content/schema/posts.ts +++ b/content/schema/posts.ts @@ -1,10 +1,4 @@ -import { - checkbox, - relationship, - select, - text, - timestamp, -} from "@keystone-6/core/fields"; +import { checkbox, relationship, select, text, timestamp } from "@keystone-6/core/fields"; import { document } from "@keystone-6/fields-document"; import { list } from "@keystone-6/core"; import { allowEditor } from "../limit"; diff --git a/content/tsconfig.json b/content/tsconfig.json index ab5d609..604c618 100644 --- a/content/tsconfig.json +++ b/content/tsconfig.json @@ -6,5 +6,5 @@ "noEmit": true, "esModuleInterop": true, "forceConsistentCasingInFileNames": true, - } + }, } diff --git a/src/assets/fonts/fonts.css b/src/assets/fonts/fonts.css index ccda964..e4f139c 100644 --- a/src/assets/fonts/fonts.css +++ b/src/assets/fonts/fonts.css @@ -139,8 +139,7 @@ body { font-family: "Noto Serif SC"; font-style: normal; font-weight: 200; - src: url("./noto-serif-sc-v22-chinese-simplified-200.woff2") - format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ + src: url("./noto-serif-sc-v22-chinese-simplified-200.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ } /* noto-serif-sc-300 - chinese-simplified */ @@ -149,8 +148,7 @@ body { font-family: "Noto Serif SC"; font-style: normal; font-weight: 300; - src: url("./noto-serif-sc-v22-chinese-simplified-300.woff2") - format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ + src: url("./noto-serif-sc-v22-chinese-simplified-300.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ } /* noto-serif-sc-regular - chinese-simplified */ @@ -159,8 +157,7 @@ body { font-family: "Noto Serif SC"; font-style: normal; font-weight: 400; - src: url("./noto-serif-sc-v22-chinese-simplified-regular.woff2") - format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ + src: url("./noto-serif-sc-v22-chinese-simplified-regular.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ } /* noto-serif-sc-500 - chinese-simplified */ @@ -169,8 +166,7 @@ body { font-family: "Noto Serif SC"; font-style: normal; font-weight: 500; - src: url("./noto-serif-sc-v22-chinese-simplified-500.woff2") - format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ + src: url("./noto-serif-sc-v22-chinese-simplified-500.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ } /* noto-serif-sc-600 - chinese-simplified */ @@ -179,8 +175,7 @@ body { font-family: "Noto Serif SC"; font-style: normal; font-weight: 600; - src: url("./noto-serif-sc-v22-chinese-simplified-600.woff2") - format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ + src: url("./noto-serif-sc-v22-chinese-simplified-600.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ } /* noto-serif-sc-700 - chinese-simplified */ @@ -189,8 +184,7 @@ body { font-family: "Noto Serif SC"; font-style: normal; font-weight: 700; - src: url("./noto-serif-sc-v22-chinese-simplified-700.woff2") - format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ + src: url("./noto-serif-sc-v22-chinese-simplified-700.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ } /* noto-serif-sc-900 - chinese-simplified */ @@ -199,6 +193,5 @@ body { font-family: "Noto Serif SC"; font-style: normal; font-weight: 900; - src: url("./noto-serif-sc-v22-chinese-simplified-900.woff2") - format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ + src: url("./noto-serif-sc-v22-chinese-simplified-900.woff2") format("woff2"); /* Chrome 36+, Opera 23+, Firefox 39+, Safari 12+, iOS 10+ */ } diff --git a/src/components/Navbar.astro b/src/components/Navbar.astro index 1701316..9ba70eb 100644 --- a/src/components/Navbar.astro +++ b/src/components/Navbar.astro @@ -1,14 +1,17 @@ --- interface MenuItem { - href: string; + href?: string; label: string; children?: MenuItem[]; } const items: MenuItem[] = [ - { href: "/posts", label: "记录" }, - { href: "/events", label: "活动" }, - { href: "/projects", label: "企划" }, + { + label: "情报", children: [ + { href: "/posts", label: "记录" }, + { href: "/events", label: "活动" } + ] + } ]; --- @@ -22,11 +25,13 @@ const items: MenuItem[] = [ fill="none" viewBox="0 0 24 24" stroke="currentColor" - > + + @@ -62,13 +67,11 @@ const items: MenuItem[] = [
{item.label}
) : ( @@ -87,18 +90,22 @@ const items: MenuItem[] = [ class="swap-on fill-current w-8 h-8" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" - > + + + + diff --git a/src/components/posts/Media.tsx b/src/components/posts/Media.tsx index 1ed0ba2..953fbee 100644 --- a/src/components/posts/Media.tsx +++ b/src/components/posts/Media.tsx @@ -1,13 +1,7 @@ import { useState, Fragment } from "react"; -export default function Media({ - sources, -}: { - sources: { caption: string; url: string; type: string }[]; -}) { - const [focus, setFocus] = useState( - sources.map((_, idx) => idx === 0) - ); +export default function Media({ sources }: { sources: { caption: string; url: string; type: string }[] }) { + const [focus, setFocus] = useState(sources.map((_, idx) => idx === 0)); function changeFocus(idx: number) { setFocus(focus.map((_, idx) => idx === idx)); @@ -26,10 +20,7 @@ export default function Media({ checked={focus[idx]} onChange={() => changeFocus(idx)} /> -
+
{item.type === "video" && (