import ReactMarkdown from 'react-markdown'; import SyntaxHighlighter from 'react-syntax-highlighter'; import { monokaiSublime as hlTheme } from 'react-syntax-highlighter/dist/cjs/styles/hljs'; import remarkGfm from 'remark-gfm'; import rehypeRaw from 'rehype-raw'; import remarkDirective from 'remark-directive'; import remarkGithubAdmonitionsToDirectives from 'remark-github-admonitions-to-directives'; import Layout from '../../components/layout'; import readMarkdown from '../../lib/read-markdown'; import { toLocaleString } from '../../lib/date'; import NotesInfo from '../../public/notes.json'; import style from '../../styles/note.module.css'; interface Note { title: string, mtime: string, content?: string, } interface Notes { [slug: string]: Note; } function Markdown({ content }: any) { return {String(children).replace(/\n$/, '')} ) : {children} } }} >{content} } function Note({ note }: { note: Note } ) { return (<> Last updated: {toLocaleString(note.mtime)}
); } export async function getStaticProps({ params }: { params: { note: string } }) { const note: string = params.note; const notesInfo: Notes = NotesInfo; const noteInfo: Note = notesInfo[note]; return { props: { note: { ...noteInfo, content: await readMarkdown('notes', note, true) } } } } export async function getStaticPaths() { return { paths: Object.keys(NotesInfo).map((note: string) => { return { params: { note } } }), fallback: false }; } export default Note;