Commit 8d872f6
Changed files (3)
src
src/pages/feed.atom.ts
@@ -2,6 +2,7 @@ import { getCollection } from "astro:content";
import type { APIRoute } from "astro";
import { Feed } from "feed";
import { SITE_CONFIG } from "@/config";
+import { rehypeCleanProperties } from "@/plugins/rehype-clean-properties";
import { rehypeExternalLinks } from "@/plugins/rehype-external-links";
import { rehypeExtractImage } from "@/plugins/rehype-extract-image";
import { renderTypstToHtml } from "@/utils/render-typst";
@@ -30,16 +31,18 @@ export const GET: APIRoute = async () => {
posts.map(async (post) => {
const url = `${siteUrl}/posts/${post.id}`;
if (typeof post.filePath !== "string") return;
+ const renderedContent = await renderTypstToHtml(post.filePath, [
+ rehypeExtractImage,
+ rehypeExternalLinks,
+ rehypeCleanProperties,
+ ]);
feed.addItem({
title: post.data.title,
id: url,
link: url,
description: post.data.desc,
- content: await renderTypstToHtml(post.filePath, [
- rehypeExtractImage,
- rehypeExternalLinks,
- ]),
+ content: renderedContent,
author: [{ name: post.data.author || SITE_CONFIG.author }],
date: post.data.date,
});
src/plugins/rehype-clean-properties.ts
@@ -0,0 +1,18 @@
+import type { RehypePlugin } from "@astrojs/markdown-remark";
+import { visit } from "unist-util-visit";
+
+export const rehypeCleanProperties: RehypePlugin = () => (tree) => {
+ visit(tree, "element", (node) => {
+ if (node.properties.class) {
+ delete node.properties.class;
+ }
+ for (const key of Object.keys(node.properties)) {
+ if (key.startsWith("data-")) {
+ delete node.properties[key];
+ }
+ }
+ if (node.properties.style) {
+ delete node.properties.style;
+ }
+ });
+};
src/plugins/rehype-extract-image.ts
@@ -2,8 +2,8 @@ import type { RehypePlugin } from "@astrojs/markdown-remark";
import { visit } from "unist-util-visit";
import { SITE_CONFIG } from "@/config.js";
import { extractImage } from "@/integrations/extract-image.js";
-import { getBase64ImageInfo } from "../utils/image.js";
import { url } from "@/utils/url.js";
+import { getBase64ImageInfo } from "../utils/image.js";
export const rehypeExtractImage: RehypePlugin = () => (tree) => {
visit(tree, "element", (node) => {