docs: add JS SDK to commerce modules sidebars (#10740)

This commit is contained in:
Shahed Nasser
2024-12-26 13:33:33 +02:00
committed by GitHub
parent 688e1e60a5
commit ee50e67a96
111 changed files with 8567 additions and 5406 deletions

View File

@@ -3,6 +3,12 @@ import { Tag } from "types"
export const parseTags = (tagNames: string): Tag => {
const parsedTags: Map<string, string> = new Map()
const splitTags = tagNames.split(",")
if (splitTags.length === 1 && !splitTags[0].includes("+")) {
return getTagItems(tagNames) || []
}
const tagsToRemove = getItemsToRemove(splitTags)
tagNames.split(",").forEach((tagName) => {
const intersectingTags = getIntersectionTags(tagName)
@@ -15,6 +21,10 @@ export const parseTags = (tagNames: string): Tag => {
})
})
tagsToRemove.forEach((tag) => {
parsedTags.delete(tag.path)
})
return Array.from(parsedTags).map(([path, title]) => ({
title,
path,
@@ -44,3 +54,12 @@ const getIntersectionTags = (tags: string): Tag => {
)
})
}
const getItemsToRemove = (tags: string[]): Tag => {
const tagsToRemove = tags
.filter((tag) => tag.startsWith("-"))
.map((tag) => getTagItems(tag.replace(/^-/, "")))
.filter(Boolean) as Tag[]
return !tagsToRemove.length ? [] : tagsToRemove[0]
}