Skip to content

Commit

Permalink
feature: added prettier and formatted all of the files in the project
Browse files Browse the repository at this point in the history
  • Loading branch information
justin1dennison committed Nov 14, 2024
1 parent 43c1269 commit 08d10b4
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 48 deletions.
13 changes: 13 additions & 0 deletions .prettierrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// .prettierrc.mjs
/** @type {import("prettier").Config} */
export default {
plugins: ["prettier-plugin-astro"],
overrides: [
{
files: "*.astro",
options: {
parser: "astro",
},
},
],
};
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]"
"packageManager": "[email protected]",
"devDependencies": {
"prettier": "^3.3.3",
"prettier-plugin-astro": "^0.14.1"
}
}
74 changes: 68 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
---
import { ViewTransitions } from "astro:transitions";
interface Props {
title: string;
title: string;
}
const { title } = Astro.props;
---

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="description" content="Astro description" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />
<head>
<meta charset="UTF-8" />
<meta name="description" content="Astro description" />
<meta name="viewport" content="width=device-width" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} />
<title>{title}</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2"
crossorigin="anonymous"
/>
/>
<ViewTransitions />
</head>
<body>
<slot />
</body>
</head>
<body>
<slot />
</body>
</html>

10 changes: 4 additions & 6 deletions src/pages/index.astro
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
---
import Layout from '../layouts/Layout.astro';
import Layout from "../layouts/Layout.astro";
const baseUrl = import.meta.env.BASE_URL;
---

<Layout title="Welcome to JD.">
<main>
<h1>Welcome to <span class="text-gradient">JD's</span> page.</h1>
<main>
<h1>Welcome to <span class="text-gradient">JD's</span> page.</h1>
</main>
<ul>
<li><a href=`${baseUrl}/posts`>Blog Posts</a></li>
<li><a href={`${baseUrl}/posts`}>Blog Posts</a></li>
</ul>
</Layout>


16 changes: 8 additions & 8 deletions src/pages/posts/[slug].astro
Original file line number Diff line number Diff line change
@@ -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();
---

<h1>{entry.data.title}</h1>
<Content />

22 changes: 9 additions & 13 deletions src/pages/posts/index.astro
Original file line number Diff line number Diff line change
@@ -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;
---

<Layout title="Posts">
<main>
<ul>
{postEntries.map((entry) =>
(
<li>
<a href=`${baseUrl}/posts/${entry.slug}`>{ entry.data.title }</a>
</li>
))}
{
postEntries.map((entry) => (
<li>
<a href={`${baseUrl}/posts/${entry.slug}`}>{entry.data.title}</a>
</li>
))
}
</ul>
</main>
</main>
</Layout>




0 comments on commit 08d10b4

Please sign in to comment.