diff --git a/astro.config.ts b/astro.config.ts index d7daf65..a2057fc 100644 --- a/astro.config.ts +++ b/astro.config.ts @@ -1,10 +1,11 @@ +import db from "@astrojs/db"; import markdoc from "@astrojs/markdoc"; import tailwind from "@astrojs/tailwind"; import expressiveCode from "astro-expressive-code"; import { defineConfig } from "astro/config"; import { rename } from "fs/promises"; -import db from "@astrojs/db"; +import webVitals from "@astrojs/web-vitals"; // https://astro.build/config export default defineConfig({ @@ -43,5 +44,6 @@ export default defineConfig({ }, }, db(), + webVitals(), ], }); diff --git a/db/config.ts b/db/config.ts index 540a2e7..40163dc 100644 --- a/db/config.ts +++ b/db/config.ts @@ -1,33 +1,33 @@ -import { column, defineDb, defineTable } from 'astro:db'; +import { column, defineDb, defineTable } from "astro:db"; const Cover = defineTable({ - columns: { - id: column.number({ primaryKey: true }), - src: column.text(), - width: column.number(), - height: column.number(), - placeholder: column.text() - } + columns: { + id: column.number({ primaryKey: true }), + src: column.text(), + width: column.number(), + height: column.number(), + placeholder: column.text(), + }, }); const Catalogue = defineTable({ - columns: { - id: column.number({ primaryKey: true }), - type: column.text(), - title: column.text(), - author: column.text(), - cover: column.number({ references: () => Cover.columns.id }), - rating: column.text(), - finishedDate: column.number({ optional: true }), - platform: column.text({ optional: true }), - metadata: column.text() - } + columns: { + id: column.number({ primaryKey: true }), + type: column.text(), + title: column.text(), + author: column.text(), + cover: column.number({ references: () => Cover.columns.id }), + rating: column.text(), + finishedDate: column.number({ optional: true }), + platform: column.text({ optional: true }), + metadata: column.text(), + }, }); // https://astro.build/db/config export default defineDb({ - tables: { - Cover, - Catalogue - } + tables: { + Cover, + Catalogue, + }, }); diff --git a/db/seed.ts b/db/seed.ts index 88728a0..9f30deb 100644 --- a/db/seed.ts +++ b/db/seed.ts @@ -6,16 +6,16 @@ import type { LocalImageServiceWithPlaceholder } from "src/imageService"; // https://astro.build/db/seed export default async function seed() { - await prepareDB(); + await prepareDB(); } export async function prepareDB() { - const games = await getCollection("games"); + const games = await getCollection("games"); const movies = await getCollection("movies"); const shows = await getCollection("shows"); const books = await getCollection("books"); - const catalogueContent = [...games, ...movies, ...shows, ...books]; + const catalogueContent = [...games, ...movies, ...shows, ...books]; for (const entry of catalogueContent) { await addCatalogueEntry(entry); } @@ -26,16 +26,19 @@ export async function addCatalogueEntry(entry: allCatalogueTypes) { const [processedCover, placeholderURL] = await getCoverAndPlaceholder(cover); const metadata = await getCatalogueData(entry); - const author = getAuthorFromEntryMetadata(type, metadata); + const author = getAuthorFromEntryMetadata(type, metadata); - const coverId = await db.insert(Cover).values({ - src: processedCover.src, - width: processedCover.attributes.width, - height: processedCover.attributes.height, - placeholder: placeholderURL, - }).returning({ id: Cover.id }); + const coverId = await db + .insert(Cover) + .values({ + src: processedCover.src, + width: processedCover.attributes.width, + height: processedCover.attributes.height, + placeholder: placeholderURL, + }) + .returning({ id: Cover.id }); - const firstCoverId = coverId[0]?.id ?? -1; + const firstCoverId = coverId[0]?.id ?? -1; const insertData = { type: type, diff --git a/package.json b/package.json index 317e75d..1aade52 100644 --- a/package.json +++ b/package.json @@ -49,6 +49,7 @@ "@astrojs/check": "^0.7.0", "@astrojs/db": "~0.10.0", "@astrojs/markdoc": "^0.11.0", + "@astrojs/web-vitals": "^0.2.0", "@types/igdb-api-node": "^5.0.3", "astro-capo": "^0.0.1", "astro-expressive-code": "^0.35.3", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f925b43..71aefac 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -14,11 +14,14 @@ dependencies: specifier: ^0.7.0 version: 0.7.0(prettier-plugin-astro@0.13.0)(prettier@3.2.5)(typescript@5.4.5) '@astrojs/db': - specifier: ~0.10.0 - version: 0.10.7 + specifier: ~0.11.4 + version: 0.11.4 '@astrojs/markdoc': specifier: ^0.11.0 version: 0.11.0(astro@4.8.6) + '@astrojs/web-vitals': + specifier: ^0.2.0 + version: 0.2.0(@astrojs/db@0.11.4) '@types/igdb-api-node': specifier: ^5.0.3 version: 5.0.3 @@ -163,9 +166,10 @@ packages: /@astrojs/compiler@2.8.0: resolution: {integrity: sha512-yrpD1WRGqsJwANaDIdtHo+YVjvIOFAjC83lu5qENIgrafwZcJgSXDuwVMXOgok4tFzpeKLsFQ6c3FoUdloLWBQ==} - /@astrojs/db@0.10.7: - resolution: {integrity: sha512-P2jP1M0KLSe9qNlKX7Y+KMVQnVKAFj6l64JB6xomLXS3y4PsY0gxGOll+aRMFb9GShpzGYarbR5Qo/B6k+ulIA==} + /@astrojs/db@0.11.4: + resolution: {integrity: sha512-PuVej9DNu5ZzlRGS0NUl3iH/5BRo/eG3XRywXbHIQvA0sdI7UZSFisbpUQYJU9iKK9Bxow/FWrqfw2jwqXaC8Q==} dependencies: + '@astrojs/studio': 0.1.0 '@libsql/client': 0.6.0 async-listen: 3.0.1 ci-info: 4.0.0 @@ -299,6 +303,14 @@ packages: dependencies: prismjs: 1.29.0 + /@astrojs/studio@0.1.0: + resolution: {integrity: sha512-pjggMFgtZHPem6RWall02DTa54VCQ4fjqj4bLV0CpQEi0ydgDlughb81PtLhpQPTV0IUtTFOnHbzx6rcKMBAzg==} + dependencies: + ci-info: 4.0.0 + kleur: 4.1.5 + ora: 8.0.1 + dev: false + /@astrojs/tailwind@5.1.0(astro@4.8.6)(tailwindcss@3.4.3): resolution: {integrity: sha512-BJoCDKuWhU9FT2qYg+fr6Nfb3qP4ShtyjXGHKA/4mHN94z7BGcmauQK23iy+YH5qWvTnhqkd6mQPQ1yTZTe9Ig==} peerDependencies: @@ -328,6 +340,15 @@ packages: transitivePeerDependencies: - supports-color + /@astrojs/web-vitals@0.2.0(@astrojs/db@0.11.4): + resolution: {integrity: sha512-9yChO17Tahs+OIvvY5pZfqMpag4Hvz1T4Lnv7NfMvc5Hx7KlmDyCGLP/P+kSy0QZ0TXnXIGrjAoZj+9CPVkIWA==} + peerDependencies: + '@astrojs/db': ^0.11.0 + dependencies: + '@astrojs/db': 0.11.4 + web-vitals: 4.0.1 + dev: false + /@babel/code-frame@7.24.2: resolution: {integrity: sha512-y5+tLQyV8pg3fsiln67BVLD1P13Eg4lh5RW9mF0zUuvLrv9uIQ4MCL+CRT+FTsBlBjcIan6PGsLcBN0m3ClUyQ==} engines: {node: '>=6.9.0'} @@ -6807,6 +6828,10 @@ packages: resolution: {integrity: sha512-6BjspCO9VriYy12z356nL6JBS0GYeEcA457YyRzD+dD6XYCQ75NKhcOHUMHentOE7OcVCIXXDvOm0jKFfQG2Gg==} dev: false + /web-vitals@4.0.1: + resolution: {integrity: sha512-AW6qT/vXK3pbf+WgVcEBXY//AWCpXjVKgdb6rt0cARSUdtT+NUtZCOeo+CSLUX7PjSQ275DmxfkAs7QlPbtR6w==} + dev: false + /webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} dev: false