www/pages/resources.tsx

130 lines
3.5 KiB
TypeScript
Raw Normal View History

2021-12-08 03:38:31 +00:00
import React, { ReactElement } from 'react';
import Layout from '../components/layout';
2021-12-08 04:30:34 +00:00
import style from '../styles/lists.module.css';
2021-12-08 03:38:31 +00:00
type listItem = {
children?: listItem[] | string[];
url?: string;
title: string;
description?: string
};
const list = [{
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) {
if (typeof obj === 'string') {
if (obj === '')
return <></>
2021-12-08 04:30:34 +00:00
return <span className={style.listItem}>{obj}</span>
2021-12-08 03:38:31 +00:00
}
if (obj.title === '')
return <></>
if (obj.url)
2021-12-08 04:30:34 +00:00
return <span className={style.listItem}><a href={obj.url}>{obj.title}</a></span>
2021-12-08 03:38:31 +00:00
if (!obj.children)
2021-12-08 04:30:34 +00:00
return <span className={style.listItem}>{obj.title}</span>
2021-12-08 03:38:31 +00:00
let title: ReactElement;
if (level >= 0 && level <= 4)
title = React.createElement(`h${level + 2}`, {}, obj.title);
else
title = React.createElement('strong', {}, obj.title);
return (
<>
{title}
{obj.description ? <p>{obj.description}</p> : <></>}
2021-12-08 04:30:34 +00:00
<div>
2021-12-08 03:38:31 +00:00
{obj.children.map(l => mapChild(l, level + 1))}
2021-12-08 04:30:34 +00:00
</div>
2021-12-08 03:38:31 +00:00
</>
);
}
function Resources() {
return (
<Layout name='Resources' title='Some Useful Resources'>
<section className='block'>
2021-12-08 04:30:34 +00:00
{list.map(l => mapChild(l, 0))}
2021-12-08 03:38:31 +00:00
</section>
</Layout>);
}
export default Resources;