docs: add JS SDK to commerce modules sidebars (#10740)
This commit is contained in:
@@ -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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user