-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fixed /blog and /garden * switched to collections in permalink pages * converted rss page
- Loading branch information
Showing
12 changed files
with
149 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,41 @@ | ||
--- | ||
export const prerender = true; | ||
import type { MarkdownInstance, GetStaticPathsResult } from "astro"; | ||
import { type Frontmatter, getPosts, slug } from "~/lib/blog"; | ||
import GithubSlugger from "github-slugger"; | ||
import type { GetStaticPathsResult } from "astro"; | ||
import { type CollectionEntry, getCollection } from "astro:content"; | ||
import BlogPost from "~/layouts/BlogPost.astro"; | ||
export interface Props { | ||
post: MarkdownInstance<Frontmatter>; | ||
post: CollectionEntry<"blog">; | ||
} | ||
export const getStaticPaths = async (): Promise<GetStaticPathsResult> => { | ||
const slugger = new GithubSlugger(); | ||
const posts = await getPosts({ blog: true }); | ||
const posts = (await getCollection("blog")).filter((p) => !p.data.draft); | ||
return posts.map((post) => { | ||
return { | ||
params: { | ||
slug: slug(post, true, slugger), | ||
slug: post.slug, | ||
}, | ||
props: { post }, | ||
}; | ||
}); | ||
}; | ||
const { | ||
post: { Content }, | ||
post: { | ||
data: { title, description, tags, pubDate }, | ||
render, | ||
}, | ||
} = Astro.props; | ||
const rendered = await render(); | ||
const Content = rendered.Content; | ||
const info = { | ||
title, | ||
description, | ||
tags, | ||
pubDate: new Date(pubDate || ""), | ||
}; | ||
--- | ||
|
||
<Content /> | ||
<BlogPost content={info}> | ||
<Content /> | ||
</BlogPost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,63 @@ | ||
--- | ||
export const prerender = true; | ||
import type { MarkdownInstance, GetStaticPathsResult } from "astro"; | ||
import { type Frontmatter, getPosts, slug } from "~/lib/blog"; | ||
import BlogPost from "~/layouts/BlogPost.astro"; | ||
import type { GetStaticPathsResult } from "astro"; | ||
import GithubSlugger from "github-slugger"; | ||
import { getCollection } from "astro:content"; | ||
import type { CollectionEntry } from "astro:content"; | ||
export interface Props { | ||
post: MarkdownInstance<Frontmatter>; | ||
post: CollectionEntry<"blog" | "garden">; | ||
} | ||
export const getStaticPaths = async (): Promise<GetStaticPathsResult> => { | ||
const slugger = new GithubSlugger(); | ||
const posts = await getPosts({ drafts: import.meta.env.DEV }); | ||
return posts.map((post) => { | ||
let date: Date = new Date(post.frontmatter.pubDate); | ||
return { | ||
params: { | ||
slug: slug(post, true, slugger), | ||
date: date.toLocaleDateString().replaceAll("/", "-"), | ||
}, | ||
props: { post }, | ||
}; | ||
}); | ||
const posts = (await getCollection("blog")).filter((p) => !p.data.draft); | ||
const garden = (await getCollection("garden")).filter((p) => !p.data.draft); | ||
let paths = [ | ||
...posts.map((post) => { | ||
let date = new Date(post.data.pubDate || ""); | ||
const slug = slugger.slug(post.id.replace(".md", ""), false); | ||
return { | ||
params: { | ||
slug, | ||
date: date.toLocaleDateString().replaceAll("/", "-"), | ||
}, | ||
props: { post }, | ||
}; | ||
}), | ||
...garden.map((post) => { | ||
let date = new Date(post.data.pubDate || ""); | ||
const slug = slugger.slug(post.id.replace(".md", ""), false); | ||
return { | ||
params: { | ||
slug, | ||
date: date.toLocaleDateString().replaceAll("/", "-"), | ||
}, | ||
props: { post }, | ||
}; | ||
}), | ||
]; | ||
return paths; | ||
}; | ||
const { | ||
post: { Content }, | ||
post: { | ||
render, | ||
data: { title, description, tags, pubDate }, | ||
}, | ||
} = Astro.props; | ||
const { Content } = await render(); | ||
const info = { | ||
title, | ||
tags, | ||
pubDate, | ||
description: description || "", | ||
}; | ||
--- | ||
|
||
<Content /> | ||
<BlogPost content={info}> | ||
<Content /> | ||
</BlogPost> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.