Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions docs/start/framework/react/guide/rendering-markdown.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,14 @@ Create a React component that renders the processed HTML with custom element han

```tsx
// src/components/Markdown.tsx
import parse, { type HTMLReactParserOptions, Element } from 'html-react-parser'
import { renderMarkdown, type MarkdownResult } from '~/utils/markdown'
import parse, {
type HTMLReactParserOptions,
domToReact,
Element,
} from 'html-react-parser'
import { renderMarkdown, type MarkdownResult } from '@/lib/markdown'
import { useEffect, useState } from 'react'
import { Link } from '@tanstack/react-router'

type MarkdownProps = {
content: string
Expand Down Expand Up @@ -156,6 +162,7 @@ Create a `content-collections.ts` file in your project root:
// content-collections.ts
import { defineCollection, defineConfig } from '@content-collections/core'
import matter from 'gray-matter'
import { z } from 'zod'

function extractFrontMatter(content: string) {
const { data, content: body, excerpt } = matter(content, { excerpt: true })
Expand All @@ -166,9 +173,9 @@ const posts = defineCollection({
name: 'posts',
directory: './src/blog', // Directory containing your .md files
include: '*.md',
schema: (z) => ({
schema: z.object({
title: z.string(),
published: z.string().date(),
published: z.date(),
description: z.string().optional(),
Comment thread
coderabbitai[bot] marked this conversation as resolved.
authors: z.string().array(),
}),
Expand Down
Loading