File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 1
1
import RSS from 'rss' ;
2
2
import { compiler } from 'markdown-to-jsx' ;
3
- import { renderToString } from 'react-dom/server' ;
4
3
5
4
import { siteUrl } from '~/seo' ;
6
5
import { buildPostData } from '@/core' ;
7
6
8
7
const { postDataList } = buildPostData ( ) ;
9
8
10
9
export async function GET ( ) {
10
+ const ReactDOM = ( await import ( 'react-dom/server' ) ) . default ;
11
+
11
12
const feed = new RSS ( {
12
13
title : 'zhw blog' ,
13
14
description : '记录我的生活' ,
@@ -21,7 +22,7 @@ export async function GET() {
21
22
postDataList . forEach ( ( post ) => {
22
23
const render = ( ) => {
23
24
try {
24
- return renderToString (
25
+ return ReactDOM . renderToString (
25
26
< div >
26
27
{ compiler ( post . text , {
27
28
overrides : {
@@ -56,7 +57,7 @@ export async function GET() {
56
57
</ div > ,
57
58
) ;
58
59
} catch {
59
- return renderToString (
60
+ return ReactDOM . renderToString (
60
61
< p >
61
62
当前内容无法在 RSS 阅读器中正确渲染,请前往:
62
63
< a href = { `${ siteUrl } /notes/${ post . title } ` } > { `${ siteUrl } /notes/${ post . title } ` } </ a >
You can’t perform that action at this time.
0 commit comments