File tree 3 files changed +11
-22
lines changed
browser/create-template/templates/nextjs-site/src
3 files changed +11
-22
lines changed Original file line number Diff line number Diff line change @@ -13,21 +13,23 @@ import styles from '@/views/Block/TextBlock.module.css';
13
13
*/
14
14
export const MarkdownContent = ( {
15
15
subject,
16
- initialContent ,
16
+ initialValue ,
17
17
} : {
18
18
subject : string ;
19
- initialContent : string | TrustedHTML ;
19
+ initialValue : string ;
20
20
} ) => {
21
21
const resource = useResource < TextBlock > ( subject ) ;
22
22
23
- const matterResult = matter ( resource . props . description ?? '' ) ;
23
+ const matterResult = matter (
24
+ resource . loading ? initialValue : resource . props . description ,
25
+ ) ;
24
26
const processed = remark ( ) . use ( html ) . processSync ( matterResult . content ) ;
25
27
26
28
return (
27
29
< div
28
30
className = { styles . wrapper }
29
31
dangerouslySetInnerHTML = { {
30
- __html : resource . loading ? initialContent : processed . toString ( ) ,
32
+ __html : processed . toString ( ) ,
31
33
} }
32
34
/>
33
35
) ;
Original file line number Diff line number Diff line change 1
1
import { Resource } from '@tomic/react' ;
2
- import { remark } from 'remark' ;
3
- import html from 'remark-html' ;
4
- import matter from 'gray-matter' ;
5
2
import { MarkdownContent } from '@/components/MarkdownContent' ;
3
+ import type { TextBlock as TextBlockType } from '@/ontologies/website' ;
6
4
7
- const TextBlock = ( { resource } : { resource : Resource } ) => {
8
- const matterResult = matter ( resource . props . description ) ;
9
-
10
- const processed = remark ( ) . use ( html ) . processSync ( matterResult . content ) ;
11
-
12
- const initialContent = processed . toString ( ) ;
5
+ const TextBlock = ( { resource } : { resource : Resource < TextBlockType > } ) => {
13
6
return (
14
7
< MarkdownContent
15
8
subject = { resource . subject }
16
- initialContent = { initialContent }
9
+ initialValue = { resource . props . description }
17
10
/>
18
11
) ;
19
12
} ;
Original file line number Diff line number Diff line change 1
1
import Container from '@/components/Layout/Container' ;
2
- import { Blogpost } from '@/ontologies/website' ;
2
+ import type { Blogpost } from '@/ontologies/website' ;
3
3
import { Resource } from '@tomic/lib' ;
4
4
import styles from './BlogpostFullPage.module.css' ;
5
5
import { Image } from '@/components/Image' ;
6
- import matter from 'gray-matter' ;
7
- import html from 'remark-html' ;
8
- import { remark } from 'remark' ;
9
6
import { MarkdownContent } from '@/components/MarkdownContent' ;
10
7
11
8
const formatter = new Intl . DateTimeFormat ( 'default' , {
@@ -16,9 +13,6 @@ const formatter = new Intl.DateTimeFormat('default', {
16
13
17
14
const BlogpostFullPage = ( { resource } : { resource : Resource < Blogpost > } ) => {
18
15
const date = formatter . format ( new Date ( resource . props . publishedAt ) ) ;
19
- const matterResult = matter ( resource . props . description ) ;
20
- const processed = remark ( ) . use ( html ) . processSync ( matterResult . content ) ;
21
- const initialContent = processed . toString ( ) ;
22
16
23
17
return (
24
18
< Container >
@@ -31,7 +25,7 @@ const BlogpostFullPage = ({ resource }: { resource: Resource<Blogpost> }) => {
31
25
< p className = { styles . publishDate } > { date } </ p >
32
26
< MarkdownContent
33
27
subject = { resource . subject }
34
- initialContent = { initialContent }
28
+ initialValue = { resource . props . description }
35
29
/>
36
30
</ div >
37
31
</ div >
You can’t perform that action at this time.
0 commit comments