Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: format homepage desc to code #1377

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
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: 14 additions & 1 deletion docs/suspensive.org/src/components/HomePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@ import Image from 'next/image'
import { useRouter } from 'nextra/hooks'
import { Link } from 'nextra-theme-docs'

const CodeBlockClassName = 'nextra-code'

const escapeHtml = (text: string) =>
text.replace(/</g, '&lt;').replace(/>/g, '&gt;')

const backtickToCodeBlock = (text: string) =>
text.replace(/`([^`]+)`/g, `<code class="${CodeBlockClassName}">$1</code>`)

const formatCodeBlocks = (desc: string) => backtickToCodeBlock(escapeHtml(desc))

export const HomePage = ({
title,
description,
Expand Down Expand Up @@ -54,7 +64,10 @@ export const HomePage = ({
key={title}
>
<div className="text-xl font-bold">{title}</div>
<p className="text-lg">{desc}</p>
<p
className="text-lg"
dangerouslySetInnerHTML={{ __html: formatCodeBlocks(desc) }}
></p>
</div>
))}
</div>
Expand Down
4 changes: 2 additions & 2 deletions docs/suspensive.org/src/pages/en/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { HomePage, Scrollycoding } from '@/components'
items={[
{
title: 'All Declarative APIs ready',
desc: '<Suspense/>, <ErrorBoundary/>, <ErrorBoundaryGroup/>, etc. are provided. Use them easily without any efforts.',
desc: '`<Suspense/>`, `<ErrorBoundary/>`, `<ErrorBoundaryGroup/>`, etc. are provided. Use them easily without any efforts.',
},
{
title: 'Zero peer dependency, Only React',
desc: "It is simply extensions of react's concepts. Named friendly with originals like just <Suspense/>, <ErrorBoundary/>, <ErrorBoundaryGroup/>.",
desc: "It is simply extensions of react's concepts. Named friendly with originals like just `<Suspense/>`, `<ErrorBoundary/>`, `<ErrorBoundaryGroup/>`.",
},
{
title: 'Suspense in SSR easily',
Expand Down
4 changes: 2 additions & 2 deletions docs/suspensive.org/src/pages/ko/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import { HomePage, Scrollycoding } from '@/components'
items={[
{
title: '모든 선언적 API를 제공',
desc: '<Suspense/>, <ErrorBoundary/>, <ErrorBoundaryGroup/> 등을 제공합니다. 별 다른 노력없이 쉽게 사용할 수 있습니다.',
desc: '`<Suspense/>`, `<ErrorBoundary/>`, `<ErrorBoundaryGroup/>` 등을 제공합니다. 별 다른 노력없이 쉽게 사용할 수 있습니다.',
},
{
title: 'Zero 의존성, 오직 React',
desc: '단순히 React의 개념을 확장한 것입니다. <Suspense/>, <ErrorBoundary/>, <ErrorBoundaryGroup/>와 같은 React 개발자에게 친숙한 이름으로 컴포넌트들을 제공합니다.',
desc: '단순히 React의 개념을 확장한 것입니다. `<Suspense/>`, `<ErrorBoundary/>`, `<ErrorBoundaryGroup/>`와 같은 React 개발자에게 친숙한 이름으로 컴포넌트들을 제공합니다.',
},
{
title: '서버 사이드 렌더링에서도 쉽게',
Expand Down
Loading