Bump script ver and refactor md metadata gen

Signed-off-by: Paul W. <lambdapaul@protonmail.com>
This commit is contained in:
2023-10-30 00:18:38 -04:00
parent b5ca20b93d
commit 35d56f5cde
38 changed files with 412 additions and 8679 deletions

View File

@@ -3,7 +3,9 @@ import Layout from '../components/layout';
function NotFoundPage() {
return (
<Layout title='Page Not Found' name='... ??? / 404: Not Found'>
<Layout
// title='Page Not Found' name='... ??? / 404: Not Found'
>
<section className='block text center'>
<h1>Error 404</h1>
<p>

View File

@@ -3,22 +3,18 @@ import ReactMarkdown from 'react-markdown';
import ReadmeMd from '../README.md';
import License from '../LICENSE.txt';
import Layout from '../components/layout';
import GitHubProfile from '../components/github-profile';
function AboutPage({usr}: any) {
function AboutPage() {
return (
<Layout name='About' title='About PaulW.XYZ'>
<Layout >
<section className='block'>
<p>This is a personal website written by <a href='https://github.com/LambdaPaul'>@LambdaPaul</a>.</p>
<p>Why did I write this?
I do not really know, at least the content I put here.
I wanted a place on the web where I wanted to put everything I think is worth looking at some point in the future.
It seems wise to have things up here even though they may not be worthwhile, as many things ultimately are not.</p>
I do not really know, at least the content I put here.
I wanted a place on the web where I wanted to put everything I think is worth looking at some point in the future.
It seems wise to have things up here even though they may not be worthwhile, as many things ultimately are not.</p>
<p>Got any questions, concerns, or issues? Contact me via email: <code>lambdapaul [at] pm [dot] me</code>.</p>
</section>
<section className='block'>
{usr && <GitHubProfile user={usr} />}
</section>
<hr />
<section className='block'>
<p>Source for this site is available at <a className='button link extern blue' href='https://github.com/LambdaPaul/www'>GitHub / LambdaPaul / www</a></p>
@@ -38,16 +34,4 @@ function AboutPage({usr}: any) {
);
}
export async function getStaticProps() {
try {
const res = await fetch('https://api.github.com/users/lambdapaul');
const usr = await res.json();
return {
props: { usr }
};
} catch (e) {
return {props: {}}
}
}
export default AboutPage;

View File

@@ -4,36 +4,30 @@ import Layout from '../components/layout';
import QuickLinks from '../components/quick-links';
import RecentNotes from '../components/recent-notes';
import RecentPosts from '../components/recent-posts';
import { getNotesMeta, getPostsMeta, INoteMeta, IPostMeta } from '../lib/slug';
import RootInfo from '../public/home.json';
function Nav() {
const nav = { 'Posts': '/posts', 'Notes': '/notes', 'About': '/about', };
const nav = RootInfo;
return (
<div className='block' style={{ textAlign: 'center' }}>
{
Object.entries(nav).map(([k, v], i) => {
return <Link key={i} href={v} className='button green'>{k}</Link>
Object.entries(nav).map(([slug, info], i) => {
return <Link key={i} href={slug} className='button green'>{info.title}</Link>
})
}
</div>
)
}
function HomePage({ postsMeta, notesMeta }: { postsMeta: IPostMeta[], notesMeta: INoteMeta[] }) {
function HomePage() {
return (
<Layout name='' title='PaulW.XYZ'>
<Layout>
<Nav />
<QuickLinks />
<RecentNotes notesMeta={notesMeta} />
<RecentPosts postsMeta={postsMeta} />
<RecentNotes />
<RecentPosts />
</Layout>
)
}
export async function getStaticProps() {
return {
props: { postsMeta: getPostsMeta(), notesMeta: getNotesMeta() }
};
}
export default HomePage;

View File

@@ -1,12 +1,23 @@
import Layout from '../../components/layout';
import { getAllNotes, getNote } from '../../lib/slug';
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 readMarkdown from '../../lib/read-markdown';
function Markdown({content}: any) {
import NotesInfo from '../../public/notes.json';
interface Note {
title: string,
mtime: string,
}
interface Notes {
[slug: string]: Note;
}
function Markdown({ content }: any) {
return <ReactMarkdown
remarkPlugins={[remarkGfm]}
rehypePlugins={[rehypeRaw]}
@@ -36,7 +47,7 @@ function Markdown({content}: any) {
function Note({ note }: any) {
return (<>
<Layout name={note.title} title={note.title} ancestors={[{ name: 'Notes', path: 'notes' }]}>
<Layout >
<section className='block'>
<Markdown content={note.content} />
</section>
@@ -46,20 +57,26 @@ function Note({ note }: any) {
}
export async function getStaticProps({ params }: any) {
const note = getNote(params.note);
const note: string = params.note;
const notesInfo: Notes = NotesInfo;
const noteInfo: Note = notesInfo[note];
return {
props: { note }
};
props: {
note: {
...noteInfo,
content: await readMarkdown('notes', note, true)
}
}
}
}
export async function getStaticPaths() {
const notes = getAllNotes();
return {
paths: notes.map((note: any) => {
paths: Object.keys(NotesInfo).map((note: string) => {
return {
params: {
note: note.slug
note
}
}
}),

View File

@@ -1,36 +1,40 @@
import Link from 'next/link';
import Layout from '../../components/layout';
import date from '../../lib/date';
import { getNotesMeta, INoteMeta } from '../../lib/slug';
function NotesPage({ notesMeta }: { notesMeta: INoteMeta[] }) {
import date from '../../lib/date';
import NotesInfo from '../../public/notes.json';
function NoteEntry(props: { path: string, note: { title: string, mtime: string } }) {
return (
<Layout name='Notes'>
<table>
<tr>
<td style={{ flex: '1 0 50%' }}>
<Link href={props.path}>
{props.note.title}
</Link>
</td>
<td style={{ fontStyle: 'italic' }}>
{props.note.mtime && date.toRelativeDate(new Date(props.note.mtime))}
</td>
</tr>
);
}
function NotesPage() {
const notes = Object.entries(NotesInfo);
return (
<Layout>
{!notes || notes.length === 0 && <>No notes found</> || <table>
<tbody>
{notesMeta && notesMeta.map((note: INoteMeta, i) => {
return (
<tr key={i}>
<td style={{flex: '1 0 50%'}}>
<Link href={`/notes/${note.slug}`}>
{note.title}
</Link>
</td>
<td style={{fontStyle: 'italic'}}>
{note.last_updated && date.toRelativeDate(new Date(note.last_updated))}
</td>
</tr>
)})}
{notes.map(([slug, note]: any, i: number) => {
return <NoteEntry path={`/notes/${slug}`} note={note} key={i} />
})}
</tbody>
</table>
</table>}
</Layout>
)
}
export async function getStaticProps() {
return {
props: { notesMeta: getNotesMeta() }
};
}
export default NotesPage;
export default NotesPage;

View File

@@ -1,16 +1,28 @@
import Layout from '../../components/layout';
import { getAllPosts, getPost } from '../../lib/slug';
import ReactMarkdown from 'react-markdown';
import style from '../../styles/post.module.css';
import PostsInfo from '../../public/posts.json';
import readMarkdown from '../../lib/read-markdown';
function Post({ post }: any) { // eh
interface Post {
title: string;
mtime: string;
otime?: string;
}
interface Posts {
[slug: string]: Post
}
function Post({ post }: { post: Post & { content: string, cover?: string } }) {
return (<>
<Layout removeContainer={true} name={post.title} title={post.title} ancestors={[{ name: 'Posts', path: 'posts' }]}>
{<div className={style.imageBlock}
style={{ backgroundImage:
post.cover ?
`url(/assets/images/${post.cover})` :
'linear-gradient(to bottom right, #565a0f, #08432c 15%, rgb(5, 39, 10) 40%, rgb(0, 22, 46) 80%)'
<Layout removeContainer={true} >
{<div className={style.imageBlock}
style={{
backgroundImage:
post.cover ?
`url(/assets/images/${post.cover})` :
'linear-gradient(to bottom right, #565a0f, #08432c 15%, rgb(5, 39, 10) 40%, rgb(0, 22, 46) 80%)'
}}></div>}
<div className={style.spacer}></div>
<section className={`${style.block} block`}>
@@ -25,20 +37,24 @@ function Post({ post }: any) { // eh
}
export async function getStaticProps({ params }: any) {
const post = getPost(params.post);
const postsInfo: Posts = PostsInfo;
const post: Post = postsInfo[params.post];
return {
props: { post }
};
props: {
post: {
...post,
content: await readMarkdown('posts', params.post, true)
}
}
}
}
export async function getStaticPaths() {
const posts = getAllPosts();
return {
paths: posts.map((post: any) => {
paths: Object.keys(PostsInfo).map((post: string) => {
return {
params: {
post: post.slug
post
}
}
}),

View File

@@ -1,47 +1,53 @@
import Link from 'next/link';
import Layout from '../../components/layout';
import date from '../../lib/date';
import { getPostsMeta, IPostMeta } from '../../lib/slug';
import PostsInfo from '../../public/posts.json';
function PostsPage({ postsMeta }: { postsMeta: IPostMeta[] }) {
return (
<Layout name='Posts'>
<table>
<tbody>
{
postsMeta.length &&
postsMeta.map((post: IPostMeta, i) => {
return <tr key={i} style={{alignItems: 'center'}}>
<td style={{display: 'inline-block', textAlign: 'right', fontSize: '0.9rem'}}>
<div style={{fontStyle: 'italics', fontSize: '.8rem'}}>{
post.last_updated && `updated ${date.toRelativeDate(new Date(post.last_updated))}`
}</div>
<div>{ date.toRelativeDate(new Date(post.created_at)) }</div>
</td>
<td style={{
flex: '1 1 60%',
alignItems: 'center',
fontFamily: `'EB Garamond', 'Garamond', 'Times New Roman', Times, serif`}}>
<Link href={`/posts/${post.slug}`} style={{textDecoration: 'none'}}>{post.title}</Link>
</td>
</tr>
}) ||
<div className='text center'>
<div>**crickets**</div>
<div>No posts found...</div>
<div><Link href='/' className='link button green back'>Go Home</Link></div>
</div>
}
</tbody>
</table>
function PostsPage() {
return (
<Layout>
{Object.keys(PostsInfo).length && <Posts /> || <NoPosts />}
</Layout>
)
}
export async function getStaticProps() {
return {
props: { postsMeta: getPostsMeta() }
};
function NoPosts() {
return (<><div className='text center'>
<div>**crickets**</div>
<div>No posts found...</div>
<div><Link href='/' className='link button green back'>Go Home</Link></div>
</div></>);
}
function Posts() {
const posts = Object.entries(PostsInfo);
return (
<>
<table>
<tbody>
{
posts.map(([slug, post]: any, i: number) => {
return <tr key={i} style={{ alignItems: 'center' }}>
<td style={{ display: 'inline-block', textAlign: 'right', fontSize: '0.9rem' }}>
<div style={{ fontStyle: 'italics', fontSize: '.8rem' }}>{
post.mtime && `Updated ${date.toRelativeDate(new Date(post.mtime))}`
}</div>
<div>{date.toRelativeDate(new Date(post.otime))}</div>
</td>
<td style={{
flex: '1 1 60%',
alignItems: 'center',
fontFamily: `'EB Garamond', 'Garamond', 'Times New Roman', Times, serif`
}}>
<Link href={`/posts/${slug}`} style={{ textDecoration: 'none' }}>{post.title}</Link>
</td>
</tr>
})}
</tbody>
</table>
</>
)
}
export default PostsPage;

31
pages/sitemap.tsx Normal file
View File

@@ -0,0 +1,31 @@
import Link from 'next/link';
import Layout from '../components/layout';
import { Site } from '../lib/site';
import SiteMap from '../public/sitemap.json';
function traverseMap(head: Site, cwd = '', depth = 0) {
if (head.subpages === undefined)
return [];
let elements = [];
for (const [slug, info] of Object.entries(head.subpages)) {
const path = `${cwd}/${slug}`;
const children = (<><ul> {traverseMap(info, path, depth + 1)}</ul></>);
elements.push(<>
<li>
<Link className='button' href={path}>{info.title}</Link> {children}
</li>
</>);
}
return elements;
}
function SiteMapPage() {
return <Layout>
<ul>{traverseMap(SiteMap)}</ul>
</Layout>;
}
export default SiteMapPage;