Typescript support

This commit is contained in:
2020-09-26 14:49:58 +02:00
parent 57ed783083
commit dcfc3eccc2
22 changed files with 3132 additions and 1264 deletions

View File

@ -25,14 +25,16 @@ export async function getFeed() {
})
const blogListing = await getBlogListing()
blogListing.forEach(post => {
blogListing.forEach((post) => {
feed.addItem({
title: post.title,
id: `https://michalvanko.dev/blog/${post.slug}`,
link: `https://michalvanko.dev/blog/${post.slug}`,
description: post.preview,
date: post.date,
image: post.thumbnail ? `https://michalvanko.dev/${post.thumbnail}` : undefined,
date: new Date(post.date),
image: post.thumbnail
? `https://michalvanko.dev/${post.thumbnail}`
: undefined,
})
})
return feed

View File

@ -1,11 +1,10 @@
import { getFeed } from './_feed'
export async function get(req, res) {
const feed = await getFeed()
const feed = await getFeed()
res.writeHead(200, {
'Content-Type': 'application/json',
})
res.end(feed.json1())
}

View File

@ -1,11 +1,10 @@
import { getFeed } from './_feed'
export async function get(req, res) {
const feed = await getFeed()
const feed = await getFeed()
res.writeHead(200, {
'Content-Type': 'application/xml',
})
res.end(feed.rss2())
}