Bump script ver and refactor md metadata gen
Signed-off-by: Paul W. <lambdapaul@protonmail.com>
This commit is contained in:
@@ -1,49 +0,0 @@
|
||||
import Image from 'next/image';
|
||||
import { parse as URIparse } from 'uri-js';
|
||||
import date from '../lib/date';
|
||||
import style from '../styles/github-profile.module.css';
|
||||
|
||||
function CardRow({label, children}: {label: string, children: JSX.Element | string}) {
|
||||
return !children? <></> : (
|
||||
<div className={style.cardRow}>
|
||||
<span className={style.cardLabel}>{label}</span>
|
||||
<span className={style.cardValue}>{children}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function GitHubProfile({user}: any) {
|
||||
return (<>
|
||||
<div className={style.card}>
|
||||
<div className={style.avatarContainer}>
|
||||
<Image
|
||||
layout='fixed'
|
||||
width={256}
|
||||
height={256}
|
||||
src={user.avatar_url}
|
||||
alt={`${user.login}'s GitHub profile avatar`}
|
||||
/>
|
||||
</div>
|
||||
<div className={style.cardTable}>
|
||||
<CardRow label='Name'>{user.name}</CardRow>
|
||||
<CardRow label='Username'>{user.login}</CardRow>
|
||||
<CardRow label='URL'><a href={user.html_url}>{user.html_url}</a></CardRow>
|
||||
{user.blog && <CardRow label='Blog'>
|
||||
<a href={ !URIparse(user.blog).scheme ? `//${user.blog}`: user.blog}>{user.blog}</a>
|
||||
</CardRow>}
|
||||
<CardRow label='Location'>{user.location}</CardRow>
|
||||
<CardRow label='About'>{user.bio}</CardRow>
|
||||
<CardRow label='Created'>{user.created_at ? date.toRelativeDate(user.created_at) : ''}</CardRow>
|
||||
{user.updated_at && <CardRow label='Last Updated'>{user.updated_at ? date.toRelativeDate(user.updated_at) : ''}</CardRow>}
|
||||
{user.twitter_username && <CardRow label='Twitter'>
|
||||
<a className='link extern blue button'
|
||||
href={`https://twitter.com/${user.twitter_username}`}>
|
||||
@{user.twitter_username}
|
||||
</a>
|
||||
</CardRow>}
|
||||
</div>
|
||||
</div>
|
||||
</>);
|
||||
}
|
||||
|
||||
export default GitHubProfile;
|
||||
@@ -1,12 +1,8 @@
|
||||
import Meta from './meta';
|
||||
import Title from './title';
|
||||
|
||||
type ChildrenType = JSX.Element | Array<ChildrenType>;
|
||||
|
||||
type LayoutProps = {
|
||||
name: string,
|
||||
title?: string,
|
||||
ancestors?: Array<{ name: string, path: string }>
|
||||
children?: ChildrenType,
|
||||
removeContainer?: boolean,
|
||||
};
|
||||
@@ -22,11 +18,10 @@ function Container(props: {children?: ChildrenType, ignore?: boolean}) {
|
||||
function Layout(props : LayoutProps) {
|
||||
return (
|
||||
<>
|
||||
<Meta name={props.name} ancestors={props.ancestors} />
|
||||
<Title title={props.title} name={props.name} ancestors={props.ancestors} />
|
||||
<Title />
|
||||
<Container ignore={props.removeContainer}>{props.children}</Container>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
export default Layout;
|
||||
export default Layout;
|
||||
|
||||
@@ -48,11 +48,6 @@ export function toListItem(record: Record<string, any>): listItem | null {
|
||||
});
|
||||
}
|
||||
|
||||
const s = {
|
||||
"af": 123,
|
||||
"asdf" : 123
|
||||
}
|
||||
|
||||
export function mapChild(
|
||||
obj: listItem | string,
|
||||
level: number,
|
||||
@@ -105,4 +100,4 @@ export function mapChild(
|
||||
</div>
|
||||
</section>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
import Head from 'next/head';
|
||||
|
||||
function Meta({name, ancestors}
|
||||
: {name: string, ancestors?: Array<{ name: string, path: string }> }) {
|
||||
function path(): string {
|
||||
if (!ancestors)
|
||||
return name;
|
||||
|
||||
let path = '';
|
||||
ancestors.forEach((obj) => {
|
||||
path = `${path}${obj.name} /`;
|
||||
});
|
||||
|
||||
return `PaulW.XYZ / ${path} ${name}`;
|
||||
}
|
||||
|
||||
return (
|
||||
<Head>
|
||||
<title>{path()}</title>
|
||||
</Head>
|
||||
);
|
||||
}
|
||||
|
||||
export default Meta;
|
||||
@@ -1,5 +1,5 @@
|
||||
import Link from 'next/link';
|
||||
import Pages from '../public/pages.json';
|
||||
import Pages from '../public/external.json';
|
||||
|
||||
function QuickLinks() {
|
||||
return (
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
import Link from "next/link";
|
||||
import { INoteMeta } from "../lib/slug";
|
||||
import NotesInfo from '../public/notes.json';
|
||||
|
||||
function RecentNotes({ notesMeta }: { notesMeta: INoteMeta[] }) {
|
||||
function RecentNotes() {
|
||||
const notes = Object.entries(NotesInfo);
|
||||
return (
|
||||
<div className='block'>
|
||||
<div className='h2'>Recent Notes</div>
|
||||
{notesMeta?.slice(0, 10)
|
||||
.map((note: any) => {
|
||||
return <Link key={note.slug} href={`/notes/${note.slug}`} className={`button link`}>{note.title}</Link>
|
||||
{notes?.slice(0, 10)
|
||||
.map(([slug, note]: any) => {
|
||||
return <Link key={slug} href={`/notes/${slug}`} className={`button link`}>{note.title}</Link>
|
||||
})
|
||||
}
|
||||
{
|
||||
notesMeta.length > 10 &&
|
||||
notes.length > 10 &&
|
||||
<div>
|
||||
<Link href='/notes' className='h5'>More...</Link>
|
||||
</div>
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
import Link from "next/link";
|
||||
import date from "../lib/date";
|
||||
import { IPostMeta } from "../lib/slug";
|
||||
import style from '../styles/recent-posts.module.css';
|
||||
import PostsInfo from '../public/posts.json';
|
||||
|
||||
function RecentPosts({ postsMeta }: { postsMeta: IPostMeta[] }) {
|
||||
if (!postsMeta.length)
|
||||
function RecentPosts() {
|
||||
const posts = Object.entries(PostsInfo);
|
||||
if (!posts.length)
|
||||
return <></>;
|
||||
return (
|
||||
<div className='block'>
|
||||
<div className='h2'>Recent Posts</div>
|
||||
<div className={style.container}>
|
||||
{postsMeta?.slice(0, 10)
|
||||
.map((post: any) => {
|
||||
{posts?.slice(0, 10)
|
||||
.map(([slug, post]: any) => {
|
||||
return <div className={style.block} key={post.slug}>
|
||||
<span className={style.postDate}>
|
||||
{date.toRelativeDate(new Date(post.created_at))}
|
||||
{date.toRelativeDate(new Date(post.otime))}
|
||||
</span>
|
||||
<div className={style.postTitle}>
|
||||
<Link href={`/posts/${post.slug}`}>
|
||||
<Link href={`/posts/${slug}`}>
|
||||
{post.title}
|
||||
</Link>
|
||||
</div>
|
||||
@@ -25,7 +26,7 @@ function RecentPosts({ postsMeta }: { postsMeta: IPostMeta[] }) {
|
||||
})}
|
||||
</div>
|
||||
{
|
||||
postsMeta.length > 10 &&
|
||||
posts.length > 10 &&
|
||||
<div className={style.more}>
|
||||
<Link href='/posts' className='h5'>More...</Link>
|
||||
</div>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import Link from 'next/link';
|
||||
import { useRouter } from 'next/router';
|
||||
|
||||
import style from '../styles/title.module.css';
|
||||
|
||||
type propsObj = {
|
||||
name: string,
|
||||
title?: string,
|
||||
ancestors?: Array<{ name: string, path: string }>
|
||||
};
|
||||
import SiteMap from '../public/sitemap.json';
|
||||
import Head from 'next/head';
|
||||
import { SiteSubPages } from '../lib/site';
|
||||
|
||||
function createPathElements(ancestors: Array<{ name: string, path: string }>) {
|
||||
let currentPath = '';
|
||||
@@ -21,19 +19,42 @@ function createPathElements(ancestors: Array<{ name: string, path: string }>) {
|
||||
});
|
||||
};
|
||||
|
||||
function Title({ name, title, ancestors }: propsObj) {
|
||||
const pathElements = ancestors && createPathElements(ancestors) || <></>;
|
||||
function Title() {
|
||||
|
||||
const router = useRouter();
|
||||
const pagePath = router.asPath;
|
||||
const splitPath: Array<{ name: string, path: string }> = [];
|
||||
|
||||
let currRoot: SiteSubPages = SiteMap.subpages;
|
||||
let title: string | null = null;
|
||||
if (pagePath !== '/') {
|
||||
const subPaths = pagePath.split('/');
|
||||
for (const p of subPaths.slice(1, subPaths.length)) {
|
||||
splitPath.push({ name: currRoot[p].title, path: p });
|
||||
if (currRoot === undefined
|
||||
|| currRoot[p] === undefined
|
||||
|| currRoot[p].subpages !== undefined)
|
||||
currRoot = currRoot[p].subpages!;
|
||||
}
|
||||
if (splitPath !== undefined && splitPath.length > 0)
|
||||
title = splitPath.pop()!.name;
|
||||
|
||||
}
|
||||
|
||||
const pathElements = splitPath && createPathElements(splitPath) || <></>;
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
<title>{title && `${title} | PaulW.XYZ` || 'PaulW.XYZ'}</title>
|
||||
</Head>
|
||||
<div className={style.container}>
|
||||
<h1 className={style.title}>
|
||||
{title || name}
|
||||
{title || 'PaulW.XYZ'}
|
||||
</h1>
|
||||
</div>
|
||||
<div className={`${style.nav} h1`}>
|
||||
{name
|
||||
? <><Link href='/'>PaulW.XYZ</Link> / {pathElements}{name}</>
|
||||
{title
|
||||
? <><Link href='/'>PaulW.XYZ</Link> / {pathElements}{title}</>
|
||||
: <>PaulW.XYZ /</>}
|
||||
</div>
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user