chore: remove junk
This commit is contained in:
parent
f6dcc302d4
commit
8f6872f739
96 changed files with 1002 additions and 2485 deletions
|
@ -1,49 +1,51 @@
|
|||
---
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import Container from "@components/Container.astro";
|
||||
import FormattedDate from "@components/FormattedDate.astro";
|
||||
import { readingTime } from "@lib/utils";
|
||||
import BackToPrevious from "@components/BackToPrevious.astro";
|
||||
import PostNavigation from "@components/PostNavigation.astro";
|
||||
import TableOfContents from "@components/TableOfContents.astro";
|
||||
import Giscus from "@components/Giscus.astro";
|
||||
import { type CollectionEntry, getCollection } from 'astro:content'
|
||||
import Layout from '@layouts/Layout.astro'
|
||||
import Container from '@components/Container.astro'
|
||||
import FormattedDate from '@components/FormattedDate.astro'
|
||||
import { readingTime } from '@lib/utils'
|
||||
import BackToPrevious from '@components/BackToPrevious.astro'
|
||||
import PostNavigation from '@components/PostNavigation.astro'
|
||||
import TableOfContents from '@components/TableOfContents.astro'
|
||||
import Giscus from '@components/Giscus.astro'
|
||||
|
||||
export async function getStaticPaths() {
|
||||
const posts = (await getCollection("blog"))
|
||||
const posts = (await getCollection('blog'))
|
||||
.filter((post) => !post.data.draft)
|
||||
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
|
||||
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf())
|
||||
return posts.map((post) => ({
|
||||
params: { slug: post.slug },
|
||||
props: post,
|
||||
}));
|
||||
}))
|
||||
}
|
||||
type Props = CollectionEntry<"blog">;
|
||||
type Props = CollectionEntry<'blog'>
|
||||
|
||||
const posts = (await getCollection("blog"))
|
||||
const posts = (await getCollection('blog'))
|
||||
.filter((post) => !post.data.draft)
|
||||
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
|
||||
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf())
|
||||
|
||||
function getPostIndex(slug: string): number {
|
||||
return posts.findIndex((post) => post.slug === slug);
|
||||
return posts.findIndex((post) => post.slug === slug)
|
||||
}
|
||||
|
||||
function getNextPost(slug: string): Props | null {
|
||||
const postIndex = getPostIndex(slug);
|
||||
return postIndex !== -1 && postIndex < posts.length - 1 ? posts[postIndex + 1] : null;
|
||||
const postIndex = getPostIndex(slug)
|
||||
return postIndex !== -1 && postIndex < posts.length - 1
|
||||
? posts[postIndex + 1]
|
||||
: null
|
||||
}
|
||||
|
||||
function getPrevPost(slug: string): Props | null {
|
||||
const postIndex = getPostIndex(slug);
|
||||
return postIndex > 0 ? posts[postIndex - 1] : null;
|
||||
const postIndex = getPostIndex(slug)
|
||||
return postIndex > 0 ? posts[postIndex - 1] : null
|
||||
}
|
||||
|
||||
const currentPostSlug = Astro.params.slug;
|
||||
const nextPost = getNextPost(currentPostSlug);
|
||||
const prevPost = getPrevPost(currentPostSlug);
|
||||
const currentPostSlug = Astro.params.slug
|
||||
const nextPost = getNextPost(currentPostSlug)
|
||||
const prevPost = getPrevPost(currentPostSlug)
|
||||
|
||||
const post = Astro.props;
|
||||
const { Content, headings } = await post.render();
|
||||
const post = Astro.props
|
||||
const { Content, headings } = await post.render()
|
||||
---
|
||||
|
||||
<Layout title={post.data.title} description={post.data.description}>
|
||||
|
@ -64,21 +66,23 @@ const { Content, headings } = await post.render();
|
|||
<h1 class="animate text-4xl font-semibold text-black dark:text-white">
|
||||
{post.data.title}
|
||||
</h1>
|
||||
<div class="font-base text-sm ">
|
||||
{post.data.tags && post.data.tags.length > 0 ? (
|
||||
post.data.tags.map((tag) => (
|
||||
<div class="inline-block my-1">
|
||||
<a
|
||||
href={`/tags/${tag}`}
|
||||
class="mx-1 rounded-full px-2 py-1 bg-orange-300 hover:bg-cyan-200 dark:bg-orange-500 dark:hover:bg-cyan-500 transition-colors duration-300 ease-in-out"
|
||||
>
|
||||
#{tag}
|
||||
</a>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<span>No tags available</span>
|
||||
)}
|
||||
<div class="font-base text-sm">
|
||||
{
|
||||
post.data.tags && post.data.tags.length > 0 ? (
|
||||
post.data.tags.map((tag) => (
|
||||
<div class="my-1 inline-block">
|
||||
<a
|
||||
href={`/tags/${tag}`}
|
||||
class="mx-1 rounded-full bg-orange-300 px-2 py-1 transition-colors duration-300 ease-in-out hover:bg-cyan-200 dark:bg-orange-500 dark:hover:bg-cyan-500"
|
||||
>
|
||||
#{tag}
|
||||
</a>
|
||||
</div>
|
||||
))
|
||||
) : (
|
||||
<span>No tags available</span>
|
||||
)
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
{headings.length > 0 && <TableOfContents headings={headings} />}
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
---
|
||||
import { type CollectionEntry, getCollection } from "astro:content";
|
||||
import Layout from "@layouts/Layout.astro";
|
||||
import Container from "@components/Container.astro";
|
||||
import ArrowCard from "@components/ArrowCard.astro";
|
||||
import { BLOG } from "@consts";
|
||||
import { type CollectionEntry, getCollection } from 'astro:content'
|
||||
import Layout from '@layouts/Layout.astro'
|
||||
import Container from '@components/Container.astro'
|
||||
import ArrowCard from '@components/ArrowCard.astro'
|
||||
import { BLOG } from '@consts'
|
||||
|
||||
const data = (await getCollection("blog"))
|
||||
const data = (await getCollection('blog'))
|
||||
.filter((post) => !post.data.draft)
|
||||
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf());
|
||||
.sort((a, b) => b.data.date.valueOf() - a.data.date.valueOf())
|
||||
|
||||
type Acc = {
|
||||
[year: string]: CollectionEntry<"blog">[];
|
||||
};
|
||||
[year: string]: CollectionEntry<'blog'>[]
|
||||
}
|
||||
|
||||
const posts = data.reduce((acc: Acc, post) => {
|
||||
const year = post.data.date.getFullYear().toString();
|
||||
const year = post.data.date.getFullYear().toString()
|
||||
if (!acc[year]) {
|
||||
acc[year] = [];
|
||||
acc[year] = []
|
||||
}
|
||||
acc[year].push(post);
|
||||
return acc;
|
||||
}, {});
|
||||
acc[year].push(post)
|
||||
return acc
|
||||
}, {})
|
||||
|
||||
const years = Object.keys(posts).sort((a, b) => parseInt(b) - parseInt(a));
|
||||
const years = Object.keys(posts).sort((a, b) => parseInt(b) - parseInt(a))
|
||||
---
|
||||
|
||||
<Layout title={BLOG.TITLE} description={BLOG.DESCRIPTION}>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue