-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
171 additions
and
238 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
--- | ||
title: mdxx-ssg@0.5.0 - mdxx-ssg-cli & mdxx-components | ||
created: 1588952818281 | ||
tags: [mdxx] | ||
--- | ||
|
||
## ChangeLog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { Article, Layout } from "mdxx-ssg-components"; | ||
import { GetStaticProps } from "next"; | ||
import ReactDOMServer from "react-dom/server"; | ||
import pages from "../gen/pages.json"; | ||
import ssgConfig from "../mdxx-ssg.json"; | ||
import Head from "next/head"; | ||
|
||
type Props = { | ||
slug: string; | ||
toc: Array<any>; | ||
history: Array<any>; | ||
frontmatter: { | ||
title: string; | ||
created: number; | ||
tags?: string[]; | ||
}; | ||
tags: string[]; | ||
html: string; | ||
}; | ||
|
||
export const config = { amp: true }; | ||
|
||
export function getStaticPaths() { | ||
const paths = pages.map((page) => { | ||
return `/${page.slug}`; | ||
}); | ||
return { | ||
paths, | ||
fallback: false, | ||
}; | ||
} | ||
|
||
export const getStaticProps: GetStaticProps = async (props) => { | ||
const slug = props.params.slug; | ||
const { frontmatter, default: Doc, toc } = await import( | ||
`../docs/${slug}.mdx` | ||
); | ||
const { default: history } = await import(`../gen/${slug}.history.json`); | ||
return { | ||
props: { | ||
slug, | ||
toc, | ||
history, | ||
tags: frontmatter.tags || [], | ||
frontmatter: frontmatter || { title: slug, created: 0, tags: [] }, | ||
html: ReactDOMServer.renderToStaticMarkup(<Doc amp />), | ||
} as Props, | ||
}; | ||
}; | ||
|
||
export default (props: Props) => ( | ||
<> | ||
<Head> | ||
<title> | ||
{props.frontmatter.title} - {ssgConfig.siteName} | ||
</title> | ||
</Head> | ||
<Layout ssgConfig={ssgConfig}> | ||
<Article | ||
ssgConfig={ssgConfig} | ||
history={props.history} | ||
toc={props.toc} | ||
title={props.frontmatter.title} | ||
tags={props.tags} | ||
> | ||
<div | ||
className="markdown-body" | ||
dangerouslySetInnerHTML={{ __html: props.html }} | ||
/> | ||
</Article> | ||
</Layout> | ||
</> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import Head from "next/head"; | ||
import { Layout, TagPage } from "mdxx-ssg-components"; | ||
import { GetStaticProps } from "next"; | ||
import ssgConfig from "../../mdxx-ssg.json"; | ||
import tagmap from "../../gen/tagmap.json"; | ||
|
||
export const config = { amp: true }; | ||
|
||
export function getStaticPaths() { | ||
const paths = Object.keys(tagmap).map((tag) => { | ||
return `/tags/${tag}`; | ||
}); | ||
return { | ||
paths, | ||
fallback: false, | ||
}; | ||
} | ||
|
||
type Props = { | ||
tagName: string; | ||
pages: Array<{ title: string; slug: string }>; | ||
}; | ||
|
||
export const getStaticProps: GetStaticProps = async (props) => { | ||
const tag = props.params.tag; | ||
return { | ||
props: { | ||
tagName: tag, | ||
pages: tagmap[tag as any], | ||
} as Props, | ||
}; | ||
}; | ||
|
||
export default (props: Props) => { | ||
return ( | ||
<> | ||
<Head> | ||
<title> | ||
{props.tagName} - {ssgConfig.siteName} | ||
</title> | ||
</Head> | ||
<Layout ssgConfig={ssgConfig}> | ||
<TagPage tagName={props.tagName} pages={props.pages} /> | ||
</Layout> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.