Skip to content

Commit 590d6e8

Browse files
library overhaul
1 parent 2e8618d commit 590d6e8

5 files changed

Lines changed: 140 additions & 73 deletions

File tree

pages/blog/[slug].js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ export async function getStaticProps({ params: { slug } }) {
7676
};
7777
}
7878

79-
// honestly not really sure why I need this. I guess Next needs it
8079
export async function getStaticPaths() {
8180
const files = fs.readdirSync(path.join('posts'));
8281

pages/library/[slug].js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import Link from 'next/link';
2+
import dayjs from 'dayjs';
3+
import Head from 'next/head';
4+
import React from 'react';
5+
6+
import { NextSeo } from 'next-seo';
7+
8+
import Reading from '../../components/reading.js';
9+
10+
import styles from '../../styles/blog.module.scss';
11+
12+
13+
export default function AI({ library }) {
14+
15+
console.log(library);
16+
const readings = library.list;
17+
18+
let sortedreadings = readings.sort((reading1, reading2) => (dayjs(reading1.dateAdded).isAfter(reading2.dateAdded) ? -1 : 1))
19+
20+
return (
21+
<>
22+
<NextSeo
23+
title={library.name}
24+
description={library.name}
25+
openGraph={{
26+
url: `https://ethancedwards.com/library/${library.slug}`,
27+
}}
28+
/>
29+
30+
<h1 className={styles.header}>{library.name}</h1>
31+
<div className={styles.podcast}>
32+
<p>{library.description}</p>
33+
<p>In no particular order:</p>
34+
</div>
35+
<div className={styles.blog}>
36+
{readings.map((reading, index) => (
37+
<React.Fragment key={index}>
38+
<Reading reading={reading} />
39+
</React.Fragment>
40+
))}
41+
</div>
42+
</>
43+
);
44+
}
45+
46+
export async function getStaticPaths() {
47+
const res = await fetch(`https://api.ethancedwards.com/zotero/v1/libraries`)
48+
const libraries = await res.json();
49+
50+
const mapping = Object.values(libraries);
51+
52+
console.log(mapping);
53+
54+
const paths = mapping.map(library => ({
55+
params: {
56+
slug: library.slug
57+
}
58+
}));
59+
60+
return {
61+
paths,
62+
fallback: false
63+
};
64+
65+
}
66+
67+
export async function getStaticProps({ params: { slug } }) {
68+
const res = await fetch(`https://api.ethancedwards.com/zotero/v1?library=${slug}`)
69+
const library = await res.json();
70+
71+
return {
72+
props: {
73+
library
74+
},
75+
revalidate: 1800
76+
}
77+
}

pages/library/ai.js

Lines changed: 0 additions & 69 deletions
This file was deleted.

pages/library/index.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import Link from 'next/link';
2+
3+
import { NextSeo } from 'next-seo';
4+
5+
import styles from '../../styles/blog.module.scss';
6+
7+
export default function Library({ libraries }) {
8+
const description = "Here is a non-exhaustive list of things I've been reading lately, loosely sorted by section.";
9+
10+
const mapping = Object.entries(libraries).map(([id, item]) => ({
11+
id,
12+
...item
13+
}));
14+
15+
16+
return (
17+
<>
18+
<NextSeo
19+
title="Library"
20+
description={description}
21+
openGraph={{
22+
url: 'https://ethancedwards.com/projects',
23+
}}
24+
/>
25+
26+
27+
<div className={styles.podcast}>
28+
<h1 className={styles.header}>Welcome to my virtual library.</h1>
29+
<p>{description}</p>
30+
</div>
31+
<h1 className={styles.header}>Libraries:</h1>
32+
<div className={styles.blog}>
33+
{mapping.map((library, index) => (
34+
<div key={index} className={styles.post}>
35+
<hr/>
36+
<Link href={'/library/' + library.slug} passHref>
37+
<h1>{library.name}</h1>
38+
</Link>
39+
<p>{library.description}</p>
40+
</div>
41+
))}
42+
</div>
43+
44+
</>
45+
);
46+
}
47+
48+
export async function getStaticProps() {
49+
const res = await fetch(`https://api.ethancedwards.com/zotero/v1/libraries`)
50+
const setlibraries = await res.json();
51+
52+
const libraries = setlibraries;
53+
54+
return {
55+
props: {
56+
libraries
57+
},
58+
revalidate: 86400
59+
}
60+
}

pages/projects.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ export async function getStaticProps() {
5555
"github": "dracula/tmux",
5656
},
5757
{
58-
"title": "AI Reading List",
59-
"description": "My reading list for the most important question humanity has faced: how do we adapt to a new world with AI? Curated by me and automatically updated every hour via an API that I've built out.",
60-
"link": "/library/ai",
58+
"title": "Virtual Library",
59+
"description": "Here is my virtual library. It contains a list of things I am currently reading. Each library (powered by Zotero) is curated by me and automatically updated every hour via an API that I've built out.",
60+
"link": "/library/",
6161
"photo": "/projects/people-walking.jpg",
6262
"photoalt": "Human silhouettes walking around"
6363
},

0 commit comments

Comments
 (0)