diff --git a/README.md b/README.md index 7c6caa3..d5add1e 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,7 @@ Copy the [`config.json`](./data/config.json) next to the `package.json` and adap | social | Social links in the footer. See config below | | imprint | URL to the legal information | | labels | Configure the labels to change the texts and labels of the radar | +| tags | (optional) Use to render only items, which contain at least one of the specified tags. e.g `["frontend", "backend"]` | | editUrl | (optional) If set, an edit button will be shown next to the revision.
You can use placeholders for `{id}` and `{release}` | #### `config.quadrants` diff --git a/data/radar/2017-03-01/demo-3.md b/data/radar/2017-03-01/demo-3.md index 4f22290..0bc86c4 100644 --- a/data/radar/2017-03-01/demo-3.md +++ b/data/radar/2017-03-01/demo-3.md @@ -2,7 +2,7 @@ title: "Demo 3" ring: hold quadrant: tools -tags: [coding] +tags: [coding, frontend] --- This is a demo entry. It is used to show how a radar item is written in Markdown format. The meta header is used to define the attributes of the item. The content of the file is used as the description of the item. diff --git a/data/radar/2024-03-01/demo-2.md b/data/radar/2024-03-01/demo-2.md index d8820e7..9a32da2 100644 --- a/data/radar/2024-03-01/demo-2.md +++ b/data/radar/2024-03-01/demo-2.md @@ -2,7 +2,7 @@ title: "Demo 2" ring: adopt quadrant: platforms-and-operations -tags: [coding] +tags: [coding, backend] --- This is a revision of the 2nd demo item. It moved from trail to adopt. diff --git a/scripts/buildData.ts b/scripts/buildData.ts index 848a9bc..a684ee2 100644 --- a/scripts/buildData.ts +++ b/scripts/buildData.ts @@ -16,7 +16,10 @@ const { chart: { size }, } = config; +const ringIds = rings.map((r) => r.id); const quadrants = config.quadrants.map((q, i) => ({ ...q, position: i + 1 })); +const quadrantIds = quadrants.map((q) => q.id); +const tags = (config as { tags?: string[] }).tags || []; const positioner = new Positioner(size, quadrants, rings); const marked = new Marked( @@ -151,11 +154,36 @@ function postProcessItems(items: Item[]): { tags: string[]; items: Item[]; } { - const releases = getUniqueReleases(items); - const tags = getUniqueTags(items); - const latestRelease = releases[releases.length - 1]; + const filteredItems = items.filter((item) => { + // check if the items' quadrant and ring are valid + if (!item.quadrant || !item.ring) { + console.warn(`Item ${item.id} has no quadrant or ring`); + return false; + } - const processedItems = items.map((item) => ({ + if (!quadrantIds.includes(item.quadrant)) { + console.warn(`Item ${item.id} has invalid quadrant ${item.quadrant}`); + return false; + } + + if (!ringIds.includes(item.ring)) { + console.warn(`Item ${item.id} has invalid ring ${item.ring}`); + return false; + } + + // check if config has a key `tags` and if it is an array + if (Array.isArray(tags) && tags.length) { + // if tags are specified, only keep items that have at least one of the tags + return item.tags.some((tag) => tags.includes(tag)); + } + + return true; + }); + + const releases = getUniqueReleases(filteredItems); + const uniqueTags = getUniqueTags(filteredItems); + const latestRelease = releases[releases.length - 1]; + const processedItems = filteredItems.map((item) => ({ ...item, position: positioner.getNextPosition(item.quadrant, item.ring), flag: getFlag(item, latestRelease), @@ -173,7 +201,7 @@ function postProcessItems(items: Item[]): { .reverse(), })); - return { releases, tags, items: processedItems }; + return { releases, tags: uniqueTags, items: processedItems }; } // Parse the data and write radar data to JSON file