@@ -91,7 +91,7 @@ export async function transform_blog(
91
91
name : doc . data . frontmatter . author ,
92
92
url : doc . data . frontmatter . authorURL ,
93
93
} ,
94
- draft : doc . data . frontmatter . draft || false
94
+ draft : doc . data . frontmatter . draft || false ,
95
95
} ;
96
96
} )
97
97
. sort ( ( a , b ) => ( a . date . numeric < b . date . numeric ? 1 : - 1 ) ) ;
@@ -165,17 +165,18 @@ function process_example(
165
165
seen_slugs : Map < string , number >
166
166
) : [ Example [ ] , ExampleMeta [ ] ] {
167
167
let full : Example [ ] = [ ] ;
168
- let list = content . map ( ( { content } ) => {
168
+ let list = content . map ( ( { content, name } ) => {
169
169
if ( typeof content === "string" )
170
170
throw new Error ( "Example contents cannot contain further directories." ) ;
171
171
172
172
const [ files , meta ] = extract_meta ( content ) ;
173
- const slug = make_slug ( meta . title , seen_slugs ) ;
173
+
174
+ const [ , , _slug ] = / ^ ( \d + ) - ( .+ ) $ / . exec ( name ) ;
175
+ const slug = make_slug ( _slug , seen_slugs ) ;
174
176
175
177
const _example = {
176
178
name : meta . title ,
177
- slug,
178
- thumbnail : `examples/thumbnails/${ slug } .jpg` ,
179
+ slug : slug ,
179
180
} ;
180
181
181
182
full . push ( { ..._example , files : files . map ( get_files ) } ) ;
@@ -192,10 +193,9 @@ export async function transform_examples(
192
193
// project: string,
193
194
// dir: string
194
195
) : Promise < { full : Example [ ] ; list : ExampleCategory [ ] } > {
195
- const seen_slugs = new Map ( ) ;
196
-
197
196
const full : Example [ ] = [ ] ;
198
- const list = examples . map ( ( { content } ) => {
197
+ const list = examples . map ( ( { content, name } ) => {
198
+ const seen_slugs = new Map ( ) ;
199
199
if ( typeof content === "string" )
200
200
throw new Error ( "Example contents cannot contain further directories." ) ;
201
201
@@ -220,7 +220,7 @@ async function process_tutorial(
220
220
) : Promise < [ Tutorial [ ] , TutorialMeta [ ] ] > {
221
221
let full : Tutorial [ ] = [ ] ;
222
222
let list = await Promise . all (
223
- content . map ( async ( { content } ) => {
223
+ content . map ( async ( { content, name } ) => {
224
224
// TODO: this is backwards, fix
225
225
if ( typeof content === "string" )
226
226
throw new Error ( "Example contents cannot contain further directories." ) ;
@@ -244,11 +244,13 @@ async function process_tutorial(
244
244
level : 3 ,
245
245
} ) ;
246
246
247
+ const [ , , _slug ] = / ^ ( \d + ) - ( .+ ) $ / . exec ( name ) ;
248
+ const slug = make_slug ( _slug , seen_slugs ) ;
249
+
247
250
const _example = {
248
251
name : vfile . data . section_title ,
249
- slug : make_slug ( `${ cat_title } ${ vfile . data . section_slug } ` , seen_slugs ) ,
250
- section_slug : make_slug ( cat_title , new Map ( ) ) ,
251
- article_slug : vfile . data . section_slug
252
+ slug : slug ,
253
+
252
254
} ;
253
255
254
256
full . push ( {
0 commit comments