Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/starting-physics/TAGS.md

This file was deleted.

1 change: 0 additions & 1 deletion examples/starting-platformer/TAGS.md

This file was deleted.

1 change: 0 additions & 1 deletion examples/starting-top-down/TAGS.md

This file was deleted.

25 changes: 24 additions & 1 deletion scripts/generate-database.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ const sortedStarterSlugs = new Set([
'geometry-monster',
]);

const sortedStartingPointSlugs = new Set([
'starting-platformer',
'starting-top-down',
'starting-physics',
]);

/**
* Computes a list of static tags to add to the example based on its slug.
* @param {string} exampleSlug
Expand All @@ -222,6 +228,9 @@ const getStaticTags = (exampleSlug) => {
const staticTags = [];
if (sortedStarterSlugs.has(exampleSlug)) staticTags.push('Starter');

if (sortedStartingPointSlugs.has(exampleSlug))
staticTags.push('Starting point');

return staticTags;
};

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

/**
* Generate the "short headers" for the examples, with starters
* listed first and in the order specified by `sortedStarterSlugs`.
* listed first and in the order specified by `sortedStarterSlugs` or `sortedStartingPointSlugs`.
* @param {Example[]} allExamples
* @return {ExampleShortHeader[]}
*/
const generateSortedShortHeaders = (allExamples) => {
const starters = [];
const startingPoints = [];
const examplesWithGameTag = [];
const examplesWithNeitherStarterNorGameTags = [];
for (const example of allExamples) {
if (sortedStarterSlugs.has(example.slug)) {
starters.push(example);
} else if (sortedStartingPointSlugs.has(example.slug)) {
startingPoints.push(example);
} else if (example.tags.includes('game')) {
examplesWithGameTag.push(example);
} else {
Expand All @@ -521,13 +533,24 @@ const generateSortedShortHeaders = (allExamples) => {
);
});

const sortedStartingPointSlugsArray = [...sortedStartingPointSlugs];
const sortedStartingPoints = [...startingPoints].sort(
(example1, example2) => {
return (
sortedStartingPointSlugsArray.indexOf(example1.slug) -
sortedStartingPointSlugsArray.indexOf(example2.slug)
);
}
);

examplesWithNeitherStarterNorGameTags.sort(
examplePreviewImageSortingFunction
);

return [
...sortedStarters,
...examplesWithGameTag,
...sortedStartingPoints,
...examplesWithNeitherStarterNorGameTags,
].map((example) => ({
id: example.id,
Expand Down
Loading