add Footer, site name

This commit is contained in:
sup39 2022-11-04 22:05:14 +09:00
parent 2c1f2adcf8
commit 2d083d8918
6 changed files with 23 additions and 12 deletions

View file

@ -1,10 +1,10 @@
import config from '#config';
export default function Footer() {
const {startYear: year0, siteAuthor} = config;
const year = new Date().getFullYear();
const {site: {startYear: year0 = year, author} = {}} = config;
return <footer>{siteAuthor &&
<div>Copyright © {year>year0 ? `${year0}-${year}` : year} {siteAuthor} All rights reserved.</div>
return <footer>{author &&
<div>Copyright © {year>year0 ? `${year0}-${year}` : year} {author} All rights reserved.</div>
}</footer>;
}

View file

@ -1,5 +1,6 @@
import Head from 'next/head';
import Nav from './Nav';
import Footer from './Footer';
import MetaInfo from './MetaInfo';
import type {HeadingInfo} from '@sup39/rehype-mdx-export-headings';
@ -27,9 +28,12 @@ export default function MDXRoot({children, data: {pathname}, meta={}, headings}:
</Head>
<Nav pathname={pathname} headings={headings} />
<main>
{h1 ? <h1>{h1}</h1> : <></>}
<MetaInfo data={meta} />
{children}
<article>
{h1 ? <h1>{h1}</h1> : <></>}
<MetaInfo data={meta} />
{children}
</article>
</main>
<Footer />
</>;
}

View file

@ -1,9 +1,11 @@
import Link from 'next/link';
import config from '#config';
export default function NavHeader({onToggleFold}: {onToggleFold?: ()=>void}) {
const {site: {name: siteName = 'supMDX'} = {}} = config;
return <header>
<Link href="/" id="icon-link">
<div style={{fontSize: '1.5em'}}>supMDX</div>
<div style={{fontSize: '1.5em'}}>{siteName}</div>
</Link>
<div className="menu-toggle" onClick={onToggleFold} />
</header>;

View file

@ -7,7 +7,7 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.md,.mdx ."
"lint": "eslint --ext .js,.jsx,.ts,.tsx,.mdx ."
},
"eslintConfig": {
"extends": [

7
supMDX-env.d.ts vendored
View file

@ -1,8 +1,11 @@
declare module '#config' {
import type {NavEntry} from '@/Nav';
type Config = {
startYear: number
siteAuthor?: string
site: {
startYear: number
author: string
name: string
}
metaFields?: {label: string, prop: string}[]
nav: NavEntry[]
};

View file

@ -1,5 +1,7 @@
startYear: 2022
siteAuthor: <Edit author name in supMDX.yml>
site:
startYear: 2022
author: <Edit author name in supMDX.yml>
name: <Site Name>
metaFields:
- {prop: author, label: 'Author: '}
- {prop: createdAt, label: 'Created at '}