Skip to content

Commit d3cd594

Browse files
Reorder starting points (#732)
1 parent 48d6599 commit d3cd594

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

examples/starting-physics/TAGS.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/starting-platformer/TAGS.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/starting-top-down/TAGS.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

scripts/generate-database.js

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ const sortedStarterSlugs = new Set([
213213
'geometry-monster',
214214
]);
215215

216+
const sortedStartingPointSlugs = new Set([
217+
'starting-platformer',
218+
'starting-top-down',
219+
'starting-physics',
220+
]);
221+
216222
/**
217223
* Computes a list of static tags to add to the example based on its slug.
218224
* @param {string} exampleSlug
@@ -222,6 +228,9 @@ const getStaticTags = (exampleSlug) => {
222228
const staticTags = [];
223229
if (sortedStarterSlugs.has(exampleSlug)) staticTags.push('Starter');
224230

231+
if (sortedStartingPointSlugs.has(exampleSlug))
232+
staticTags.push('Starting point');
233+
225234
return staticTags;
226235
};
227236

@@ -496,17 +505,20 @@ const updateExampleFiles = async (gd, allExampleFiles) => {
496505

497506
/**
498507
* Generate the "short headers" for the examples, with starters
499-
* listed first and in the order specified by `sortedStarterSlugs`.
508+
* listed first and in the order specified by `sortedStarterSlugs` or `sortedStartingPointSlugs`.
500509
* @param {Example[]} allExamples
501510
* @return {ExampleShortHeader[]}
502511
*/
503512
const generateSortedShortHeaders = (allExamples) => {
504513
const starters = [];
514+
const startingPoints = [];
505515
const examplesWithGameTag = [];
506516
const examplesWithNeitherStarterNorGameTags = [];
507517
for (const example of allExamples) {
508518
if (sortedStarterSlugs.has(example.slug)) {
509519
starters.push(example);
520+
} else if (sortedStartingPointSlugs.has(example.slug)) {
521+
startingPoints.push(example);
510522
} else if (example.tags.includes('game')) {
511523
examplesWithGameTag.push(example);
512524
} else {
@@ -521,13 +533,24 @@ const generateSortedShortHeaders = (allExamples) => {
521533
);
522534
});
523535

536+
const sortedStartingPointSlugsArray = [...sortedStartingPointSlugs];
537+
const sortedStartingPoints = [...startingPoints].sort(
538+
(example1, example2) => {
539+
return (
540+
sortedStartingPointSlugsArray.indexOf(example1.slug) -
541+
sortedStartingPointSlugsArray.indexOf(example2.slug)
542+
);
543+
}
544+
);
545+
524546
examplesWithNeitherStarterNorGameTags.sort(
525547
examplePreviewImageSortingFunction
526548
);
527549

528550
return [
529551
...sortedStarters,
530552
...examplesWithGameTag,
553+
...sortedStartingPoints,
531554
...examplesWithNeitherStarterNorGameTags,
532555
].map((example) => ({
533556
id: example.id,

0 commit comments

Comments
 (0)