Yamlify page objects

This commit is contained in:
Paul W. 2022-04-23 19:03:43 -04:00
parent 7ac30458d1
commit 088932a742
13 changed files with 235 additions and 249 deletions

View File

@ -7,22 +7,27 @@ module.exports = {
config.experiments = { asset: true }; config.experiments = { asset: true };
config.module.rules.push( config.module.rules.push(
{
test: /\.ya?ml$/,
use: 'js-yaml-loader',
},
{ {
test: /\.svg$/, test: /\.svg$/,
use: [{ loader: "@svgr/webpack" }] use: [{ loader: "@svgr/webpack" }],
}, },
{ {
test: /\.md$/, test: /\.md$/,
type: 'asset/source' type: 'asset/source',
}, },
{ {
test: /\.otf$/, test: /\.otf$/,
type: 'asset/resource' type: 'asset/resource',
}, },
{ {
resourceQuery: /raw/, resourceQuery: /raw/,
type: 'asset/source', type: 'asset/source',
} },
); );
return config return config

79
package-lock.json generated
View File

@ -8,6 +8,7 @@
"@types/react": "^17.0.37", "@types/react": "^17.0.37",
"dotenv": "^10.0.0", "dotenv": "^10.0.0",
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"js-yaml-loader": "^1.2.2",
"next": "^11.1.4", "next": "^11.1.4",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"react": "^17.0.2", "react": "^17.0.2",
@ -3643,7 +3644,6 @@
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz",
"integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==",
"dev": true,
"engines": { "engines": {
"node": ">= 4" "node": ">= 4"
} }
@ -5256,6 +5256,40 @@
"js-yaml": "bin/js-yaml.js" "js-yaml": "bin/js-yaml.js"
} }
}, },
"node_modules/js-yaml-loader": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/js-yaml-loader/-/js-yaml-loader-1.2.2.tgz",
"integrity": "sha512-H+NeuNrG6uOs/WMjna2SjkaCw13rMWiT/D7l9+9x5n8aq88BDsh2sRmdfxckWPIHtViYHWRG6XiCKYvS1dfyLg==",
"dependencies": {
"js-yaml": "^3.13.1",
"loader-utils": "^1.2.3",
"un-eval": "^1.2.0"
}
},
"node_modules/js-yaml-loader/node_modules/json5": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"dependencies": {
"minimist": "^1.2.0"
},
"bin": {
"json5": "lib/cli.js"
}
},
"node_modules/js-yaml-loader/node_modules/loader-utils": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz",
"integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==",
"dependencies": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^1.0.1"
},
"engines": {
"node": ">=4.0.0"
}
},
"node_modules/jsesc": { "node_modules/jsesc": {
"version": "2.5.2", "version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
@ -8141,6 +8175,11 @@
"node": ">=4.2.0" "node": ">=4.2.0"
} }
}, },
"node_modules/un-eval": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/un-eval/-/un-eval-1.2.0.tgz",
"integrity": "sha512-Wlj/pum6dQtGTPD/lclDtoVPkSfpjPfy1dwnnKw/sZP5DpBH9fLhBgQfsqNhe5/gS1D+vkZUuB771NRMUPA5CA=="
},
"node_modules/unbox-primitive": { "node_modules/unbox-primitive": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",
@ -11206,8 +11245,7 @@
"emojis-list": { "emojis-list": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz", "resolved": "https://registry.npmjs.org/emojis-list/-/emojis-list-3.0.0.tgz",
"integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q==", "integrity": "sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q=="
"dev": true
}, },
"encoding": { "encoding": {
"version": "0.1.13", "version": "0.1.13",
@ -12367,6 +12405,36 @@
"esprima": "^4.0.0" "esprima": "^4.0.0"
} }
}, },
"js-yaml-loader": {
"version": "1.2.2",
"resolved": "https://registry.npmjs.org/js-yaml-loader/-/js-yaml-loader-1.2.2.tgz",
"integrity": "sha512-H+NeuNrG6uOs/WMjna2SjkaCw13rMWiT/D7l9+9x5n8aq88BDsh2sRmdfxckWPIHtViYHWRG6XiCKYvS1dfyLg==",
"requires": {
"js-yaml": "^3.13.1",
"loader-utils": "^1.2.3",
"un-eval": "^1.2.0"
},
"dependencies": {
"json5": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz",
"integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==",
"requires": {
"minimist": "^1.2.0"
}
},
"loader-utils": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/loader-utils/-/loader-utils-1.4.0.tgz",
"integrity": "sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA==",
"requires": {
"big.js": "^5.2.2",
"emojis-list": "^3.0.0",
"json5": "^1.0.1"
}
}
}
},
"jsesc": { "jsesc": {
"version": "2.5.2", "version": "2.5.2",
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz",
@ -14472,6 +14540,11 @@
"integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==", "integrity": "sha512-TCTIul70LyWe6IJWT8QSYeA54WQe8EjQFU4wY52Fasj5UKx88LNYKCgBEHcOMOrFF1rKGbD8v/xcNWVUq9SymA==",
"dev": true "dev": true
}, },
"un-eval": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/un-eval/-/un-eval-1.2.0.tgz",
"integrity": "sha512-Wlj/pum6dQtGTPD/lclDtoVPkSfpjPfy1dwnnKw/sZP5DpBH9fLhBgQfsqNhe5/gS1D+vkZUuB771NRMUPA5CA=="
},
"unbox-primitive": { "unbox-primitive": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz",

View File

@ -9,6 +9,7 @@
"@types/react": "^17.0.37", "@types/react": "^17.0.37",
"dotenv": "^10.0.0", "dotenv": "^10.0.0",
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
"js-yaml-loader": "^1.2.2",
"next": "^11.1.4", "next": "^11.1.4",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"react": "^17.0.2", "react": "^17.0.2",

View File

@ -1,5 +1,6 @@
import React, { ReactElement } from 'react'; import React, { ReactElement } from 'react';
import Layout from '../components/layout'; import Layout from '../components/layout';
import pl from '../public/playlists.yaml';
type listItem = { type listItem = {
children?: listItem[]; children?: listItem[];
@ -7,27 +8,7 @@ type listItem = {
title: string; title: string;
}; };
const list: listItem[] = [{ const list: listItem[] = pl;
title: 'Classical by Composer',
children: [
{
title: '[Youtube] Antonio Lucio Vivaldi',
url: 'https://youtube.com/playlist?list=PLSU6wJEYct5HslkoJWHQFCttB-lhSwVr2'
},
{
title: '[Youtube] Johann Sebastian Bach',
url: 'https://youtube.com/playlist?list=PLSU6wJEYct5HftuY6UunC6zE_QMXOGmhm'
},
{
title: '[Youtube] Ludwig van Beethoven',
url: 'https://youtube.com/playlist?list=PLSU6wJEYct5Etx0WAXUQ7YXe84Fp5E142'
},
{
title: '[Youtube] Wolfgang Amadeus Mozart',
url: 'https://youtube.com/playlist?list=PLSU6wJEYct5EJsE-9Zh-jWckBuZAmIt8Q'
}
]
}];
function mapChild(obj: listItem, level: number) { function mapChild(obj: listItem, level: number) {
if (obj.url) if (obj.url)

View File

@ -1,6 +1,6 @@
import Layout from '../../components/layout'; import Layout from '../../components/layout';
import { useRouter } from 'next/router'; import { useRouter } from 'next/router';
import { getAllPosts, getPost } from '../../lib/slug'; import { getAllPosts, getPost } from '../../util/slug';
import ReactMarkdown from 'react-markdown'; import ReactMarkdown from 'react-markdown';
import Image from 'next/image'; import Image from 'next/image';

View File

@ -1,7 +1,6 @@
import Link from 'next/link'; import Link from 'next/link';
import React from 'react'; import React from 'react';
import Layout from '../../components/layout'; import Layout from '../../components/layout';
import { getAllPosts } from '../../lib/slug';
import Pages from '../../public/pages.json'; import Pages from '../../public/pages.json';
import cachePostLinkData from '../../util/post-cache'; import cachePostLinkData from '../../util/post-cache';

View File

@ -1,6 +1,7 @@
import React, { ReactElement } from 'react'; import React, { ReactElement } from 'react';
import Layout from '../components/layout'; import Layout from '../components/layout';
import style from '../styles/lists.module.css'; import style from '../styles/lists.module.css';
import rec from '../public/recommended.yaml';
type listItem = { type listItem = {
children?: listItem[] | string[]; children?: listItem[] | string[];
@ -9,150 +10,10 @@ type listItem = {
description?: string description?: string
}; };
const list: listItem[] = [ const list: listItem[] = rec // todo: validate this
{
title: 'Books',
children: [
{
title: 'Technology',
children: [
{
title: 'C programming',
children: [
{
title: 'The C Programming Language [K&R]',
url: 'https://en.wikipedia.org/wiki/The_C_Programming_Language'
},
{
title: 'Expert C Programming by Peter van der Linden'
},
{
title: 'Practical C Programming by Steve Oualline (outdated like all the books in this section but still good)'
},
{
title: 'Mastering Algorithms with C by Kyle Loudon'
}
]
},
{
title: 'Other Programming',
children: [
'Programming Perl by Larry Wall [Camel Book] (one of the first programming books I used. It probably is outdated but it is written well)',
'Programming Rust: Fast, Safe Systems Development',
'The Rust Programming Language',
'Programming in Lua, Fourth Edition by Roberto Ierusalimschy'
]
},
{
title: 'Operating Systems',
children: [
'Advanced Programming in the Unix Environment by W. Richard Stevens',
'Operating Systems: Design and Implementation by Andrew S. Tanenbaum (I have not had a chance to read his other books on OS. I am not a fan of his networking book though.)'
]
},
// {
// title: 'Networking'
// },
// {
// title: 'Electronics'
// },
{
title: 'Computer Engineering',
children: [
'Making Embedded Systems: Design Patterns for Great Software by Elecia White',
'Computer Organization and Design: the Hardware/Software Interface [Patterson Hennessy]',
'Computer Architecture: A Quantitative Approach [Hennessy Patterson]'
]
},
{
title: 'Compilers',
children: [
{
title: 'Compilers: Principles, Techniques, and Tools [Dragon Book] (discusses theory in detail so it is kind of hard to read)'
}
]
},
{
title: 'Other',
children: [
{
title: 'Definitive Guide to sed: Tutorial and Reference'
}
]
}
]
},
{
title: 'Classics',
description: 'Only the English ones for now.',
children: [
'Christmas Carol',
'A Tale of Two Cities',
'The Mayor of Casterbridge',
'The Citadel',
'Oliver Twist',
'Macbeth',
'Othello',
'Adventures of Huckleberry Finn',
'Murder on the Orient Express'
]
},
{
title: 'Language Learning',
children: ['Lingua Latina per se Illustrata (Both parts)']
}
]
},
{
title: 'Movies',
children: [
'Pulp Fiction',
'Blade Runner 2049',
'The Grand Budapest Hotel',
'The Hateful Eight',
'Goodfellas',
'Inception',
'Memento',
'Dune (2021)',
'Hot Fuzz',
'Snatch'
]
},
{
title: 'Music',
children: [
'American Pie by Don McLean',
'L\'Ultima Diligenza by Ennio Morricone'
]
},
{
title: 'Classical Music',
children: [
'Große Fuge Op. 133',
'KV 387',
'KV 448',
'KV 626',
'Piano Sonata No. 2 Mvmt. 3 (Chopin)',
'BWV 1048',
'Prelude in G Minor (Op. 23 No. 5)',
'String Quartet, Op. 20 No. 2 (Haydn)',
'Arabesque No. 1 (Debussy)'
]
},
{
title: 'Video Games',
children: [
'The Legend of Zelda: Breath of the Wild',
'Portal 2',
'Factorio',
'The Witcher 3: The Wild Hunt GOTY Edition (Especially the DLCs)',
'Baba is You',
'Red Dead Redemption'
]
}
];
function mapChild(obj: listItem | string, level: number) { function mapChild(obj: listItem | string, level: number) {
console.log(list)
if (typeof obj === 'string') { if (typeof obj === 'string') {
if (obj === '') if (obj === '')
return <></> return <></>

View File

@ -1,6 +1,7 @@
import React, { ReactElement } from 'react'; import React, { ReactElement } from 'react';
import Layout from '../components/layout'; import Layout from '../components/layout';
import style from '../styles/lists.module.css'; import style from '../styles/lists.module.css';
import res from '../public/resources.yaml';
type listItem = { type listItem = {
children?: listItem[] | string[]; children?: listItem[] | string[];
@ -9,80 +10,7 @@ type listItem = {
description?: string description?: string
}; };
const list = [{ const list: listItem[] = res;
title: 'Programming',
children: [
{
url: 'http://aggregate.org/MAGIC/',
title: 'The Aggregate Magic Algorithms'
},
{
url: 'https://3fx.ch/typing-is-hard.html',
title: 'Typing is Hard'
},
{
url: 'https://www.atlassian.com/git/',
title: 'Atlassian\'s Git Guide'
},
{
url: 'https://learnopengl.com/',
title: 'LearnOpenGL.com'
},
{
url: 'http://ctan.math.utah.edu/ctan/tex-archive/info/symbols/comprehensive/symbols-letter.pdf',
title: '[PDF] LaTeX Symbols'
},
{
url: 'https://tobi.oetiker.ch/lshort/lshort.pdf',
title: '[PDF] The Not So Short Introduction to LATEX 2ε'
},
{
url: 'https://writing.kemitchell.com/2016/09/21/MIT-License-Line-by-Line.html',
title: 'The MIT License, Line by Line by Kyle E. Mitchell'
},
{
title: 'Posts',
children: [
{
title: 'How to Make Your Code Reviewer Fall in Love with You by Michael Lynch',
url: 'https://mtlynch.io/code-review-love/'
},
{
title: 'What\'s in the box? by @fasterthanlime',
url: 'https://fasterthanli.me/articles/whats-in-the-box'
}
]
},
{
title: 'Talks',
children: [
{
title: 'Concurrency is not Parallelism by Rob Pike',
url: 'https://talks.golang.org/2012/waza.slide'
}
]
}
]
},
{
title: 'Electrical',
children: [
{
title: 'Common Wire-To-Board, Wire-To-Wire Connectors, And Crimp Tools',
url: 'http://www.mattmillman.com/info/crimpconnectors/'
}
]
},
{
title: 'Other Topics',
children: [
{
title: 'Sight Reading Trainer',
url: 'https://sightreading.training/'
}
]
}];
function mapChild(obj: listItem | string, level: number) { function mapChild(obj: listItem | string, level: number) {
if (typeof obj === 'string') { if (typeof obj === 'string') {

11
public/playlists.yaml Normal file
View File

@ -0,0 +1,11 @@
- title: Classical by Composer
children:
- title: "[Youtube] Antonio Lucio Vivaldi"
url: https://youtube.com/playlist?list=PLSU6wJEYct5HslkoJWHQFCttB-lhSwVr2
- title: "[Youtube] Johann Sebastian Bach"
url: https://youtube.com/playlist?list=PLSU6wJEYct5HftuY6UunC6zE_QMXOGmhm
- title: "[Youtube] Ludwig van Beethoven"
url: https://youtube.com/playlist?list=PLSU6wJEYct5Etx0WAXUQ7YXe84Fp5E142
- title: "[Youtube] Wolfgang Amadeus Mozart"
url: https://youtube.com/playlist?list=PLSU6wJEYct5EJsE-9Zh-jWckBuZAmIt8Q

89
public/recommended.yaml Normal file
View File

@ -0,0 +1,89 @@
- title: Books
hey: sdf
children:
- title: Technology
children:
- title: C programming
children:
- title: The C Programming Language [K&R]
url: https://en.wikipedia.org/wiki/The_C_Programming_Language
- title: Expert C Programming by Peter van der Linden
- title: Practical C Programming by Steve Oualline (outdated like all the books
in this section but still good)
- title: Mastering Algorithms with C by Kyle Loudon
- title: Other Programming
children:
- Programming Perl by Larry Wall [Camel Book] (one of the first programming
books I used. It probably is outdated but it is written well)
- 'Programming Rust: Fast, Safe Systems Development'
- The Rust Programming Language
- Programming in Lua, Fourth Edition by Roberto Ierusalimschy
- title: Operating Systems
children:
- Advanced Programming in the Unix Environment by W. Richard Stevens
- 'Operating Systems: Design and Implementation by Andrew S. Tanenbaum (I have
not had a chance to read his other books on OS. I am not a fan of his networking
book though.)'
- title: Computer Engineering
children:
- 'Making Embedded Systems: Design Patterns for Great Software by Elecia White'
- 'Computer Organization and Design: the Hardware/Software Interface [Patterson
Hennessy]'
- 'Computer Architecture: A Quantitative Approach [Hennessy Patterson]'
- title: Compilers
children:
- title: 'Compilers: Principles, Techniques, and Tools [Dragon Book] (discusses
theory in detail so it is kind of hard to read)'
- title: Other
children:
- title: 'Definitive Guide to sed: Tutorial and Reference'
- title: Classics
description: Only the English ones for now.
children:
- Christmas Carol
- A Tale of Two Cities
- The Mayor of Casterbridge
- The Citadel
- Oliver Twist
- Macbeth
- Othello
- Adventures of Huckleberry Finn
- Murder on the Orient Express
- title: Language Learning
children:
- Lingua Latina per se Illustrata (Both parts)
- title: Movies
children:
- Pulp Fiction
- Blade Runner 2049
- The Grand Budapest Hotel
- The Hateful Eight
- Goodfellas
- Inception
- Memento
- Dune (2021)
- Hot Fuzz
- Snatch
- title: Music
children:
- American Pie by Don McLean
- L'Ultima Diligenza by Ennio Morricone
- title: Classical Music
children:
- Große Fuge Op. 133
- KV 387
- KV 448
- KV 626
- Piano Sonata No. 2 Mvmt. 3 (Chopin)
- BWV 1048
- Prelude in G Minor (Op. 23 No. 5)
- String Quartet, Op. 20 No. 2 (Haydn)
- Arabesque No. 1 (Debussy)
- title: Video Games
children:
- 'The Legend of Zelda: Breath of the Wild'
- Portal 2
- Factorio
- 'The Witcher 3: The Wild Hunt GOTY Edition (Especially the DLCs)'
- Baba is You
- Red Dead Redemption

34
public/resources.yaml Normal file
View File

@ -0,0 +1,34 @@
- title: Programming
children:
- url: http://aggregate.org/MAGIC/
title: The Aggregate Magic Algorithms
- url: https://3fx.ch/typing-is-hard.html
title: Typing is Hard
- url: https://www.atlassian.com/git/
title: Atlassian's Git Guide
- url: https://learnopengl.com/
title: LearnOpenGL.com
- url: http://ctan.math.utah.edu/ctan/tex-archive/info/symbols/comprehensive/symbols-letter.pdf
title: "[PDF] LaTeX Symbols"
- url: https://tobi.oetiker.ch/lshort/lshort.pdf
title: "[PDF] The Not So Short Introduction to LATEX 2ε"
- url: https://writing.kemitchell.com/2016/09/21/MIT-License-Line-by-Line.html
title: The MIT License, Line by Line by Kyle E. Mitchell
- title: Posts
children:
- title: How to Make Your Code Reviewer Fall in Love with You by Michael Lynch
url: https://mtlynch.io/code-review-love/
- title: What's in the box? by @fasterthanlime
url: https://fasterthanli.me/articles/whats-in-the-box
- title: Talks
children:
- title: Concurrency is not Parallelism by Rob Pike
url: https://talks.golang.org/2012/waza.slide
- title: Electrical
children:
- title: Common Wire-To-Board, Wire-To-Wire Connectors, And Crimp Tools
url: http://www.mattmillman.com/info/crimpconnectors/
- title: Other Topics
children:
- title: Sight Reading Trainer
url: https://sightreading.training/

View File

@ -1,5 +1,5 @@
import fs from 'fs'; import fs from 'fs';
import { getAllPosts } from '../lib/slug'; import { getAllPosts } from './slug';
import { join } from 'path'; import { join } from 'path';
const publicDir = join(process.cwd(), 'public'); const publicDir = join(process.cwd(), 'public');

View File

@ -39,5 +39,9 @@ export function getPost(rawslug: string, filter: Array<any> = []) {
export function getAllPosts(filter: Array<any> = []) { export function getAllPosts(filter: Array<any> = []) {
const files = fs.readdirSync(postsDirectory); const files = fs.readdirSync(postsDirectory);
return files.map(file => { return getPost(file, filter) }); return files
.filter(c => !c.match(/^\./))
.map(file => {
return getPost(file, filter)
});
} }