Skip to content

Commit

Permalink
refactor: enable mdxRs (#2518)
Browse files Browse the repository at this point in the history
  • Loading branch information
ykzts authored Mar 1, 2023
1 parent 17aad18 commit 8d4841e
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 53 deletions.
15 changes: 0 additions & 15 deletions app/(content)/(document)/Link.tsx

This file was deleted.

18 changes: 0 additions & 18 deletions app/(content)/(document)/MarkdownWrapper.tsx

This file was deleted.

3 changes: 0 additions & 3 deletions app/(content)/(document)/about/AboutWrapper.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions app/(content)/(document)/about/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type Metadata } from 'next'
import { title as siteName, twitterAccount } from '@/lib/constants'
import SimpleTitle from '@/ui/SimpleTitle'
import AboutWrapper from './AboutWrapper'
import About from './About.mdx'

const title = '因幡神社とは'

Expand All @@ -26,7 +26,7 @@ export default function Page() {
return (
<>
<SimpleTitle>{title}</SimpleTitle>
<AboutWrapper />
<About />
</>
)
}
7 changes: 1 addition & 6 deletions app/(content)/(document)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { type ReactNode } from 'react'
import MarkdownWrapper from './MarkdownWrapper'
import styles from './layout.module.css'

type Props = {
children: ReactNode
}

export default function DocumentLayout({ children }: Props) {
return (
<MarkdownWrapper>
<div className={styles.markdown}>{children}</div>
</MarkdownWrapper>
)
return <div className={styles.markdown}>{children}</div>
}
3 changes: 0 additions & 3 deletions app/(content)/(document)/privacy/PrivacyWrapper.tsx

This file was deleted.

4 changes: 2 additions & 2 deletions app/(content)/(document)/privacy/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { type Metadata } from 'next'
import { title as siteName, twitterAccount } from '@/lib/constants'
import SimpleTitle from '@/ui/SimpleTitle'
import PrivacyWrapper from './PrivacyWrapper'
import Privacy from './Privacy.mdx'

const title = 'プライバシーポリシー'

Expand All @@ -26,7 +26,7 @@ export default function Page() {
return (
<>
<SimpleTitle>{title}</SimpleTitle>
<PrivacyWrapper />
<Privacy />
</>
)
}
4 changes: 2 additions & 2 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import '@reach/skip-nav/styles.css'
import '@/styles/globals.css'
import { SkipNavLink } from '@reach/skip-nav'
import { Analytics } from '@vercel/analytics/react'
import { type Metadata } from 'next'
import Link from 'next/link'
import { type ReactNode } from 'react'
Expand All @@ -14,7 +15,6 @@ import {
themeColor,
twitterAccount
} from '@/lib/constants'
import AnalyticsWrapper from './AnalyticsWrapper'
import Background from './Background'
import Menu from './Menu'
import styles from './layout.module.css'
Expand Down Expand Up @@ -116,7 +116,7 @@ export default function RootLayout({ children }: Props) {

<Background />

<AnalyticsWrapper />
<Analytics />
</body>
</html>
)
Expand Down
15 changes: 15 additions & 0 deletions mdx-components.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { type MDXComponents } from 'mdx/types'
import Link from 'next/link'

export function useMDXComponents(components: MDXComponents): MDXComponents {
return {
a: ({ href, ref: _ref, ...props }) => {
if (!href || /https?:\/\//.test(href)) {
return <a href={href} {...props} />
}

return <Link href={href} {...props} />
},
...components
}
}
4 changes: 2 additions & 2 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import remarkGfm from 'remark-gfm'

const withMDX = nextMDX({
options: {
jsx: true,
rehypePlugins: [
[
rehypeExternalLinks,
Expand Down Expand Up @@ -33,7 +32,8 @@ const nextConfig = {
dirs: ['__mocks__', 'app', 'lib', 'ui']
},
experimental: {
appDir: true
appDir: true,
mdxRs: true
},
async headers() {
return [
Expand Down

0 comments on commit 8d4841e

Please sign in to comment.