File tree Expand file tree Collapse file tree 3 files changed +11
-22
lines changed
browser/create-template/templates/nextjs-site/src Expand file tree Collapse file tree 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';
1313 */
1414export const MarkdownContent = ( {
1515 subject,
16- initialContent ,
16+ initialValue ,
1717} : {
1818 subject : string ;
19- initialContent : string | TrustedHTML ;
19+ initialValue : string ;
2020} ) => {
2121 const resource = useResource < TextBlock > ( subject ) ;
2222
23- const matterResult = matter ( resource . props . description ?? '' ) ;
23+ const matterResult = matter (
24+ resource . loading ? initialValue : resource . props . description ,
25+ ) ;
2426 const processed = remark ( ) . use ( html ) . processSync ( matterResult . content ) ;
2527
2628 return (
2729 < div
2830 className = { styles . wrapper }
2931 dangerouslySetInnerHTML = { {
30- __html : resource . loading ? initialContent : processed . toString ( ) ,
32+ __html : processed . toString ( ) ,
3133 } }
3234 />
3335 ) ;
Original file line number Diff line number Diff line change 11import { Resource } from '@tomic/react' ;
2- import { remark } from 'remark' ;
3- import html from 'remark-html' ;
4- import matter from 'gray-matter' ;
52import { MarkdownContent } from '@/components/MarkdownContent' ;
3+ import type { TextBlock as TextBlockType } from '@/ontologies/website' ;
64
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 > } ) => {
136 return (
147 < MarkdownContent
158 subject = { resource . subject }
16- initialContent = { initialContent }
9+ initialValue = { resource . props . description }
1710 />
1811 ) ;
1912} ;
Original file line number Diff line number Diff line change 11import Container from '@/components/Layout/Container' ;
2- import { Blogpost } from '@/ontologies/website' ;
2+ import type { Blogpost } from '@/ontologies/website' ;
33import { Resource } from '@tomic/lib' ;
44import styles from './BlogpostFullPage.module.css' ;
55import { Image } from '@/components/Image' ;
6- import matter from 'gray-matter' ;
7- import html from 'remark-html' ;
8- import { remark } from 'remark' ;
96import { MarkdownContent } from '@/components/MarkdownContent' ;
107
118const formatter = new Intl . DateTimeFormat ( 'default' , {
@@ -16,9 +13,6 @@ const formatter = new Intl.DateTimeFormat('default', {
1613
1714const BlogpostFullPage = ( { resource } : { resource : Resource < Blogpost > } ) => {
1815 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 ( ) ;
2216
2317 return (
2418 < Container >
@@ -31,7 +25,7 @@ const BlogpostFullPage = ({ resource }: { resource: Resource<Blogpost> }) => {
3125 < p className = { styles . publishDate } > { date } </ p >
3226 < MarkdownContent
3327 subject = { resource . subject }
34- initialContent = { initialContent }
28+ initialValue = { resource . props . description }
3529 />
3630 </ div >
3731 </ div >
You can’t perform that action at this time.
0 commit comments