[site/MDX,slug][m]: added 'Edit this page' option

This commit is contained in:
olayway 2022-05-12 12:05:35 +02:00
parent 979815a7ce
commit eb16e1ba4b
4 changed files with 5911 additions and 143 deletions

View File

@ -7,9 +7,9 @@ const components = {
p: Paragraph p: Paragraph
} }
export default function MdxPage({ children }) { export default function MdxPage({ children, editUrl }) {
const { Component, frontmatter } = children const { Component, frontmatter } = children
let podcastEmbed let podcastEmbed
if (frontmatter.podcast && frontmatter.podcast.includes("life-itself")) { if (frontmatter.podcast && frontmatter.podcast.includes("life-itself")) {
@ -24,7 +24,7 @@ export default function MdxPage({ children }) {
return ( return (
<article className="prose dark:prose-invert mx-auto p-6"> <article className="prose dark:prose-invert mx-auto p-6">
<header> <header>
<div className="mb-6"> <div className="my-6">
{frontmatter.title && <h1 className="mb-0">{frontmatter.title}</h1>} {frontmatter.title && <h1 className="mb-0">{frontmatter.title}</h1>}
{frontmatter.authors && ( {frontmatter.authors && (
<div className="-mt-6"> <div className="-mt-6">
@ -74,7 +74,20 @@ export default function MdxPage({ children }) {
</div> </div>
</header> </header>
<main> <main>
<Component components={components} /> <div className="my-6">
<Component components={components} />
</div>
{editUrl && (
<div className='mt-12 mb-6'>
<a className="flex no-underline font-semibold text-yellow-li" href={editUrl} target="_blank">
Edit this page
<span className="mx-1">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
<path stroke-linecap="round" stroke-linejoin="round" d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" />
</svg>
</span>
</a>
</div>)}
</main> </main>
</article> </article>
); );

View File

@ -3,6 +3,8 @@ import Logo from "../public/img/life-itself-logo.svg"
const siteConfig = { const siteConfig = {
title: "Making Sense of Crypto and Web3", title: "Making Sense of Crypto and Web3",
url: "https://web3.lifeitself.us", url: "https://web3.lifeitself.us",
repoRoot: "https://github.com/life-itself/web3",
repoEditPath: "/edit/main/",
tagline: "", tagline: "",
description: description:
"Introductions to key concepts and ideas in crypto and web3. Plus in-depth evaluation of its potential impact.", "Introductions to key concepts and ideas in crypto and web3. Plus in-depth evaluation of its potential impact.",

6024
site/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -25,6 +25,11 @@ export default function Page({ body, ...rest }) {
const title = children.frontmatter.title ?? titleFromUrl const title = children.frontmatter.title ?? titleFromUrl
const imageUrl = siteConfig.url + children.frontmatter.image const imageUrl = siteConfig.url + children.frontmatter.image
// enable editing content only for claims, concepts, and guide for now
const editUrl = ['claims', 'concepts', 'guide'].includes(rest._raw.sourceFileDir)
? siteConfig.repoRoot + siteConfig.repoEditPath + rest._raw.sourceFilePath
: null
return ( return (
<> <>
@ -45,7 +50,7 @@ export default function Page({ body, ...rest }) {
], ],
}} }}
/> />
<MdxPage children={children} /> <MdxPage children={children} editUrl={editUrl} />
</> </>
); );
} }