From 04b1282f12c0cbb8917074c05594201afa735e22 Mon Sep 17 00:00:00 2001 From: thiloho <123883702+thiloho@users.noreply.github.com> Date: Sun, 27 Apr 2025 00:09:52 +0200 Subject: [PATCH] Turn .mjs files into .ts files --- astro.config.mjs => astro.config.ts | 0 package-lock.json | 37 ++++++++++++++++++++++++++++ package.json | 2 ++ src/pages/{rss.xml.js => rss.xml.ts} | 9 ++++--- 4 files changed, 44 insertions(+), 4 deletions(-) rename astro.config.mjs => astro.config.ts (100%) rename src/pages/{rss.xml.js => rss.xml.ts} (75%) diff --git a/astro.config.mjs b/astro.config.ts similarity index 100% rename from astro.config.mjs rename to astro.config.ts diff --git a/package-lock.json b/package-lock.json index f5fdc05..283e04e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,8 @@ }, "devDependencies": { "@tailwindcss/typography": "0.5.16", + "@types/markdown-it": "^14.1.2", + "@types/sanitize-html": "^2.15.0", "prettier": "3.5.3", "prettier-plugin-astro": "0.14.1" } @@ -1600,6 +1602,24 @@ "@types/unist": "*" } }, + "node_modules/@types/linkify-it": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/@types/linkify-it/-/linkify-it-5.0.0.tgz", + "integrity": "sha512-sVDA58zAw4eWAffKOaQH5/5j3XeayukzDk+ewSsnv3p4yJEZHCCzMDiZM8e0OUrRvmpGZ85jf4yDHkHsgBNr9Q==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/markdown-it": { + "version": "14.1.2", + "resolved": "https://registry.npmjs.org/@types/markdown-it/-/markdown-it-14.1.2.tgz", + "integrity": "sha512-promo4eFwuiW+TfGxhi+0x3czqTYJkG8qB17ZUJiVF10Xm7NLVRSLUsfRTU/6h1e24VvRnXCx+hG7li58lkzog==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/linkify-it": "^5", + "@types/mdurl": "^2" + } + }, "node_modules/@types/mdast": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", @@ -1609,6 +1629,13 @@ "@types/unist": "*" } }, + "node_modules/@types/mdurl": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@types/mdurl/-/mdurl-2.0.0.tgz", + "integrity": "sha512-RGdgjQUZba5p6QEFAVx2OGb8rQDL/cPRG7GiedRzMcJ1tYnUANBncjbSB1NRGwbvjcPeikRABz2nshyPk1bhWg==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/ms": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/@types/ms/-/ms-2.1.0.tgz", @@ -1635,6 +1662,16 @@ "undici-types": "~6.21.0" } }, + "node_modules/@types/sanitize-html": { + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/@types/sanitize-html/-/sanitize-html-2.15.0.tgz", + "integrity": "sha512-71Z6PbYsVKfp4i6Jvr37s5ql6if1Q/iJQT80NbaSi7uGaG8CqBMXP0pk/EsURAOuGdk5IJCd/vnzKrR7S3Txsw==", + "dev": true, + "license": "MIT", + "dependencies": { + "htmlparser2": "^8.0.0" + } + }, "node_modules/@types/unist": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-3.0.3.tgz", diff --git a/package.json b/package.json index 0cc16f9..1f4dac7 100644 --- a/package.json +++ b/package.json @@ -19,6 +19,8 @@ }, "devDependencies": { "@tailwindcss/typography": "0.5.16", + "@types/markdown-it": "^14.1.2", + "@types/sanitize-html": "^2.15.0", "prettier": "3.5.3", "prettier-plugin-astro": "0.14.1" } diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.ts similarity index 75% rename from src/pages/rss.xml.js rename to src/pages/rss.xml.ts index 5e01ff1..ed40819 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.ts @@ -1,10 +1,11 @@ import rss from "@astrojs/rss"; +import type { APIContext } from "astro"; import { getCollection } from "astro:content"; import sanitizeHtml from "sanitize-html"; import MarkdownIt from "markdown-it"; const parser = new MarkdownIt(); -export const GET = async (context) => { +export const GET = async (context: APIContext) => { const blog = await getCollection("blog"); const latestModDate = blog.reduce((latest, article) => { @@ -15,18 +16,18 @@ export const GET = async (context) => { return rss({ title: "Thilo Hohlt's Blog", description: "Thilo Hohlt's Blog", - site: context.site, + site: context.url.origin, trailingSlash: false, xmlns: { atom: "http://www.w3.org/2005/Atom", }, customData: ` ${latestModDate.toUTCString()} - + `, items: blog.map((article) => ({ link: `/blog/${article.id}/`, - content: sanitizeHtml(parser.render(article.body), { + content: sanitizeHtml(parser.render(article.body ?? ""), { allowedTags: sanitizeHtml.defaults.allowedTags.concat(["img"]), }), ...article.data,