Format literally everything

This commit is contained in:
Cassidy Williams
2022-10-23 23:26:41 -05:00
parent ff9f16105e
commit 0d4e70c5ee
45 changed files with 11569 additions and 11706 deletions

View File

@@ -1,32 +1,32 @@
---
import BaseHead from '../components/BaseHead.astro';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import RandomPosts from '../components/RandomPosts.astro';
import ColorScript from '../components/ColorScript.astro';
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
import { Content as About } from './about.md';
import BaseHead from "../components/BaseHead.astro";
import Header from "../components/Header.astro";
import Footer from "../components/Footer.astro";
import RandomPosts from "../components/RandomPosts.astro";
import ColorScript from "../components/ColorScript.astro";
import { SITE_TITLE, SITE_DESCRIPTION } from "../config";
import { Content as About } from "./about.md";
const posts = (await Astro.glob('../posts/*.{md,mdx}'));
const posts = await Astro.glob("../posts/*.{md,mdx}");
// Get tags from all posts
const getTags = posts.map((post) => {
const postTags = post.frontmatter.tags;
let allTags = []
const getTags = posts
.map((post) => {
const postTags = post.frontmatter.tags;
let allTags = [];
if (postTags.length > 0) {
postTags.forEach((tag) => {
if (allTags.indexOf(tag) === -1) {
allTags.push(tag);
}
});
}
return allTags;
}).flat(1);
if (postTags.length > 0) {
postTags.forEach((tag) => {
if (allTags.indexOf(tag) === -1) {
allTags.push(tag);
}
});
}
return allTags;
})
.flat(1);
// Make the tags unique
let tags = [...new Set(getTags)];
---
<!DOCTYPE html>
@@ -44,9 +44,17 @@ let tags = [...new Set(getTags)];
<h3>View posts by tag</h3>
<p>
{tags && tags.map(tag => (
<><a class="tag-home" href={`/tag/${tag}`}>#{tag}</a>{` `}</>
))}
{
tags &&
tags.map((tag) => (
<>
<a class="tag" href={`/tag/${tag}`}>
#{tag}
</a>
{` `}
</>
))
}
</p>
</main>
<Footer />

View File

@@ -1,23 +1,22 @@
---
// Credit to @rachsmithcodes for this function
export async function getStaticPaths() {
let posts = await Astro.glob(`../../posts/*.md`);
let posts = await Astro.glob(`../../posts/*.md`);
return posts.map((post) => {
return ({
params: { slug: post.frontmatter.slug },
props: { post: post },
})
});
return posts.map((post) => {
return {
params: { slug: post.frontmatter.slug },
props: { post: post },
};
});
}
const { post } = Astro.props;
const {
Content,
frontmatter: { title, added, updated, tags, excerpt },
Content,
frontmatter: { title, added, updated, tags, excerpt },
} = post;
---
<Content />

View File

@@ -1,15 +1,17 @@
---
import BaseHead from '../components/BaseHead.astro';
import Header from '../components/Header.astro';
import Footer from '../components/Footer.astro';
import Post from '../components/Post.astro';
import ColorScript from '../components/ColorScript.astro';
import BaseHead from "../components/BaseHead.astro";
import Header from "../components/Header.astro";
import Footer from "../components/Footer.astro";
import Post from "../components/Post.astro";
import ColorScript from "../components/ColorScript.astro";
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
import { SITE_TITLE, SITE_DESCRIPTION } from "../config";
// Use Astro.glob() to fetch all posts, and then sort them by date.
const posts = (await Astro.glob('../posts/*.{md,mdx}')).sort(
(a, b) => new Date(b.frontmatter.added).valueOf() - new Date(a.frontmatter.added).valueOf()
const posts = (await Astro.glob("../posts/*.{md,mdx}")).sort(
(a, b) =>
new Date(b.frontmatter.added).valueOf() -
new Date(a.frontmatter.added).valueOf()
);
---
@@ -28,11 +30,15 @@ const posts = (await Astro.glob('../posts/*.{md,mdx}')).sort(
<main>
<content>
<ul>
{posts.map(
({url, frontmatter: { description, slug, title, tags, added: date }}) => (
<Post {url} {description} {date} {slug} {title} {tags} />
))}
</ul>
{
posts.map(
({
url,
frontmatter: { description, slug, title, tags, added: date },
}) => <Post {url} {description} {date} {slug} {title} {tags} />
)
}
</ul>
</content>
<Footer />
</main>

View File

@@ -1,10 +1,10 @@
import rss from '@astrojs/rss';
import { SITE_TITLE, SITE_DESCRIPTION } from '../config';
import rss from "@astrojs/rss";
import { SITE_TITLE, SITE_DESCRIPTION } from "../config";
export const get = () =>
rss({
title: SITE_TITLE,
description: SITE_DESCRIPTION,
site: import.meta.env.SITE,
items: import.meta.glob('./blog/**/*.md'),
items: import.meta.glob("./blog/**/*.md"),
});

View File

@@ -1,38 +1,38 @@
---
import BaseHead from '../../components/BaseHead.astro';
import Header from '../../components/Header.astro';
import Footer from '../../components/Footer.astro';
import Post from '../../components/Post.astro';
import BaseHead from "../../components/BaseHead.astro";
import Header from "../../components/Header.astro";
import Footer from "../../components/Footer.astro";
import Post from "../../components/Post.astro";
import ColorScript from "../../components/ColorScript.astro";
import { SITE_TITLE, SITE_DESCRIPTION } from '../../config';
import { SITE_TITLE, SITE_DESCRIPTION } from "../../config";
// Credit to @rachsmithcodes for helping out my lil ol brain
export async function getStaticPaths() {
let posts = await Astro.glob(`../../posts/*.md`);
const tags = posts.reduce((allTags, post) => {
const postTags = post.frontmatter.tags;
if (postTags) {
postTags.forEach((tag) => {
if (!allTags[tag]) {
allTags[tag] = [];
}
allTags[tag].push(post);
});
}
return allTags;
}, {});
let posts = await Astro.glob(`../../posts/*.md`);
const tags = posts.reduce((allTags, post) => {
const postTags = post.frontmatter.tags;
if (postTags) {
postTags.forEach((tag) => {
if (!allTags[tag]) {
allTags[tag] = [];
}
allTags[tag].push(post);
});
}
return allTags;
}, {});
return Object.keys(tags).map((t) => {
return ({
params: { tag: t },
props: { tag: tags[t] },
})
});
return Object.keys(tags).map((t) => {
return {
params: { tag: t },
props: { tag: tags[t] },
};
});
}
const { tag } = Astro.props;
const { tag: currentTag } = Astro.params;
---
<!DOCTYPE html>
@@ -49,15 +49,20 @@ const { tag: currentTag } = Astro.params;
<Header />
<main>
<content>
<h3>Posts tagged with "{currentTag}"</h3>
<h3>Posts tagged with "{currentTag}"</h3>
<ul>
{tag.map(
({url, frontmatter: { description, slug, title, tags, added: date }}) => (
<Post {url} {description} {date} {slug} {title} {tags} />
))}
</ul>
{
tag.map(
({
url,
frontmatter: { description, slug, title, tags, added: date },
}) => <Post {url} {description} {date} {slug} {title} {tags} />
)
}
</ul>
</content>
<Footer />
</main>
<ColorScript />
</body>
</html>