forked from medusajs/medusa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: support generating sidebar items with tags (medusajs#10672)
* docs: support generating sidebar items with tags * small fix * fix dependencies * test * test fix * test fix * test fix * test fix * another fix * revert change * fix for resources
- Loading branch information
1 parent
1118e35
commit 65007c4
Showing
19 changed files
with
119 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../utils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { getTagItems } from "tags" | ||
import { Tag } from "types" | ||
|
||
export const parseTags = (tagNames: string): Tag => { | ||
const parsedTags: Tag = [] | ||
tagNames.split(",").forEach((tagName) => { | ||
const intersectingTags = getIntersectionTags(tagName) | ||
|
||
if (!intersectingTags.length) { | ||
return | ||
} | ||
|
||
parsedTags.push(...intersectingTags) | ||
}) | ||
|
||
return parsedTags | ||
} | ||
|
||
const getIntersectionTags = (tags: string): Tag => { | ||
const tagsToIntersect: Tag[] = tags | ||
.split("+") | ||
.map((tagName) => getTagItems(tagName)) | ||
.filter((tag) => tag !== undefined) as Tag[] | ||
|
||
if (!tagsToIntersect.length) { | ||
return [] | ||
} | ||
|
||
if (tagsToIntersect.length === 1) { | ||
return tagsToIntersect[0] | ||
} | ||
|
||
return tagsToIntersect[0].filter((tagItem) => { | ||
return tagsToIntersect | ||
.slice(1) | ||
.every((otherTag) => | ||
otherTag.some( | ||
(otherTagItem) => | ||
otherTagItem.title === tagItem.title && | ||
otherTagItem.path === tagItem.path | ||
) | ||
) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { matter } from "vfile-matter" | ||
import { readSync } from "to-vfile" | ||
import { FrontMatter } from "types" | ||
|
||
export function getFileSlugSync(filePath: string): string | undefined { | ||
const content = readSync(filePath) | ||
|
||
matter(content) | ||
|
||
return ((content.data.matter as FrontMatter).slug as string) || undefined | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./find-title.js" | ||
export * from "./get-file-slug-sync.js" | ||
export * from "./get-file-slug.js" | ||
export * from "./get-front-matter.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters