Get feed to work again Without any breaking changes

This commit is contained in:
Michal Vanko 2023-01-31 20:34:20 +01:00
parent b3153ae06a
commit 236ac565f7
7 changed files with 25 additions and 25 deletions

View File

@ -7,7 +7,6 @@ import { getBlogListing } from '../../content'
import type { RequestHandler } from './$types' import type { RequestHandler } from './$types'
export const GET = (async ({ params }) => { export const GET = (async ({ params }) => {
console.log('article-params', params)
const handledParams = params.params === 'index' ? '' : params.params const handledParams = params.params === 'index' ? '' : params.params
const { page = 1, pageSize = 7, ...filters } = parseParams(handledParams) const { page = 1, pageSize = 7, ...filters } = parseParams(handledParams)
const paginationParams = getDropTakeFromPageParams( const paginationParams = getDropTakeFromPageParams(

View File

@ -0,0 +1,12 @@
import type { RequestHandler } from '@sveltejs/kit'
import { getFeed } from '../feed'
export const GET = (async ({ setHeaders }) => {
const feed = await getFeed()
setHeaders({
'Content-Type': 'application/json',
'Cache-Control': 'max-age=86400',
})
return new Response(feed.json1())
}) satisfies RequestHandler

View File

@ -1,5 +1,5 @@
import { Feed } from 'feed' import { Feed } from 'feed'
import { getBlogListing } from '../blog/content' import { getBlogListing } from './blog/content'
export async function getFeed() { export async function getFeed() {
const feed = new Feed({ const feed = new Feed({

View File

@ -0,0 +1,12 @@
import type { RequestHandler } from '@sveltejs/kit'
import { getFeed } from '../feed'
export const GET = (async ({ setHeaders }) => {
const feed = await getFeed()
setHeaders({
'Content-Type': 'application/xml',
'Cache-Control': 'max-age=86400',
})
return new Response(feed.rss2())
}) satisfies RequestHandler

View File

@ -1,10 +0,0 @@
import { getFeed } from './_feed'
export async function get() {
const feed = await getFeed()
return {
status: 200,
body: feed.json1(),
}
}

View File

@ -1,13 +0,0 @@
import { getFeed } from './_feed'
export async function get(req, res) {
const feed = await getFeed()
return {
status: 200,
headers: {
'Content-Type': 'application/xml',
},
body: feed.rss2(),
}
}