-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4863598
commit 8d04fe8
Showing
29 changed files
with
90 additions
and
220 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,5 @@ public/bikes.json | |
.wrangler | ||
.astro | ||
.dev.vars | ||
build/ | ||
build/ | ||
posts/ |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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,13 +1,10 @@ | ||
--- | ||
import { getCollection } from "astro:content" | ||
import { PostLayout, PhotoLayout } from "@layouts" | ||
import { sortPosts } from "@utils" | ||
import { PostService } from "@services" | ||
const entry = (await getCollection("posts")) | ||
.sort((a, b) => sortPosts(a.data, b.data))[0] | ||
const Layout = entry.data.type == "post" ? PostLayout : PhotoLayout | ||
const { Content } = await entry.render() | ||
const service = PostService(Astro.locals.runtime.env.DB) | ||
const post = await service.getLatest() | ||
if (!post) return Astro.redirect("/404") | ||
const Layout = post.type === "post" ? PostLayout : PhotoLayout | ||
--- | ||
<Layout post={entry.data}> | ||
<Content /> | ||
</Layout> | ||
<PostLayout post={post} /> |
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,23 +1,10 @@ | ||
--- | ||
import { getCollection } from "astro:content" | ||
import { PostLayout, PhotoLayout } from "@layouts" | ||
export async function getStaticPaths() { | ||
const entries = await getCollection("posts") | ||
return entries.map(function(entry) { | ||
return { | ||
params: { | ||
slug: entry.slug | ||
}, | ||
props: { | ||
entry | ||
}, | ||
} | ||
}) | ||
} | ||
const { entry } = Astro.props | ||
const { Content } = await entry.render() | ||
const Layout = entry.data.type == "post" ? PostLayout : PhotoLayout | ||
import { PostService } from "@services" | ||
const { slug } = Astro.params | ||
const service = PostService(Astro.locals.runtime.env.DB) | ||
const post = await service.getBySlug(slug!) | ||
if (!post) return Astro.redirect("/404") | ||
--- | ||
<Layout post={entry.data}> | ||
<Content /> | ||
</Layout> | ||
{post.type === "post" ? <PostLayout post={post}/> : <PhotoLayout post={post}/>} |
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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import rss from "@astrojs/rss" | ||
import metadata from "../metadata" | ||
import { PostService } from "@services" | ||
import type { APIContext } from "astro" | ||
|
||
const { description } = metadata | ||
|
||
export async function GET(context: APIContext) { | ||
const service = PostService(context.locals.runtime.env.DB) | ||
const posts = await service.list() | ||
return rss({ | ||
title: context.site!.origin, | ||
description: description, | ||
site: context.site!, | ||
items: posts.map((post) => ({ | ||
title: post.title, | ||
description: post.tags.join(","), | ||
link: `/posts/${post.slug}`, | ||
pubDate: post.published, | ||
}), | ||
) | ||
}) | ||
} |
Oops, something went wrong.