www/pages/playlists.tsx

67 lines
1.7 KiB
TypeScript
Raw Normal View History

2021-12-08 03:38:31 +00:00
import React, { ReactElement } from 'react';
import Layout from '../components/layout';
type listItem = {
children?: listItem[];
url?: string;
title: string;
};
const list: listItem[] = [{
title: 'Classical by Composer',
children: [
{
2022-01-25 00:58:01 +00:00
title: '[Youtube] Antonio Lucio Vivaldi',
2021-12-08 03:38:31 +00:00
url: 'https://youtube.com/playlist?list=PLSU6wJEYct5HslkoJWHQFCttB-lhSwVr2'
},
{
2022-01-25 00:58:01 +00:00
title: '[Youtube] Johann Sebastian Bach',
2021-12-08 03:38:31 +00:00
url: 'https://youtube.com/playlist?list=PLSU6wJEYct5HftuY6UunC6zE_QMXOGmhm'
},
{
2022-01-25 00:58:01 +00:00
title: '[Youtube] Ludwig van Beethoven',
2021-12-08 03:38:31 +00:00
url: 'https://youtube.com/playlist?list=PLSU6wJEYct5Etx0WAXUQ7YXe84Fp5E142'
},
{
2022-01-25 00:58:01 +00:00
title: '[Youtube] Wolfgang Amadeus Mozart',
2021-12-08 03:38:31 +00:00
url: 'https://youtube.com/playlist?list=PLSU6wJEYct5EJsE-9Zh-jWckBuZAmIt8Q'
}
]
}];
function mapChild(obj: listItem, level: number) {
if (obj.url)
return <li key=''><a href={obj.url}>{obj.title}</a></li>
if (!obj.children)
return <></> // ignore playlists without links
let title: ReactElement;
if (level >= 0 && level <= 3)
title = React.createElement(`h${level+3}`, {}, obj.title);
else
title = React.createElement('strong', {}, obj.title);
return (
<>
{title}
<ul>
{obj.children.map(l => mapChild(l, level + 1))}
</ul>
</>
);
}
function Playlists() {
return (
<Layout name='Playlists'>
<section className='block'>
<h2>Music</h2>
{list.map(l => mapChild(l, 0))}
</section>
</Layout>
);
}
2022-01-25 00:58:01 +00:00
export default Playlists;