Skip to content

Commit 81730d4

Browse files
committed
feat: ensure blog metadata is available in payload
1 parent 829b11d commit 81730d4

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

src/format/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ export type custom_vfile = VFile & {
2323
seen_slugs: Map<string, number>;
2424
docs_type: docs_type;
2525
file_type: "readme" | "other";
26+
frontmatter: Record<string, unknown>
2627
};
2728
};

src/transform/docs.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import type { SimpleFile } from "../fs";
1919
import { format } from "../format";
2020
import { make_session_slug_processor } from "../format/slug";
2121
import { name } from "vfile-message";
22+
import { data } from "vfile";
2223

2324
type DocsSource = {
2425
name: string;
@@ -85,6 +86,11 @@ export async function transform_blog(
8586
file: blogs[i].name,
8687
content: doc.contents.toString(),
8788
date: dates[i],
89+
description: doc.data.frontmatter.description,
90+
author: {
91+
name: doc.data.frontmatter.author,
92+
url: doc.data.frontmatter.authorURL,
93+
}
8894
};
8995
})
9096
.sort((a, b) => (a.date.numeric < b.date.numeric ? 1 : -1));

src/transform/fixtures/blog.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ export const blog_out_full = [
3232
pretty: "Sun Dec 31 2017",
3333
numeric: "2017-12-31",
3434
},
35+
description: "Taking the next-plus-one step",
36+
author: {
37+
name: 'Rich Harris',
38+
url: 'https://twitter.com/Rich_Harris'
39+
}
3540
},
3641
{
3742
title: "The zen of Just Writing CSS",
@@ -43,6 +48,11 @@ export const blog_out_full = [
4348
pretty: "Wed Sep 06 2017",
4449
numeric: "2017-09-06",
4550
},
51+
description: "I would say this is the future, but we're already doing it.",
52+
author: {
53+
name: 'Rich Harris',
54+
url: 'https://twitter.com/Rich_Harris'
55+
}
4656
},
4757
{
4858
title: "The easiest way to get started with Svelte",
@@ -54,6 +64,11 @@ export const blog_out_full = [
5464
pretty: "Mon Aug 07 2017",
5565
numeric: "2017-08-07",
5666
},
67+
description: "This'll only take a minute.",
68+
author: {
69+
name: 'Rich Harris',
70+
url: 'https://twitter.com/Rich_Harris'
71+
}
5772
},
5873
{
5974
title:
@@ -66,6 +81,11 @@ export const blog_out_full = [
6681
pretty: "Sat Nov 26 2016",
6782
numeric: "2016-11-26",
6883
},
84+
description: "You can't write serious applications in vanilla JavaScript without hitting a complexity wall. But a compiler can do it for you.",
85+
author: {
86+
name: 'Rich Harris',
87+
url: 'https://twitter.com/Rich_Harris'
88+
}
6989
},
7090
];
7191

@@ -78,6 +98,11 @@ export const blog_out_list = [
7898
pretty: "Sun Dec 31 2017",
7999
numeric: "2017-12-31",
80100
},
101+
description: "Taking the next-plus-one step",
102+
author: {
103+
name: 'Rich Harris',
104+
url: 'https://twitter.com/Rich_Harris'
105+
}
81106
},
82107
{
83108
title: "The zen of Just Writing CSS",
@@ -87,6 +112,11 @@ export const blog_out_list = [
87112
pretty: "Wed Sep 06 2017",
88113
numeric: "2017-09-06",
89114
},
115+
description: "I would say this is the future, but we're already doing it.",
116+
author: {
117+
name: 'Rich Harris',
118+
url: 'https://twitter.com/Rich_Harris'
119+
}
90120
},
91121
{
92122
title: "The easiest way to get started with Svelte",
@@ -96,6 +126,11 @@ export const blog_out_list = [
96126
pretty: "Mon Aug 07 2017",
97127
numeric: "2017-08-07",
98128
},
129+
description: "This'll only take a minute.",
130+
author: {
131+
name: 'Rich Harris',
132+
url: 'https://twitter.com/Rich_Harris'
133+
}
99134
},
100135
{
101136
title:
@@ -106,5 +141,10 @@ export const blog_out_list = [
106141
pretty: "Sat Nov 26 2016",
107142
numeric: "2016-11-26",
108143
},
144+
description: "You can't write serious applications in vanilla JavaScript without hitting a complexity wall. But a compiler can do it for you.",
145+
author: {
146+
name: 'Rich Harris',
147+
url: 'https://twitter.com/Rich_Harris'
148+
}
109149
},
110150
];

src/transform/fixtures/everything.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,6 +899,11 @@ export const everything = [
899899
pretty: "Sun Dec 31 2017",
900900
numeric: "2017-12-31",
901901
},
902+
description: "Taking the next-plus-one step",
903+
author: {
904+
name: 'Rich Harris',
905+
url: 'https://twitter.com/Rich_Harris'
906+
}
902907
},
903908
{
904909
title: "The zen of Just Writing CSS",
@@ -908,6 +913,11 @@ export const everything = [
908913
pretty: "Wed Sep 06 2017",
909914
numeric: "2017-09-06",
910915
},
916+
description: "I would say this is the future, but we're already doing it.",
917+
author: {
918+
name: 'Rich Harris',
919+
url: 'https://twitter.com/Rich_Harris'
920+
}
911921
},
912922
{
913923
title: "The easiest way to get started with Svelte",
@@ -917,6 +927,11 @@ export const everything = [
917927
pretty: "Mon Aug 07 2017",
918928
numeric: "2017-08-07",
919929
},
930+
description: "This'll only take a minute.",
931+
author: {
932+
name: 'Rich Harris',
933+
url: 'https://twitter.com/Rich_Harris'
934+
}
920935
},
921936
{
922937
title:
@@ -927,6 +942,11 @@ export const everything = [
927942
pretty: "Sat Nov 26 2016",
928943
numeric: "2016-11-26",
929944
},
945+
description: "You can't write serious applications in vanilla JavaScript without hitting a complexity wall. But a compiler can do it for you.",
946+
author: {
947+
name: 'Rich Harris',
948+
url: 'https://twitter.com/Rich_Harris'
949+
}
930950
},
931951
],
932952
full: [
@@ -940,6 +960,11 @@ export const everything = [
940960
pretty: "Sun Dec 31 2017",
941961
numeric: "2017-12-31",
942962
},
963+
description: "Taking the next-plus-one step",
964+
author: {
965+
name: 'Rich Harris',
966+
url: 'https://twitter.com/Rich_Harris'
967+
}
943968
},
944969
{
945970
title: "The zen of Just Writing CSS",
@@ -951,6 +976,11 @@ export const everything = [
951976
pretty: "Wed Sep 06 2017",
952977
numeric: "2017-09-06",
953978
},
979+
description: "I would say this is the future, but we're already doing it.",
980+
author: {
981+
name: 'Rich Harris',
982+
url: 'https://twitter.com/Rich_Harris'
983+
}
954984
},
955985
{
956986
title: "The easiest way to get started with Svelte",
@@ -962,6 +992,11 @@ export const everything = [
962992
pretty: "Mon Aug 07 2017",
963993
numeric: "2017-08-07",
964994
},
995+
description: "This'll only take a minute.",
996+
author: {
997+
name: 'Rich Harris',
998+
url: 'https://twitter.com/Rich_Harris'
999+
}
9651000
},
9661001
{
9671002
title:
@@ -974,6 +1009,11 @@ export const everything = [
9741009
pretty: "Sat Nov 26 2016",
9751010
numeric: "2016-11-26",
9761011
},
1012+
description: "You can't write serious applications in vanilla JavaScript without hitting a complexity wall. But a compiler can do it for you.",
1013+
author: {
1014+
name: 'Rich Harris',
1015+
url: 'https://twitter.com/Rich_Harris'
1016+
}
9771017
},
9781018
],
9791019
},

0 commit comments

Comments
 (0)