@xexr/blog-platform 1.0.16 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lib/mdx.ts CHANGED
@@ -1,3 +1,9 @@
1
+ import type { MDXRemoteOptions } from "next-mdx-remote-client/rsc";
2
+ import rehypeRaw from "rehype-raw";
3
+ import rehypeSanitize, {
4
+ defaultSchema,
5
+ type Options as RehypeSanitizeOptions,
6
+ } from "rehype-sanitize";
1
7
  import remarkGfm from "remark-gfm";
2
8
  import remarkToc from "remark-toc";
3
9
  import rehypeSlug from "rehype-slug";
@@ -9,10 +15,48 @@ interface HastNode {
9
15
  children?: HastNode[];
10
16
  }
11
17
 
12
- export const articleMdxOptions = {
18
+ const globalAttributes = defaultSchema.attributes?.["*"] ?? [];
19
+ const anchorAttributes = defaultSchema.attributes?.a ?? [];
20
+ const imageAttributes = defaultSchema.attributes?.img ?? [];
21
+
22
+ export const articleMdxSanitizeSchema: RehypeSanitizeOptions = {
23
+ ...defaultSchema,
24
+ tagNames: [...(defaultSchema.tagNames ?? []), "figure", "figcaption"],
25
+ attributes: {
26
+ ...defaultSchema.attributes,
27
+ "*": [...globalAttributes, "className"],
28
+ a: [...anchorAttributes, "className", "href", "target", "rel", "title"],
29
+ img: [
30
+ ...imageAttributes,
31
+ "className",
32
+ "src",
33
+ "alt",
34
+ "title",
35
+ "width",
36
+ "height",
37
+ "loading",
38
+ ],
39
+ figure: ["className"],
40
+ figcaption: ["className"],
41
+ span: ["className"],
42
+ },
43
+ protocols: {
44
+ ...defaultSchema.protocols,
45
+ href: ["http", "https", "mailto", "tel"],
46
+ src: ["http", "https"],
47
+ },
48
+ };
49
+
50
+ export const articleMdxOptions: MDXRemoteOptions = {
13
51
  mdxOptions: {
52
+ format: "md",
14
53
  remarkPlugins: [remarkToc, remarkGfm],
15
- rehypePlugins: [rehypeUnwrapStandaloneImages, rehypeSlug],
54
+ rehypePlugins: [
55
+ rehypeRaw,
56
+ [rehypeSanitize, articleMdxSanitizeSchema],
57
+ rehypeUnwrapStandaloneImages,
58
+ rehypeSlug,
59
+ ],
16
60
  },
17
61
  };
18
62
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xexr/blog-platform",
3
- "version": "1.0.16",
3
+ "version": "1.0.17",
4
4
  "description": "SEO-friendly blog platform for Next.js 15 with Bloggy integration",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -70,6 +70,8 @@
70
70
  "lucide-react": "^1.14.0",
71
71
  "next-mdx-remote-client": "^2.1.10",
72
72
  "react-icons": "^5.6.0",
73
+ "rehype-raw": "^7.0.0",
74
+ "rehype-sanitize": "^6.0.0",
73
75
  "rehype-slug": "^6.0.0",
74
76
  "remark-gfm": "^4.0.1",
75
77
  "remark-toc": "^9.0.0",