From 2a2fb74a5773f093aae1a32d395185d569bde16e Mon Sep 17 00:00:00 2001 From: Eva Decker Date: Thu, 12 Dec 2024 10:20:43 -0500 Subject: [PATCH] Upgrade to Astro 5 --- astro.config.mjs | 2 +- package.json | 2 +- pnpm-lock.yaml | 93 ++----------------- src/{content/config.ts => content.config.ts} | 11 ++- src/data/colors.ts | 18 ++-- src/pages/{[slug].astro => [id].astro} | 10 +- src/pages/blog/{[slug].astro => [id].astro} | 15 ++- src/pages/blog/index.astro | 2 +- .../brand-assets/_components/Swatches.astro | 2 +- src/pages/index.astro | 5 +- 10 files changed, 43 insertions(+), 117 deletions(-) rename src/{content/config.ts => content.config.ts} (82%) rename src/pages/{[slug].astro => [id].astro} (72%) rename src/pages/blog/{[slug].astro => [id].astro} (94%) diff --git a/astro.config.mjs b/astro.config.mjs index 282a6c9..7af04f6 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -13,7 +13,7 @@ import cssnano from "cssnano"; // https://astro.build/config export default defineConfig({ - output: "hybrid", + output: "static", adapter: cloudflare({ imageService: "compile", }), diff --git a/package.json b/package.json index 6ad7cdd..ed7db75 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "dependencies": { "@astrojs/check": "^0.9.4", "@astrojs/cloudflare": "12.0.1", - "@astrojs/markdoc": "^0.12.1", + "@astrojs/markdoc": "^0.12.3", "@astrojs/react": "^4.1.0", "@astrojs/sitemap": "^3.2.1", "@axe-core/playwright": "^4.10.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e8f19b6..d718a4d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -15,8 +15,8 @@ importers: specifier: 12.0.1 version: 12.0.1(@types/node@22.10.1)(astro@5.0.5(@types/node@22.10.1)(rollup@4.28.1)(sass@1.82.0)(typescript@5.7.2)(yaml@2.5.1))(sass@1.82.0)(yaml@2.5.1) '@astrojs/markdoc': - specifier: ^0.12.1 - version: 0.12.1(@types/react@19.0.1)(astro@5.0.5(@types/node@22.10.1)(rollup@4.28.1)(sass@1.82.0)(typescript@5.7.2)(yaml@2.5.1))(react@19.0.0) + specifier: ^0.12.3 + version: 0.12.3(@types/react@19.0.1)(astro@5.0.5(@types/node@22.10.1)(rollup@4.28.1)(sass@1.82.0)(typescript@5.7.2)(yaml@2.5.1))(react@19.0.0) '@astrojs/react': specifier: ^4.1.0 version: 4.1.0(@types/node@22.10.1)(@types/react-dom@19.0.2(@types/react@19.0.1))(@types/react@19.0.1)(react-dom@19.0.0(react@19.0.0))(react@19.0.0)(sass@1.82.0)(yaml@2.5.1) @@ -149,15 +149,12 @@ packages: prettier-plugin-astro: optional: true - '@astrojs/markdoc@0.12.1': - resolution: {integrity: sha512-1ayrIK1DlsT72QurLGMBCNmmTIlvVFbNih3bobaUxbjQ/r0hKbbdlLx42p8bfvf0J4iTiXSL7FhpU972rtwMHA==} + '@astrojs/markdoc@0.12.3': + resolution: {integrity: sha512-LLmHq2vOkDGdfmr25r7gloRqU81Xx7LY85y/A4tSsWpINniStadH6ayL1aOM7ToU41CkNzb+87yVthW3wVGC0g==} engines: {node: ^18.17.1 || ^20.3.0 || >=22.0.0} peerDependencies: astro: ^5.0.0 - '@astrojs/markdown-remark@6.0.0': - resolution: {integrity: sha512-Tabo7xM44Pz2Yf9qpdaCCgxRmtaypi2YCinqTUNefDrWUa+OyKW62OuNeCaGwNh/ys+QAd9FUWN5/3HgPWjP4Q==} - '@astrojs/markdown-remark@6.0.1': resolution: {integrity: sha512-CTSYijj25NfxgZi15TU3CwPwgyD1/7yA3FcdcNmB9p94nydupiUbrIiq3IqeTp2m5kCVzxbPZeC7fTwEOaNyGw==} @@ -1816,33 +1813,18 @@ packages: cpu: [x64] os: [win32] - '@shikijs/core@1.24.1': - resolution: {integrity: sha512-3q/9oarMVcLqJ+NQOdKL40dJVq/UKCsiWXz3QRQPBglHqa8dDJ0p6TuMuk2gHphy5FZcvFtg4UHBgpW0JtZ8+A==} - '@shikijs/core@1.24.2': resolution: {integrity: sha512-BpbNUSKIwbKrRRA+BQj0BEWSw+8kOPKDJevWeSE/xIqGX7K0xrCZQ9kK0nnEQyrzsUoka1l81ZtJ2mGaCA32HQ==} - '@shikijs/engine-javascript@1.24.1': - resolution: {integrity: sha512-lNgUSHYDYaQ6daj4lJJqcY2Ru9LgHwpFoposJkRVRPh21Yg4kaPFRhzaWoSg3PliwcDOpDuMy3xsmQaJp201Fg==} - '@shikijs/engine-javascript@1.24.2': resolution: {integrity: sha512-EqsmYBJdLEwEiO4H+oExz34a5GhhnVp+jH9Q/XjPjmBPc6TE/x4/gD0X3i0EbkKKNqXYHHJTJUpOLRQNkEzS9Q==} - '@shikijs/engine-oniguruma@1.24.1': - resolution: {integrity: sha512-KdrTIBIONWd+Xs61eh8HdIpfigtrseat9dpARvaOe2x0g/FNTbwbkGr3y92VSOVD1XotzEskh3v/nCzyWjkf7g==} - '@shikijs/engine-oniguruma@1.24.2': resolution: {integrity: sha512-ZN6k//aDNWRJs1uKB12pturKHh7GejKugowOFGAuG7TxDRLod1Bd5JhpOikOiFqPmKjKEPtEA6mRCf7q3ulDyQ==} - '@shikijs/types@1.24.1': - resolution: {integrity: sha512-ZwZFbShFY/APfKNt3s9Gv8rhTm29GodSKsOW66X6N+HGsZuaHalE1VUEX4fv93UXHTZTLjb3uxn63F96RhGfXw==} - '@shikijs/types@1.24.2': resolution: {integrity: sha512-bdeWZiDtajGLG9BudI0AHet0b6e7FbR0EsE4jpGaI0YwHm/XJunI9+3uZnzFtX65gsyJ6ngCIWUfA4NWRPnBkQ==} - '@shikijs/vscode-textmate@9.3.0': - resolution: {integrity: sha512-jn7/7ky30idSkd/O5yDBfAnVt+JJpepofP/POZ1iMOxK59cOfqIgg/Dj0eFsjOTMw+4ycJN0uhZH/Eb0bs/EUA==} - '@shikijs/vscode-textmate@9.3.1': resolution: {integrity: sha512-79QfK1393x9Ho60QFyLti+QfdJzRQCVLFb97kOIV7Eo9vQU/roINgk7m24uv0a7AUvN//RDH36FLjjK48v0s9g==} @@ -3593,9 +3575,6 @@ packages: resolution: {integrity: sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==} engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} - shiki@1.24.1: - resolution: {integrity: sha512-/qByWMg05+POb63c/OvnrU17FcCUa34WU4F6FCrd/mjDPEDPl8YUNRkRMbo8l3iYMLydfCgxi1r37JFoSw8A4A==} - shiki@1.24.2: resolution: {integrity: sha512-TR1fi6mkRrzW+SKT5G6uKuc32Dj2EEa7Kj0k8kGqiBINb+C1TiflVOiT9ta6GqOJtC4fraxO5SLUaKBcSY38Fg==} @@ -4243,10 +4222,10 @@ snapshots: transitivePeerDependencies: - typescript - '@astrojs/markdoc@0.12.1(@types/react@19.0.1)(astro@5.0.5(@types/node@22.10.1)(rollup@4.28.1)(sass@1.82.0)(typescript@5.7.2)(yaml@2.5.1))(react@19.0.0)': + '@astrojs/markdoc@0.12.3(@types/react@19.0.1)(astro@5.0.5(@types/node@22.10.1)(rollup@4.28.1)(sass@1.82.0)(typescript@5.7.2)(yaml@2.5.1))(react@19.0.0)': dependencies: '@astrojs/internal-helpers': 0.4.2 - '@astrojs/markdown-remark': 6.0.0 + '@astrojs/markdown-remark': 6.0.1 '@astrojs/prism': 3.2.0 '@markdoc/markdoc': 0.4.0(@types/react@19.0.1)(react@19.0.0) astro: 5.0.5(@types/node@22.10.1)(rollup@4.28.1)(sass@1.82.0)(typescript@5.7.2)(yaml@2.5.1) @@ -4258,30 +4237,6 @@ snapshots: - react - supports-color - '@astrojs/markdown-remark@6.0.0': - dependencies: - '@astrojs/prism': 3.2.0 - github-slugger: 2.0.0 - hast-util-from-html: 2.0.3 - hast-util-to-text: 4.0.2 - import-meta-resolve: 4.1.0 - js-yaml: 4.1.0 - mdast-util-definitions: 6.0.0 - rehype-raw: 7.0.0 - rehype-stringify: 10.0.1 - remark-gfm: 4.0.0 - remark-parse: 11.0.0 - remark-rehype: 11.1.1 - remark-smartypants: 3.0.2 - shiki: 1.24.1 - unified: 11.0.5 - unist-util-remove-position: 5.0.0 - unist-util-visit: 5.0.0 - unist-util-visit-parents: 6.0.1 - vfile: 6.0.3 - transitivePeerDependencies: - - supports-color - '@astrojs/markdown-remark@6.0.1': dependencies: '@astrojs/prism': 3.2.0 @@ -6285,15 +6240,6 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.28.1': optional: true - '@shikijs/core@1.24.1': - dependencies: - '@shikijs/engine-javascript': 1.24.1 - '@shikijs/engine-oniguruma': 1.24.1 - '@shikijs/types': 1.24.1 - '@shikijs/vscode-textmate': 9.3.0 - '@types/hast': 3.0.4 - hast-util-to-html: 9.0.3 - '@shikijs/core@1.24.2': dependencies: '@shikijs/engine-javascript': 1.24.2 @@ -6303,40 +6249,22 @@ snapshots: '@types/hast': 3.0.4 hast-util-to-html: 9.0.3 - '@shikijs/engine-javascript@1.24.1': - dependencies: - '@shikijs/types': 1.24.1 - '@shikijs/vscode-textmate': 9.3.0 - oniguruma-to-es: 0.7.0 - '@shikijs/engine-javascript@1.24.2': dependencies: '@shikijs/types': 1.24.2 '@shikijs/vscode-textmate': 9.3.1 oniguruma-to-es: 0.7.0 - '@shikijs/engine-oniguruma@1.24.1': - dependencies: - '@shikijs/types': 1.24.1 - '@shikijs/vscode-textmate': 9.3.0 - '@shikijs/engine-oniguruma@1.24.2': dependencies: '@shikijs/types': 1.24.2 '@shikijs/vscode-textmate': 9.3.1 - '@shikijs/types@1.24.1': - dependencies: - '@shikijs/vscode-textmate': 9.3.0 - '@types/hast': 3.0.4 - '@shikijs/types@1.24.2': dependencies: '@shikijs/vscode-textmate': 9.3.1 '@types/hast': 3.0.4 - '@shikijs/vscode-textmate@9.3.0': {} - '@shikijs/vscode-textmate@9.3.1': {} '@sindresorhus/slugify@1.1.2': @@ -8598,15 +8526,6 @@ snapshots: '@img/sharp-win32-ia32': 0.33.5 '@img/sharp-win32-x64': 0.33.5 - shiki@1.24.1: - dependencies: - '@shikijs/core': 1.24.1 - '@shikijs/engine-javascript': 1.24.1 - '@shikijs/engine-oniguruma': 1.24.1 - '@shikijs/types': 1.24.1 - '@shikijs/vscode-textmate': 9.3.0 - '@types/hast': 3.0.4 - shiki@1.24.2: dependencies: '@shikijs/core': 1.24.2 diff --git a/src/content/config.ts b/src/content.config.ts similarity index 82% rename from src/content/config.ts rename to src/content.config.ts index 83533ac..b420675 100644 --- a/src/content/config.ts +++ b/src/content.config.ts @@ -1,10 +1,11 @@ +import { glob } from "astro/loaders"; import { z, defineCollection, reference } from "astro:content"; import type { RoughAnnotationType } from "rough-notation/lib/model"; import type { NamesakeColor } from "~/data/colors"; export const collections = { authors: defineCollection({ - type: "data", + loader: glob({ pattern: "**/[^_]*.yaml", base: "./src/content/authors" }), schema: ({ image }) => z.object({ name: z.string(), @@ -22,7 +23,7 @@ export const collections = { }), pages: defineCollection({ - type: "content", + loader: glob({ pattern: "**/[^_]*.md", base: "./src/content/pages" }), schema: ({ image }) => z.object({ title: z.string(), @@ -39,7 +40,7 @@ export const collections = { }), posts: defineCollection({ - type: "content", + loader: glob({ pattern: "**/[^_]*.md", base: "./src/content/posts" }), schema: ({ image }) => z.object({ title: z.string(), @@ -59,7 +60,7 @@ export const collections = { }), partners: defineCollection({ - type: "data", + loader: glob({ pattern: "**/[^_]*.yaml", base: "./src/content/partners" }), schema: ({ image }) => z.object({ name: z.string(), @@ -70,7 +71,7 @@ export const collections = { }), press: defineCollection({ - type: "data", + loader: glob({ pattern: "**/[^_]*.yaml", base: "./src/content/press" }), schema: ({ image }) => z.object({ title: z.string(), diff --git a/src/data/colors.ts b/src/data/colors.ts index 69b9b9e..49264de 100644 --- a/src/data/colors.ts +++ b/src/data/colors.ts @@ -1,6 +1,6 @@ type Color = { + id: string; name: string; - slug: string; hex: string; forText?: boolean; }; @@ -17,44 +17,44 @@ export type NamesakeColor = export const colors: Record = { purple: { + id: "purple", name: "Namesake Purple", - slug: "purple", hex: "#CDA5EF", }, pink: { + id: "pink", name: "Pastel Pink", - slug: "pink", hex: "#ECADD4", }, blue: { + id: "blue", name: "Pastel Blue", - slug: "blue", hex: "#96C7F2", }, yellow: { + id: "yellow", name: "Pastel Yellow", - slug: "yellow", hex: "#ECDD85", }, green: { + id: "green", name: "Pastel Green", - slug: "green", hex: "#97CF9C", }, brown: { + id: "brown", name: "Pastel Brown", - slug: "brown", hex: "#DDB896", }, black: { + id: "black", name: "Photocopy Black", - slug: "black", hex: "#111111", forText: true, }, white: { + id: "white", name: "Photocopy White", - slug: "white", hex: "#E1E1E1", forText: true, }, diff --git a/src/pages/[slug].astro b/src/pages/[id].astro similarity index 72% rename from src/pages/[slug].astro rename to src/pages/[id].astro index 3698e00..98b21ef 100644 --- a/src/pages/[slug].astro +++ b/src/pages/[id].astro @@ -1,5 +1,5 @@ --- -import { getCollection, type CollectionEntry } from "astro:content"; +import { getCollection, type CollectionEntry, render } from "astro:content"; import ProseLayout from "~/layouts/ProseLayout.astro"; @@ -11,14 +11,14 @@ export async function getStaticPaths() { const pages = await getCollection("pages"); return pages.map((page) => ({ - params: { slug: page.slug }, - props: { page }, + params: { id: page.id }, + props: page, })); } const { page } = Astro.props; -const { data, render } = page; -const { Content } = await render(); +const { data } = page; +const { Content } = await render(page); --- ; @@ -12,15 +17,15 @@ export async function getStaticPaths() { const posts = await getCollection("posts"); return posts.map((post) => ({ - params: { slug: post.slug }, - props: { post }, + params: { id: post.id }, + props: post, })); } const { post } = Astro.props; -const { data, render } = post; -const { Content } = await render(); +const { data } = post; +const { Content } = await render(post); const authors = await getEntries(data.authors); --- diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index cdcc827..f78ae6c 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -28,7 +28,7 @@ const posts = await getCollection("posts"); authors={authorsNames} title={post.data.title} date={post.data.publishDate} - url={`/blog/${post.slug}`} + url={`/blog/${post.id}`} description={post.data.description} image={ post.data.image diff --git a/src/pages/brand-assets/_components/Swatches.astro b/src/pages/brand-assets/_components/Swatches.astro index f5293bb..551b32f 100644 --- a/src/pages/brand-assets/_components/Swatches.astro +++ b/src/pages/brand-assets/_components/Swatches.astro @@ -18,7 +18,7 @@ import { colors } from "~/data/colors";