Prettier config

This commit is contained in:
2023-02-25 17:56:35 +00:00
parent eaa1ccfd9e
commit b60f598ba2
17 changed files with 1381 additions and 220 deletions
+7
View File
@@ -172,6 +172,13 @@ declare module 'astro:content' {
collection: "blog",
data: InferEntrySchema<"blog">
},
"the-right-way-to-code.md": {
id: "the-right-way-to-code.md",
slug: "the-right-way-to-code",
body: string,
collection: "blog",
data: InferEntrySchema<"blog">
},
},
};
+7 -1
View File
@@ -1,3 +1,9 @@
{
"plugins": ["./node_modules/prettier-plugin-astro"]
"plugins": ["./node_modules/prettier-plugin-astro"],
"trailingComma": "es5",
"tabWidth": 2,
"useTabs": true,
"semi": false,
"singleQuote": true,
"bracketSpacing": true
}
+9 -5
View File
@@ -1,8 +1,12 @@
import { defineConfig } from "astro/config";
import netlify from "@astrojs/netlify/functions";
import { defineConfig } from 'astro/config'
import netlify from '@astrojs/netlify/functions'
// https://astro.build/config
import mdx from '@astrojs/mdx'
// https://astro.build/config
export default defineConfig({
output: "server",
adapter: netlify()
});
output: 'server',
adapter: netlify(),
integrations: [mdx()],
})
+1143
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -11,6 +11,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/mdx": "^0.17.0",
"@astrojs/netlify": "^2.1.2",
"@astrojs/rss": "^2.1.0",
"astro": "^2.0.10",
+4 -4
View File
@@ -1,12 +1,12 @@
---
import FormattedDate from "@components/FormattedDate.astro";
import FormattedDate from '@components/FormattedDate.astro'
interface Props {
title: String;
date: String;
title: String
date: String
}
const { title, date } = Astro.props;
const { title, date } = Astro.props
---
<div class="blog-header">
+1 -1
View File
@@ -1,5 +1,5 @@
---
const year = new Date().getFullYear();
const year = new Date().getFullYear()
---
<footer>
+4 -4
View File
@@ -1,11 +1,11 @@
---
import { format, add } from "date-fns";
import { format, add } from 'date-fns'
interface Props {
date: Date;
date: Date
}
const { date } = Astro.props;
const { date } = Astro.props
---
<span>{format(add(new Date(date), { hours: 6 }), "MMM do, y")}</span>
<span>{format(add(new Date(date), { hours: 6 }), 'MMM do, y')}</span>
+5 -5
View File
@@ -1,10 +1,10 @@
---
const { pathname } = Astro.url;
const { pathname } = Astro.url
const navLinks = [
{ label: "Blog", icon: "website-with-texticonImage24px", path: "/" },
{ label: "About", icon: "usericonImage24px", path: "/about/" },
];
{ label: 'Blog', icon: 'website-with-texticonImage24px', path: '/' },
{ label: 'About', icon: 'usericonImage24px', path: '/about/' },
]
---
<header>
@@ -15,7 +15,7 @@ const navLinks = [
navLinks.map((link) => (
<li>
<a
class={pathname === link.path ? "active-nav" : null}
class={pathname === link.path ? 'active-nav' : null}
href={link.path}
>
<img src={`/media/icons/${link.icon}.svg`} />
+5 -8
View File
@@ -1,20 +1,17 @@
---
import BlogHeader from "@components/BlogHeader.astro";
import BlogHeader from '@components/BlogHeader.astro'
interface Props {
post: Object;
post: Object
}
const { post } = Astro.props;
const { data, slug } = post;
const preview = post.body.split("\n")[1];
const { post } = Astro.props
const { data, slug } = post
---
<article class="post-preview">
<div>
<BlogHeader title={post.data.title} date={post.data.pubDate} />
<p>{preview}</p>
<a href={`/posts/${slug}`}>Read More</a>
<a href={`/posts/${slug}`}>Read Post</a>
</div>
</article>
+3 -3
View File
@@ -1,12 +1,12 @@
import { z, defineCollection } from "astro:content";
import { z, defineCollection } from 'astro:content'
const blogCollection = defineCollection({
schema: z.object({
title: z.string(),
pubDate: z.date(),
}),
});
})
export const collections = {
blog: blogCollection,
};
}
+8 -8
View File
@@ -1,16 +1,16 @@
---
export const prerender = true;
import Layout from "@layouts/Layout.astro";
export const prerender = true
import Layout from '@layouts/Layout.astro'
const styles = {
img: {
display: "block",
maxWidth: "300px",
margin: "auto",
marginBottom: "26px",
borderRadius: "200px",
display: 'block',
maxWidth: '300px',
margin: 'auto',
marginBottom: '26px',
borderRadius: '200px',
},
};
}
---
<Layout title="About">
+5 -5
View File
@@ -1,16 +1,16 @@
---
import "@styles/global.css";
import '@styles/global.css'
import Header from "@components/Header.astro";
import Footer from "@components/Footer.astro";
import Header from '@components/Header.astro'
import Footer from '@components/Footer.astro'
export interface Props {
title: string;
title: string
}
const title = Astro.props.frontmatter
? Astro.props.frontmatter.title
: Astro.props.title;
: Astro.props.title
---
<!DOCTYPE html>
+20 -20
View File
@@ -1,27 +1,27 @@
---
import { getCollection } from "astro:content";
const sortParam = Astro.url.search.split("=")[1];
import { getCollection } from 'astro:content'
const sortParam = Astro.url.search.split('=')[1]
import Layout from "@layouts/Layout.astro";
import FormattedDate from "@components/FormattedDate.astro";
import Layout from '@layouts/Layout.astro'
import FormattedDate from '@components/FormattedDate.astro'
const posts = await getCollection("blog");
const posts = await getCollection('blog')
switch (sortParam) {
case "date-des":
case 'date-des':
posts.sort(
(a, b) => Date.parse(b.data.pubDate) - Date.parse(a.data.pubDate)
);
break;
case "date-asc":
)
break
case 'date-asc':
posts.sort(
(a, b) => Date.parse(a.data.pubDate) - Date.parse(b.data.pubDate)
);
break;
case "title":
posts.sort((a, b) => a.data.title - b.data.title);
)
break
case 'title':
posts.sort((a, b) => a.data.title - b.data.title)
default:
break;
break
}
---
@@ -38,7 +38,7 @@ switch (sortParam) {
{
posts.map(({ slug, data }) => (
<div>
<a href={`/posts/${slug}`}>{data.title}</a> -{" "}
<a href={`/posts/${slug}`}>{data.title}</a> -{' '}
<FormattedDate date={data.pubDate} />
</div>
))
@@ -46,15 +46,15 @@ switch (sortParam) {
</Layout>
<script is:inline>
const sort = location.search.split("=")[1];
const sortEl = document.querySelector("#sort-by");
const sort = location.search.split('=')[1]
const sortEl = document.querySelector('#sort-by')
sortEl.value = sort || "title";
sortEl.value = sort || 'title'
sortEl.addEventListener(
"change",
'change',
() => (window.location.href = `/archive?sort=${sortEl.value}`)
);
)
</script>
<style>
+5 -5
View File
@@ -1,11 +1,11 @@
---
export const prerender = true;
import { getCollection } from "astro:content";
export const prerender = true
import { getCollection } from 'astro:content'
import Layout from "@layouts/Layout.astro";
import PostPreview from "@components/PostPreview.astro";
import Layout from '@layouts/Layout.astro'
import PostPreview from '@components/PostPreview.astro'
const posts = await getCollection("blog");
const posts = await getCollection('blog')
---
<Layout title="Home">
+12 -9
View File
@@ -1,23 +1,23 @@
---
export const prerender = true;
import { getCollection } from "astro:content";
export const prerender = true
import { getCollection } from 'astro:content'
import Layout from "@layouts/Layout.astro";
import BlogHeader from "@components/BlogHeader.astro";
import Layout from '@layouts/Layout.astro'
import BlogHeader from '@components/BlogHeader.astro'
export async function getStaticPaths() {
const posts = await getCollection("blog");
const posts = await getCollection('blog')
return posts.map((post) => ({
params: { slug: post.slug },
props: { post },
}));
}))
}
const { post } = Astro.props;
const { post } = Astro.props
const { data } = post;
const { data } = post
const { Content } = await post.render();
const { Content } = await post.render()
---
<Layout title={data.title}>
@@ -34,4 +34,7 @@ const { Content } = await post.render();
display: block;
margin: auto;
}
.no-shadow {
box-shadow: none;
}
</style>
+11 -11
View File
@@ -1,17 +1,17 @@
import rss from "@astrojs/rss";
import { getCollection } from "astro:content";
import sanitizeHtml from "sanitize-html";
import MarkdownIt from "markdown-it";
const parser = new MarkdownIt({ html: true });
import rss from '@astrojs/rss'
import { getCollection } from 'astro:content'
import sanitizeHtml from 'sanitize-html'
import MarkdownIt from 'markdown-it'
const parser = new MarkdownIt({ html: true })
export async function get(context) {
const blog = await getCollection("blog");
console.log(blog);
const blog = await getCollection('blog')
console.log(blog)
return rss({
title: "ghall.blog",
title: 'ghall.blog',
description:
"My personal blog about life, gaming, tech, and whatever else I feel like writing about.",
site: "https://ghall.blog",
'My personal blog about life, gaming, tech, and whatever else I feel like writing about.',
site: 'https://ghall.blog',
items: blog
.sort((a, b) => Date.parse(b.data.pubDate) - Date.parse(a.data.pubDate))
.map((post) => ({
@@ -19,5 +19,5 @@ export async function get(context) {
content: sanitizeHtml(parser.render(post.body)),
...post.data,
})),
});
})
}