Fix type and other minor issues
This commit is contained in:
@@ -16,6 +16,7 @@ import style from '../../styles/note.module.css';
|
||||
interface Note {
|
||||
title: string,
|
||||
mtime: string,
|
||||
content?: string,
|
||||
}
|
||||
|
||||
interface Notes {
|
||||
@@ -50,7 +51,7 @@ function Markdown({ content }: any) {
|
||||
>{content}</ReactMarkdown>
|
||||
}
|
||||
|
||||
function Note({ note }: any) {
|
||||
function Note({ note }: { note: Note } ) {
|
||||
return (<>
|
||||
<Layout >
|
||||
<span className={style['last-updated']}>
|
||||
@@ -64,7 +65,7 @@ function Note({ note }: any) {
|
||||
);
|
||||
}
|
||||
|
||||
export async function getStaticProps({ params }: any) {
|
||||
export async function getStaticProps({ params }: { params: { note: string } }) {
|
||||
const note: string = params.note;
|
||||
const notesInfo: Notes = NotesInfo;
|
||||
const noteInfo: Note = notesInfo[note];
|
||||
|
||||
@@ -10,13 +10,27 @@ function traverseMap(head: Site, cwd = '', depth = 0) {
|
||||
for (const [slug, info] of Object.entries(head.subpages)) {
|
||||
if (slug === 'sitemap')
|
||||
continue;
|
||||
const path = `${cwd}/${slug}`;
|
||||
const children = (<><dl style={{marginLeft: '3rem'}}> {traverseMap(info, path, depth + 1)}</dl></>);
|
||||
elements.push(<>
|
||||
if (slug.startsWith('http://')) {
|
||||
elements.push(<>
|
||||
<dt>{info.title}</dt>
|
||||
<dd><Link href={path}>paulw.xyz{path}</Link></dd>
|
||||
{children}
|
||||
</>);
|
||||
<dd><Link href={slug}>{slug.substring(7)}</Link></dd>
|
||||
</>);
|
||||
}
|
||||
else if (slug.startsWith('https://')) {
|
||||
elements.push(<>
|
||||
<dt>{info.title}</dt>
|
||||
<dd><Link href={slug}>{slug.substring(8)}</Link></dd>
|
||||
</>);
|
||||
}
|
||||
else {
|
||||
const path = `${cwd}/${slug}`;
|
||||
const children = (<><dl style={{marginLeft: '3rem'}}> {traverseMap(info, path, depth + 1)}</dl></>);
|
||||
elements.push(<>
|
||||
<dt>{info.title}</dt>
|
||||
<dd><Link href={path}>paulw.xyz{path}</Link></dd>
|
||||
{children}
|
||||
</>);
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user