From 8650e6178eb10b9969be733ced6e00326a5dd70d Mon Sep 17 00:00:00 2001 From: Shahed Nasser Date: Thu, 19 Dec 2024 19:33:23 +0200 Subject: [PATCH] docs: remove duplicate parsed tag items (#10676) --- www/apps/resources/package.json | 3 +- www/package.json | 3 +- .../build-scripts/src/utils/parse-tags.ts | 11 ++++++-- www/packages/tags/src/tags/index.ts | 28 +++++++++---------- www/turbo.json | 5 ++++ 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/www/apps/resources/package.json b/www/apps/resources/package.json index de66ef5b9b..e5bd48c1c2 100644 --- a/www/apps/resources/package.json +++ b/www/apps/resources/package.json @@ -10,7 +10,8 @@ "start:monorepo": "yarn start -p 3003", "lint": "next lint --fix", "lint:content": "eslint --no-config-lookup -c .content.eslintrc.mjs app/**/*.mdx --fix", - "prep": "node ./scripts/prepare.mjs" + "prep": "node ./scripts/prepare.mjs", + "prep:turbo": "npx turbo run prep" }, "dependencies": { "@mdx-js/loader": "^3.1.0", diff --git a/www/package.json b/www/package.json index 515177dad7..350e946a55 100644 --- a/www/package.json +++ b/www/package.json @@ -17,7 +17,8 @@ "dev": "turbo run dev:monorepo", "lint": "turbo run lint", "lint:content": "turbo run lint:content", - "watch": "turbo run watch" + "watch": "turbo run watch", + "prep": "turbo run prep" }, "dependencies": { "autoprefixer": "10.4.14", diff --git a/www/packages/build-scripts/src/utils/parse-tags.ts b/www/packages/build-scripts/src/utils/parse-tags.ts index eed76318ab..ba4ac77874 100644 --- a/www/packages/build-scripts/src/utils/parse-tags.ts +++ b/www/packages/build-scripts/src/utils/parse-tags.ts @@ -2,7 +2,7 @@ import { getTagItems } from "tags" import { Tag } from "types" export const parseTags = (tagNames: string): Tag => { - const parsedTags: Tag = [] + const parsedTags: Map = new Map() tagNames.split(",").forEach((tagName) => { const intersectingTags = getIntersectionTags(tagName) @@ -10,10 +10,15 @@ export const parseTags = (tagNames: string): Tag => { return } - parsedTags.push(...intersectingTags) + intersectingTags.forEach((tag) => { + parsedTags.set(tag.path, tag.title) + }) }) - return parsedTags + return Array.from(parsedTags).map(([path, title]) => ({ + title, + path, + })) } const getIntersectionTags = (tags: string): Tag => { diff --git a/www/packages/tags/src/tags/index.ts b/www/packages/tags/src/tags/index.ts index 37078bf2f6..28ffdb4e05 100644 --- a/www/packages/tags/src/tags/index.ts +++ b/www/packages/tags/src/tags/index.ts @@ -1,18 +1,18 @@ export * from "./product.js" -export * from "./storefront.js" -export * from "./order.js" -export * from "./payment.js" -export * from "./cart.js" -export * from "./fulfillment.js" -export * from "./stripe.js" -export * from "./customer.js" -export * from "./product-category.js" -export * from "./auth.js" -export * from "./inventory.js" -export * from "./product-collection.js" -export * from "./api-key.js" -export * from "./region.js" -export * from "./publishable-api-key.js" export * from "./tax.js" export * from "./pricing.js" +export * from "./payment.js" +export * from "./cart.js" +export * from "./order.js" +export * from "./customer.js" +export * from "./fulfillment.js" +export * from "./product-category.js" +export * from "./storefront.js" export * from "./query.js" +export * from "./stripe.js" +export * from "./region.js" +export * from "./api-key.js" +export * from "./product-collection.js" +export * from "./inventory.js" +export * from "./publishable-api-key.js" +export * from "./auth.js" diff --git a/www/turbo.json b/www/turbo.json index bb72e09e18..22f318446f 100644 --- a/www/turbo.json +++ b/www/turbo.json @@ -12,6 +12,11 @@ "dist/**" ] }, + "prep": { + "dependsOn": [ + "^tags#build" + ] + }, "start:monorepo": { "dependsOn": [ "^build-scripts#build",