1
0
Fork 0
mirror of https://github.com/mat-1/matdoesdev.git synced 2025-08-02 14:46:04 +00:00

add content to atom

This commit is contained in:
mat 2024-01-10 17:52:06 -06:00
parent 2aa1861cde
commit aa4f2963b9

View file

@ -1,11 +1,16 @@
import type { RequestHandler } from '@sveltejs/kit'
import type { BlogPostPreview } from '../blog.json/+server'
import type { BlogPost } from '$lib/blog'
import { getPostsUntrimmed } from '../blog.json/preview'
export const prerender = true
export const GET: RequestHandler = async ({ fetch }) => {
const posts = (await fetch('/blog.json').then((r) => r.json())) as BlogPostPreview[]
function item(post: BlogPostPreview) {
const posts = await getPostsUntrimmed()
function item(post: BlogPost) {
const escapedPostHtml = post.html
.replace(/&/g, '&')
.replace(/</g, '&lt;')
.replace(/>/g, '&gt;')
return `
<entry>
<title>${post.title}</title>
@ -13,6 +18,7 @@ export const GET: RequestHandler = async ({ fetch }) => {
<id>https://matdoes.dev/${post.slug}</id>
<published>${post.published}</published>
<updated>${post.published}</updated>
<content type="xhtml">${escapedPostHtml}</content>
</entry>
`
}