From 08d10b4ee8e8aeaacb3cfd3edd6d0421969fbe59 Mon Sep 17 00:00:00 2001 From: Justin Dennison Date: Wed, 13 Nov 2024 21:17:22 -0500 Subject: [PATCH] feature: added prettier and formatted all of the files in the project --- .prettierrc.mjs | 13 +++++++ package.json | 8 +++- pnpm-lock.yaml | 74 +++++++++++++++++++++++++++++++++--- src/layouts/Layout.astro | 25 ++++++------ src/pages/index.astro | 10 ++--- src/pages/posts/[slug].astro | 16 ++++---- src/pages/posts/index.astro | 22 +++++------ 7 files changed, 120 insertions(+), 48 deletions(-) create mode 100644 .prettierrc.mjs diff --git a/.prettierrc.mjs b/.prettierrc.mjs new file mode 100644 index 0000000..3ce655d --- /dev/null +++ b/.prettierrc.mjs @@ -0,0 +1,13 @@ +// .prettierrc.mjs +/** @type {import("prettier").Config} */ +export default { + plugins: ["prettier-plugin-astro"], + overrides: [ + { + files: "*.astro", + options: { + parser: "astro", + }, + }, + ], +}; diff --git a/package.json b/package.json index a93e508..cd1be4a 100644 --- a/package.json +++ b/package.json @@ -10,12 +10,16 @@ "astro": "astro" }, "dependencies": { + "@astrojs/check": "^0.9.4", "@astrojs/mdx": "^3.1.8", "@astrojs/rss": "^4.0.9", "@astrojs/sitemap": "^3.2.1", "astro": "^4.16.7", - "@astrojs/check": "^0.9.4", "typescript": "^5.6.3" }, - "packageManager": "pnpm@9.12.1" + "packageManager": "pnpm@9.12.1", + "devDependencies": { + "prettier": "^3.3.3", + "prettier-plugin-astro": "^0.14.1" + } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 76fb018..5686f3b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,7 +9,7 @@ importers: dependencies: "@astrojs/check": specifier: ^0.9.4 - version: 0.9.4(typescript@5.6.3) + version: 0.9.4(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.6.3) "@astrojs/mdx": specifier: ^3.1.8 version: 3.1.8(astro@4.16.7(rollup@4.24.2)(typescript@5.6.3)) @@ -25,6 +25,13 @@ importers: typescript: specifier: ^5.6.3 version: 5.6.3 + devDependencies: + prettier: + specifier: ^3.3.3 + version: 3.3.3 + prettier-plugin-astro: + specifier: ^0.14.1 + version: 0.14.1 packages: "@ampproject/remapping@2.3.0": @@ -2626,6 +2633,13 @@ packages: } engines: { node: ">=18.12" } + prettier-plugin-astro@0.14.1: + resolution: + { + integrity: sha512-RiBETaaP9veVstE4vUwSIcdATj6dKmXljouXc/DDNwBSPTp8FRkLGDSGFClKsAFeeg+13SB0Z1JZvbD76bigJw==, + } + engines: { node: ^14.15.0 || >=16.0.0 } + prettier@2.8.7: resolution: { @@ -2634,6 +2648,14 @@ packages: engines: { node: ">=10.13.0" } hasBin: true + prettier@3.3.3: + resolution: + { + integrity: sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==, + } + engines: { node: ">=14" } + hasBin: true + prismjs@1.29.0: resolution: { @@ -2842,6 +2864,18 @@ packages: integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==, } + s.color@0.0.15: + resolution: + { + integrity: sha512-AUNrbEUHeKY8XsYr/DYpl+qk5+aM+DChopnWOPEzn8YKzOhv4l2zH6LzZms3tOZP3wwdOyc0RmTciyi46HLIuA==, + } + + sass-formatter@0.7.9: + resolution: + { + integrity: sha512-CWZ8XiSim+fJVG0cFLStwDvft1VI7uvXdCNJYXhDvowiv+DsbD1nXLiQ4zrE5UBvj5DWZJ93cwN0NX5PMsr1Pw==, + } + sax@1.4.1: resolution: { @@ -3015,6 +3049,12 @@ packages: integrity: sha512-xT47I/Eo0rwJmaXC4oilDGDWLohVhR6o/xAQcPQN8q6QBuZVL8qMYL85kLmST5cPjAorwvqIA4qXTRQoYHaL6g==, } + suf-log@2.5.3: + resolution: + { + integrity: sha512-KvC8OPjzdNOe+xQ4XWJV2whQA0aM1kGVczMQ8+dStAO6KfEB140JEVQ9dE76ONZ0/Ylf67ni4tILPJB41U0eow==, + } + tinyexec@0.3.1: resolution: { @@ -3537,9 +3577,9 @@ snapshots: "@jridgewell/gen-mapping": 0.3.5 "@jridgewell/trace-mapping": 0.3.25 - "@astrojs/check@0.9.4(typescript@5.6.3)": + "@astrojs/check@0.9.4(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.6.3)": dependencies: - "@astrojs/language-server": 2.15.4(typescript@5.6.3) + "@astrojs/language-server": 2.15.4(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.6.3) chokidar: 4.0.1 kleur: 4.1.5 typescript: 5.6.3 @@ -3552,7 +3592,7 @@ snapshots: "@astrojs/internal-helpers@0.4.1": {} - "@astrojs/language-server@2.15.4(typescript@5.6.3)": + "@astrojs/language-server@2.15.4(prettier-plugin-astro@0.14.1)(prettier@3.3.3)(typescript@5.6.3)": dependencies: "@astrojs/compiler": 2.10.3 "@astrojs/yaml2ts": 0.2.2 @@ -3566,12 +3606,15 @@ snapshots: volar-service-css: 0.0.62(@volar/language-service@2.4.8) volar-service-emmet: 0.0.62(@volar/language-service@2.4.8) volar-service-html: 0.0.62(@volar/language-service@2.4.8) - volar-service-prettier: 0.0.62(@volar/language-service@2.4.8) + volar-service-prettier: 0.0.62(@volar/language-service@2.4.8)(prettier@3.3.3) volar-service-typescript: 0.0.62(@volar/language-service@2.4.8) volar-service-typescript-twoslash-queries: 0.0.62(@volar/language-service@2.4.8) volar-service-yaml: 0.0.62(@volar/language-service@2.4.8) vscode-html-languageservice: 5.3.1 vscode-uri: 3.0.8 + optionalDependencies: + prettier: 3.3.3 + prettier-plugin-astro: 0.14.1 transitivePeerDependencies: - typescript @@ -5420,9 +5463,17 @@ snapshots: find-yarn-workspace-root2: 1.2.16 which-pm: 3.0.0 + prettier-plugin-astro@0.14.1: + dependencies: + "@astrojs/compiler": 2.10.3 + prettier: 3.3.3 + sass-formatter: 0.7.9 + prettier@2.8.7: optional: true + prettier@3.3.3: {} + prismjs@1.29.0: {} prompts@2.4.2: @@ -5617,6 +5668,12 @@ snapshots: dependencies: queue-microtask: 1.2.3 + s.color@0.0.15: {} + + sass-formatter@0.7.9: + dependencies: + suf-log: 2.5.3 + sax@1.4.1: {} section-matter@1.0.0: @@ -5731,6 +5788,10 @@ snapshots: dependencies: inline-style-parser: 0.2.4 + suf-log@2.5.3: + dependencies: + s.color: 0.0.15 + tinyexec@0.3.1: {} to-regex-range@5.0.1: @@ -5872,11 +5933,12 @@ snapshots: optionalDependencies: "@volar/language-service": 2.4.8 - volar-service-prettier@0.0.62(@volar/language-service@2.4.8): + volar-service-prettier@0.0.62(@volar/language-service@2.4.8)(prettier@3.3.3): dependencies: vscode-uri: 3.0.8 optionalDependencies: "@volar/language-service": 2.4.8 + prettier: 3.3.3 volar-service-typescript-twoslash-queries@0.0.62(@volar/language-service@2.4.8): dependencies: diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index b0dc445..074dacf 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -1,7 +1,7 @@ --- import { ViewTransitions } from "astro:transitions"; interface Props { - title: string; + title: string; } const { title } = Astro.props; @@ -9,23 +9,22 @@ const { title } = Astro.props; - - - - - - + + + + + + {title} + /> - - - - + + + + - diff --git a/src/pages/index.astro b/src/pages/index.astro index 37bfa5c..43da8b8 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,16 +1,14 @@ --- -import Layout from '../layouts/Layout.astro'; +import Layout from "../layouts/Layout.astro"; const baseUrl = import.meta.env.BASE_URL; --- -
-

Welcome to JD's page.

+
+

Welcome to JD's page.

- - diff --git a/src/pages/posts/[slug].astro b/src/pages/posts/[slug].astro index 56bd7c5..1f2722d 100644 --- a/src/pages/posts/[slug].astro +++ b/src/pages/posts/[slug].astro @@ -1,19 +1,19 @@ --- import { getCollection } from "astro:content"; - export async function getStaticPaths() { -const postEntries = await getCollection("posts", ({ data }) => { - return import.meta.env.PROD ? data.draft !== true : true; -}); -return postEntries.map(entry => ({ params: { slug: entry.slug }, props: { entry }})) + const postEntries = await getCollection("posts", ({ data }) => { + return import.meta.env.PROD ? data.draft !== true : true; + }); + return postEntries.map((entry) => ({ + params: { slug: entry.slug }, + props: { entry }, + })); } const { entry } = Astro.props; -const { Content } = await entry.render() - +const { Content } = await entry.render(); ---

{entry.data.title}

- diff --git a/src/pages/posts/index.astro b/src/pages/posts/index.astro index 0df64ca..af7444e 100644 --- a/src/pages/posts/index.astro +++ b/src/pages/posts/index.astro @@ -1,26 +1,22 @@ --- -import Layout from '../../layouts/Layout.astro'; +import Layout from "../../layouts/Layout.astro"; import { getCollection } from "astro:content"; const postEntries = await getCollection("posts", ({ data }) => { return import.meta.env.PROD ? data.draft !== true : true; }); const baseUrl = import.meta.env.BASE_URL; - ---
-
+
- - - -