Skip to content

Commit 9c0d88b

Browse files
committed
provider: youtube (experiment)
1 parent a35e988 commit 9c0d88b

35 files changed

+162
-80
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ export const Provider = z
4141
name: z.string(),
4242
profile: z.string().url("Must be a valid URL"),
4343
rss: z.string().url("Must be a valid URL"),
44-
articles: z.record(Article).optional(),
44+
contents: z.record(Content).optional(),
4545
})
4646
.strict();
4747
```
4848

4949
**Model Schema:**
5050

5151
```ts
52-
export const Article = z
52+
export const Content = z
5353
.object({
5454
id: z.string().toLowerCase(),
5555
title: z.string(),
@@ -70,6 +70,7 @@ See existing providers in the `providers/` directory for reference:
7070

7171
- `providers/atomicobject/` - spin posts
7272
- `providers/github/` - gist posts
73+
- `providers/youtube/` - youtube posts
7374

7475
### Working on frontend
7576

packages/core/src/generate.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import path from "path";
22

3-
import { Article, Provider } from "./schema.js";
3+
import { Content, Provider } from "./schema.js";
44

55
export async function generate(directory: string) {
66
const result = {} as Record<string, Provider>;
@@ -26,31 +26,31 @@ export async function generate(directory: string) {
2626
throw provider.error;
2727
}
2828

29-
// Process articles if articles directory exists
30-
const contentPath = path.join(directory, providerID, "content");
29+
// Process contents if contents directory exists
30+
const contentsPath = path.join(directory, providerID, "content");
3131
try {
32-
provider.data.articles = {};
33-
for await (const articlePath of new Bun.Glob("**/*.toml").scan({
34-
cwd: contentPath,
32+
provider.data.contents = {};
33+
for await (const contentPath of new Bun.Glob("**/*.toml").scan({
34+
cwd: contentsPath,
3535
absolute: true,
3636
followSymlinks: true,
3737
})) {
38-
const articleID = path.relative(contentPath, articlePath).slice(0, -5);
39-
const toml = await import(articlePath, {
38+
const contentID = path.relative(contentsPath, contentPath).slice(0, -5);
39+
const toml = await import(contentPath, {
4040
with: {
4141
type: "toml",
4242
},
4343
}).then((mod) => mod.default);
44-
toml.id = articleID;
45-
const article = Article.safeParse(toml);
46-
if (!article.success) {
47-
article.error.cause = toml;
48-
throw article.error;
44+
toml.id = contentID;
45+
const content = Content.safeParse(toml);
46+
if (!content.success) {
47+
content.error.cause = toml;
48+
throw content.error;
4949
}
50-
provider.data.articles[articleID] = article.data;
50+
provider.data.contents[contentID] = content.data;
5151
}
5252
} catch (error) {
53-
// Article directory might not exist for all providers
53+
// Content directory might not exist for all providers
5454
console.log(`No content directory found for provider ${providerID}`);
5555
}
5656

packages/core/src/schema.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { z } from "zod";
22

3-
// Normalised Article schema used throughout the project.
4-
export const Article = z
3+
// Normalised Content schema used throughout the project.
4+
export const Content = z
55
.object({
66
id: z.string().toLowerCase(),
77
title: z.string(),
@@ -15,7 +15,7 @@ export const Article = z
1515
})
1616
.strict();
1717

18-
export type Article = z.infer<typeof Article>;
18+
export type Content = z.infer<typeof Content>;
1919

2020
// Provider metadata – loosely based on RSS, but includes profile & rss urls.
2121
export const Provider = z
@@ -24,7 +24,7 @@ export const Provider = z
2424
name: z.string(),
2525
profile: z.string().url("Must be a valid URL"),
2626
rss: z.string().url("Must be a valid URL"),
27-
articles: z.record(Article).optional(),
27+
contents: z.record(Content).optional(),
2828
})
2929
.strict();
3030

packages/web/.DS_Store

-8 KB
Binary file not shown.

packages/web/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html>
33
<head>
44
<meta charset="UTF-8" />
5-
<title>Nathan Papes / Articles</title>
5+
<title>Nathan Papes / Contents</title>
66
<meta
77
name="description"
88
content="Drawn to complex problems. Bad at giving up on them."
@@ -27,7 +27,7 @@
2727
sizes="any"
2828
type="image/svg+xml"
2929
/>
30-
<meta property="og:title" content="Nathan Papes / Articles" />
30+
<meta property="og:title" content="Nathan Papes / Contents" />
3131
<meta
3232
property="og:description"
3333
content="Drawn to complex problems. Bad at giving up on them."

packages/web/src/render.tsx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const Rendered = renderToString(
4040
</svg>
4141
</a>
4242
<div class="search-container">
43-
<input type="text" id="search" placeholder="Filter articles" />
43+
<input type="text" id="search" placeholder="Filter contents" />
4444
<span class="search-shortcut">⌘K</span>
4545
</div>
4646
</div>
@@ -59,7 +59,7 @@ export const Rendered = renderToString(
5959
Site <span class="sort-indicator"></span>
6060
</th>
6161
<th class="sortable" data-type="number">
62-
Reading Time <span class="sort-indicator"></span>
62+
Time Est.<span class="sort-indicator"></span>
6363
</th>
6464
<th class="sortable" data-type="text">
6565
Link <span class="sort-indicator"></span>
@@ -72,25 +72,25 @@ export const Rendered = renderToString(
7272
providerA.name.localeCompare(providerB.name)
7373
)
7474
.flatMap(([providerId, provider]) =>
75-
provider.articles
76-
? Object.entries(provider.articles)
75+
provider.contents
76+
? Object.entries(provider.contents)
7777
.sort(
78-
([, articleA], [, articleB]) =>
79-
new Date(articleB.created_at).getTime() -
80-
new Date(articleA.created_at).getTime()
78+
([, contentA], [, contentB]) =>
79+
new Date(contentB.created_at).getTime() -
80+
new Date(contentA.created_at).getTime()
8181
)
82-
.map(([articleId, article]) => (
83-
<tr key={`${providerId}-${articleId}`}>
82+
.map(([contentId, content]) => (
83+
<tr key={`${providerId}-${contentId}`}>
8484
<td>
85-
<strong>{article.title}</strong>
86-
{article.description && (
85+
<strong>{content.title}</strong>
86+
{content.description && (
8787
<div style="font-size: 0.9em; color: #666; margin-top: 4px;">
88-
{article.description.slice(0, 45)}...
88+
{content.description.slice(0, 45)}...
8989
</div>
9090
)}
9191
</td>
9292
<td>
93-
{new Date(article.created_at).toLocaleDateString(
93+
{new Date(content.created_at).toLocaleDateString(
9494
"en-US",
9595
{
9696
year: "numeric",
@@ -102,7 +102,7 @@ export const Rendered = renderToString(
102102
<td>
103103
{(() => {
104104
try {
105-
return new URL(article.url).hostname.replace(
105+
return new URL(content.url).hostname.replace(
106106
"www.",
107107
""
108108
);
@@ -112,18 +112,18 @@ export const Rendered = renderToString(
112112
})()}
113113
</td>
114114
<td>
115-
{article.reading_time_minutes !== undefined
116-
? `${article.reading_time_minutes} min`
115+
{content.reading_time_minutes !== undefined
116+
? `${content.reading_time_minutes} min`
117117
: "-"}
118118
</td>
119119
<td>
120120
<a
121-
href={article.url}
121+
href={content.url}
122122
target="_blank"
123123
rel="noopener noreferrer"
124124
style="text-decoration: none;"
125125
>
126-
Read Article
126+
goto
127127
</a>
128128
</td>
129129
</tr>

providers/atomicobject/content/cdata-aurora-mysql-8-upgrade-using-the-aws-blue-green-style.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ id = "cdata-aurora-mysql-8-upgrade-using-the-aws-blue-green-style"
22
title = "Aurora MySQL 8 Upgrade: Using the AWS Blue/Green Style"
33
description = "Upgrade database with AWS RDS going from Aurora MySQL 5.7 to 8.0 using Blue/Green deployment. No downtime. No more RDS Extended Support."
44
url = "https://spin.atomicobject.com/aurora-mysql-8-aws-blue-green/"
5-
created_at = "2025-02-12T13:00:51+00:00"
5+
created_at = "2025-02-12T19:52:56Z"
66
reading_time_minutes = 7

providers/atomicobject/content/cdata-create-a-time-tracking-cli-tool-with-go-oauth2-and-goo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ id = "cdata-create-a-time-tracking-cli-tool-with-go-oauth2-and-goo"
22
title = "Create a Time-Tracking CLI Tool with Go, OAuth2, and Google Calendar API"
33
description = "In 2024, there&#039;s been a lot of hype around Golang. I felt inspired to try it out and write a program in this language."
44
url = "https://spin.atomicobject.com/golang-time-tracking/"
5-
created_at = "2024-04-17T12:00:53+00:00"
5+
created_at = "2024-04-16T20:59:47Z"
66
reading_time_minutes = 4

providers/atomicobject/content/cdata-docker-compose-dependency-management-isn-8217-t-a-silv.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ id = "cdata-docker-compose-dependency-management-isn-8217-t-a-silv"
22
title = "Docker Compose Dependency Management Isn&#039;t a Silver Bullet"
33
description = "The dependency management in Docker Compose, particularly with the depends_on attribute, isn&#039;t a silver bullet."
44
url = "https://spin.atomicobject.com/docker-dependency-management/"
5-
created_at = "2024-01-26T13:00:50+00:00"
5+
created_at = "2024-01-25T21:27:16Z"
66
reading_time_minutes = 3

providers/atomicobject/content/cdata-from-green-to-great-building-confidence-in-consulting.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ id = "cdata-from-green-to-great-building-confidence-in-consulting"
22
title = "From Green to Great: Building Confidence in Consulting"
33
description = "Preferring simplicity over complexity and being a great communicator are traits I&#039;ve observed from effective software consultants."
44
url = "https://spin.atomicobject.com/software-consultants-confidence/"
5-
created_at = "2024-07-18T12:00:31+00:00"
5+
created_at = "2024-07-17T18:51:31Z"
66
reading_time_minutes = 4

0 commit comments

Comments
 (0)