docs: add tags package to generate tags (#10666)

* initial changes

* finalize implementation

* run generator on prep

* remove tags package from book

* optimization attempt

* test transpile

* test transpile

* rename utils

* rename directory

* add vercel ignore

* add tags to book
This commit is contained in:
Shahed Nasser authored and GitHub committed 2024-12-19 13:15:42 +02:00
1 parent 3f4d574748
commit 16ae192456
41 files changed
+424 -62

No files matched your search

@@ -24,10 +24,12 @@
],
"scripts": {
"build": "yarn clean && tsc",
"clean": "rimraf dist"
"clean": "rimraf dist",
"watch": "tsc --watch"
},
"dependencies": {
"@cloudinary/url-gen": "^1.17.0",
"docs-utils": "*",
"remark-frontmatter": "^5.0.0",
"remark-parse": "^11.0.0",
"remark-stringify": "^11.0.0",
@@ -9,5 +9,3 @@ export * from "./type-list-link-fixer.js"
export * from "./workflow-diagram-link-fixer.js"
export * from "./utils/fix-link.js"
export * from "./utils/get-file-slug.js"
export * from "./utils/get-front-matter.js"
@@ -98,15 +98,6 @@ export declare type CloudinaryConfig = {
roundCorners?: number
}
export declare type FrontMatter = {
slug?: string
sidebar_label?: string
sidebar_group?: string
sidebar_group_main?: boolean
sidebar_position?: number
sidebar_autogenerate_exclude?: boolean
}
export declare type CrossProjectLinksOptions = {
baseUrl: string
projectUrls?: {
@@ -1,5 +1,5 @@
import path from "path"
import { getFileSlugSyncUtil } from "./get-file-slug.js"
import { getFileSlugSync } from "../../../docs-utils/dist/index.js"
export type FixLinkOptions = {
currentPageFilePath: string
@@ -20,7 +20,7 @@ export function fixLinkUtil({
fullLinkedFilePath = fullLinkedFilePath.replace(hash, "")
// get absolute path of the URL
const linkedFilePath = fullLinkedFilePath.replace(basePath, "")
const linkedFileSlug = getFileSlugSyncUtil(fullLinkedFilePath)
const linkedFileSlug = getFileSlugSync(fullLinkedFilePath)
const newLink =
linkedFileSlug ||
@@ -1,23 +0,0 @@
import { getFrontMatterUtil } from "./get-front-matter.js"
import { matter } from "vfile-matter"
import { readSync } from "to-vfile"
import { FrontMatter } from "../types/index.js"
export async function getFileSlugUtil(
filePath: string
): Promise<string | undefined> {
const fileFrontmatter = await getFrontMatterUtil(filePath)
if (fileFrontmatter.slug) {
// add to slugs array
return fileFrontmatter.slug
}
}
export function getFileSlugSyncUtil(filePath: string): string | undefined {
const content = readSync(filePath)
matter(content)
return ((content.data.matter as FrontMatter).slug as string) || undefined
}
@@ -1,24 +0,0 @@
import remarkFrontmatter from "remark-frontmatter"
import remarkParse from "remark-parse"
import remarkStringify from "remark-stringify"
import { unified } from "unified"
import { read } from "to-vfile"
import { matter } from "vfile-matter"
import { FrontMatter } from "../types/index.js"
export async function getFrontMatterUtil(
filePath: string
): Promise<FrontMatter> {
return (
await unified()
.use(remarkParse)
.use(remarkStringify)
.use(remarkFrontmatter, ["yaml"])
.use(() => {
return (tree, file) => {
matter(file)
}
})
.process(await read(filePath))
).data.matter as FrontMatter
}