From e803c1ae96a2267ba81b8c94b8ef5a6c2d45e6a2 Mon Sep 17 00:00:00 2001 From: Fabinatix97 Date: Fri, 20 Dec 2024 18:18:55 +0100 Subject: [PATCH] Refactor RSS route to use getQuery for format handling --- server/routes/rss.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/server/routes/rss.ts b/server/routes/rss.ts index a020884..fb941fe 100644 --- a/server/routes/rss.ts +++ b/server/routes/rss.ts @@ -1,9 +1,8 @@ -import { defineEventHandler } from 'h3'; +import { defineEventHandler, getQuery, send } from 'h3'; import { promises as fs } from 'fs'; -import path from 'path'; import { Feed } from 'feed'; +import path from 'path'; import matter from 'gray-matter'; -import { send } from 'h3'; export default defineEventHandler(async (event) => { const contentDir = path.resolve('content/blog'); @@ -59,8 +58,10 @@ export default defineEventHandler(async (event) => { image: `https://www.fabi-online.de/${post.img}` }); } + + const query = getQuery(event); + const format = query.format || 'rss'; - const format = event.context.query.format || 'rss'; let content: string; let contentType: string;