Skip to content

Commit c0db498

Browse files
committed
Added mdx embeds for CodePen, Gist, Tweet, YouTube, Repl, Glitch, CodeSandbox
1 parent bc9415f commit c0db498

File tree

3 files changed

+789
-8
lines changed

3 files changed

+789
-8
lines changed

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,15 @@
2121
"dependencies": {
2222
"@badrap/bar-of-progress": "0.1.2",
2323
"@headlessui/react": "0.3.1",
24+
"@mdx-js/mdx": "1.6.22",
25+
"@mdx-js/react": "1.6.22",
2426
"@tailwindcss/line-clamp": "0.2.0",
2527
"classnames": "2.2.6",
2628
"fauna-schema-migrate": "0.1.10",
2729
"faunadb": "4.1.0",
2830
"luxon": "1.26.0",
2931
"markdown-to-jsx": "7.1.1",
32+
"mdx-embed": "0.0.19",
3033
"next": "10.0.7",
3134
"next-auth": "3.5.0",
3235
"next-themes": "0.0.11",

src/components/Markdown.tsx

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
11
import MarkdownOriginal, { MarkdownToJSX } from 'markdown-to-jsx'
22
import React from 'react'
33
import { A, Pre } from '@/components'
4+
import { CodePen, Gist, Tweet, YouTube, CodeSandbox } from 'mdx-embed'
5+
6+
function Repl({ replLink }: { replLink: string }) {
7+
return (
8+
<>
9+
<iframe
10+
title={`repl-${replLink}`}
11+
height="400px"
12+
width="100%"
13+
src={`https://repl.it/${replLink}?lite=true`}
14+
scrolling="no"
15+
frameBorder="no"
16+
allowTransparency={true}
17+
allowFullScreen={true}
18+
sandbox="allow-forms allow-pointer-lock allow-popups allow-same-origin allow-scripts allow-modals"
19+
/>
20+
</>
21+
)
22+
}
23+
24+
function Glitch({ glitchId }: { glitchId: string }) {
25+
return (
26+
<div
27+
className="glitch-embed-wrap"
28+
style={{ height: '420px', width: '100%' }}
29+
>
30+
<iframe
31+
src={`https://glitch.com/embed/#!/embed/${glitchId}`}
32+
title="probable-stellar-gull on Glitch"
33+
allow="geolocation; microphone; camera; midi; vr; encrypted-media"
34+
style={{ height: '100%', width: '100%', border: 0 }}
35+
></iframe>
36+
</div>
37+
)
38+
}
439

540
export default function Markdown(props: {
641
[key: string]: any
@@ -21,6 +56,27 @@ export default function Markdown(props: {
2156
pre: {
2257
component: Pre,
2358
},
59+
CodePen: {
60+
component: CodePen,
61+
},
62+
Gist: {
63+
component: Gist,
64+
},
65+
Tweet: {
66+
component: Tweet,
67+
},
68+
YouTube: {
69+
component: YouTube,
70+
},
71+
CodeSandbox: {
72+
component: CodeSandbox,
73+
},
74+
Repl: {
75+
component: Repl,
76+
},
77+
Glitch: {
78+
component: Glitch,
79+
},
2480
},
2581
}}
2682
/>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy