Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add with-mdx-remote example#16613

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
kodiakhq merged 17 commits intovercel:canaryfromdaneden:with-mdx-remote-example
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
17 commits
Select commitHold shift + click to select a range
fa05082
Add with-mdx-remote example
danedenAug 26, 2020
ed2892a
Add note about conditional custom components
danedenAug 26, 2020
4679aa0
Add clarifying comment to components object
danedenAug 26, 2020
466f862
Add example React component
danedenAug 27, 2020
e44d1d2
Consistently use .jsx extension
danedenAug 27, 2020
6c9e335
Use `as` prop for Link to dynamic routes
danedenAug 27, 2020
944c596
Update readme and add next-remote-watch example
danedenAug 27, 2020
919e469
Remove next.config.js
danedenAug 28, 2020
3a61cb0
Update readme to use `getStaticProps` instead of `getInitialProps`
danedenAug 28, 2020
2f6e129
Remove empty devDependencies
danedenAug 28, 2020
2ae64ff
Improve design for example
danedenAug 28, 2020
0e031ac
Use .js instead of .jsx
danedenAug 28, 2020
bcb948c
Add nicer styles and example content
danedenAug 28, 2020
3d2eaaa
Merge branch 'canary' into with-mdx-remote-example
danedenAug 28, 2020
5e03d7f
Updated readme
lfadesAug 28, 2020
7e80a84
Updated package.json
lfadesAug 29, 2020
ce8ecad
Merge branch 'canary' into with-mdx-remote-example
kodiakhq[bot]Aug 29, 2020
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
PrevPrevious commit
NextNext commit
Add nicer styles and example content
  • Loading branch information
@daneden
daneden committedAug 28, 2020
commitbcb948c26b0fc433e4a9cb48be615473f4a4cbaa
15 changes: 15 additions & 0 deletionsexamples/with-mdx-remote/components/Layout.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -6,9 +6,15 @@ export default function Layout({ children }) {
.wrapper {
max-width: 36rem;
margin: 0 auto;
padding: 1.5rem;
}
`}</style>
<style jsx global>{`
* {
margin: 0;
padding: 0;
}

:root {
--site-color: royalblue;
--divider-color: rgba(0, 0, 0, 0.4);
Expand All@@ -28,6 +34,15 @@ export default function Layout({ children }) {
color: var(--site-color);
text-decoration-color: currentcolor;
}

h1,
p {
margin-bottom: 1.5rem;
}

code {
font-family: 'Menlo';
}
`}</style>
</>
)
Expand Down
15 changes: 14 additions & 1 deletionexamples/with-mdx-remote/components/TestComponent.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
export default function TestComponent({ name = 'world' }) {
return <div>Hello, {name}!</div>
return (
<>
<div>Hello, {name}!</div>
<style jsx>{`
div {
background-color: #111;
border-radius: 0.5em;
color: #fff;
margin-bottom: 1.5em;
padding: 0.5em 0.75em;
}
`}</style>
</>
)
}
22 changes: 20 additions & 2 deletionsexamples/with-mdx-remote/pages/posts/[slug].js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,6 +3,7 @@ import matter from 'gray-matter'
import hydrate from 'next-mdx-remote/hydrate'
import renderToString from 'next-mdx-remote/render-to-string'
import dynamic from 'next/dynamic'
import Head from 'next/head'
import Link from 'next/link'
import path from 'path'
import CustomLink from '../../components/CustomLink'
Expand All@@ -19,6 +20,7 @@ const components = {
// useful for conditionally loading components for certain routes.
// See the notes in README.md for more details.
TestComponent: dynamic(() => import('../../components/TestComponent')),
Head,
}

export default function PostPage({ source, frontMatter }) {
Expand All@@ -32,10 +34,26 @@ export default function PostPage({ source, frontMatter }) {
</Link>
</nav>
</header>
<div className="wrapper">
<div className="post-header">
<h1>{frontMatter.title}</h1>
{content}
{frontMatter.description && (
<p className="description">{frontMatter.description}</p>
)}
</div>
<main>{content}</main>

<style jsx>{`
.post-header h1 {
margin-bottom: 0;
}

.post-header {
margin-bottom: 2rem;
}
.description {
opacity: 0.6;
}
`}</style>
</Layout>
)
}
Expand Down
3 changes: 3 additions & 0 deletionsexamples/with-mdx-remote/posts/example-post.mdx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
---
title: Example Post
description: This frontmatter description will appear below the title
---

This is an example post, with a [link](https://nextjs.org) and a React component:

<TestComponent name="next-mdx-remote" />

The title and description are pulled from the MDX file and processed using `gray-matter`. Additionally, links are rendered using a custom component passed to `next-mdx-remote`.

Go back [home](/).

[8]ページ先頭

©2009-2025 Movatter.jp