Skip to content

Commit 460fe01

Browse files
authored
Merge branch 'main' into setup-node
2 parents 5c92774 + b9f62bd commit 460fe01

File tree

18 files changed

+155
-6
lines changed

18 files changed

+155
-6
lines changed

content-testing/schemas.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const {
1313
youtubePlaylistIdValidator,
1414
videoNumberValidator,
1515
timestampsArrayValidator,
16+
correctionsArrayValidator,
1617
urlOrRelativeLinkValidator
1718
} = require('./validators');
1819

@@ -44,6 +45,8 @@ const baseVideosSchema = strictObject({
4445

4546
timestamps: timestampsArrayValidator.required(),
4647

48+
corrections: correctionsArrayValidator,
49+
4750
codeExamples: array(
4851
strictObject({
4952
title: string().required(),

content-testing/validators.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,42 @@ const timestampsArrayValidator = array(
264264
return true;
265265
});
266266

267+
const correctionsArrayValidator = array(
268+
strictObject({
269+
time: timestampValidator.required(),
270+
title: string().required()
271+
}).required()
272+
).test((values, context) => {
273+
if (!values) return true;
274+
275+
// Per https://support.google.com/youtube/answer/57404
276+
277+
// Timestamps should be sequential
278+
const sequenceErrors = [];
279+
let previousTime = -1;
280+
281+
for (const value of values) {
282+
const currentTime = timestampToSeconds(value.time);
283+
284+
if (currentTime <= previousTime) sequenceErrors.push(value);
285+
286+
previousTime = currentTime;
287+
}
288+
289+
if (sequenceErrors.length > 0) {
290+
const details = sequenceErrors
291+
.map((v) => `${v.time} - ${v.title}`)
292+
.join(' | ');
293+
const plural = sequenceErrors.length > 1 ? 's are' : ' is';
294+
295+
return context.createError({
296+
message: `${sequenceErrors.length} correction${plural} not in sequential order | ${details}`
297+
});
298+
}
299+
300+
return true;
301+
});
302+
267303
// generate all valid track paths, including deeplinks to chapters and videos
268304
const tracksWithChaptersOrVideosSlugs = new Set(slugs.tracks);
269305
paths.tracks.forEach((p) => {
@@ -330,5 +366,6 @@ module.exports = {
330366
youtubePlaylistIdValidator,
331367
videoNumberValidator,
332368
timestampsArrayValidator,
369+
correctionsArrayValidator,
333370
urlOrRelativeLinkValidator
334371
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"title": "2048 Remake",
3+
"author": {
4+
"name": "Loïc Rico",
5+
"url": "https://rico.studio"
6+
},
7+
"url": "https://github.com/ricoloic/personal-webpage-v4/blob/main/src/pages/games/2048.astro",
8+
"submittedOn": "2023-11-08T00:20:33.284Z"
9+
}
19.4 KB
Loading
256 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"title": "Bouncing Ball",
3+
"author": {
4+
"name": "Mauricio Fernández M",
5+
"instagram": "https://www.instagram.com/spacemauro/"
6+
},
7+
"url": "https://editor.p5js.org/spacemonkey01/full/-Av25IZ4M",
8+
"submittedOn": "2023-11-05T18:04:54.728Z"
9+
}
45.1 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"title": "random Walker with vectors",
3+
"author": {
4+
"name": "alpaslan özdemir",
5+
"url": "https://www.youtube.com/@alpaslanozdemir5229"
6+
},
7+
"url": "https://youtube.com/shorts/jbPR6xy-tsU",
8+
"submittedOn": "2023-11-06T13:40:45.947Z"
9+
}
34.4 KB
Loading
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"title": "vector math",
3+
"author": {
4+
"name": "alpaslan özdemir",
5+
"url": "https://www.youtube.com/@alpaslanozdemir5229"
6+
},
7+
"url": "https://youtube.com/shorts/zxtZKJp_hG0",
8+
"submittedOn": "2023-11-06T13:42:30.732Z"
9+
}

0 commit comments

Comments
 (0)