-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
3f4d574
commit 16ae192
Showing
41 changed files
with
424 additions
and
62 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import { generateEditedDates } from "build-scripts" | ||
import path from "path" | ||
import { generateTags } from "tags" | ||
|
||
async function main() { | ||
await generateEditedDates() | ||
await generateTags(path.resolve("..", "..", "packages", "tags")) | ||
} | ||
|
||
void main() |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
import { generateEditedDates, generateSidebar } from "build-scripts" | ||
import { generateTags } from "tags" | ||
import { main as generateSlugChanges } from "./generate-slug-changes.mjs" | ||
import { main as generateFilesMap } from "./generate-files-map.mjs" | ||
import { sidebar } from "../sidebar.mjs" | ||
import path from "path" | ||
|
||
async function main() { | ||
await generateSidebar(sidebar) | ||
await generateSlugChanges() | ||
await generateFilesMap() | ||
await generateEditedDates() | ||
await generateTags(path.resolve("..", "..", "packages", "tags")) | ||
} | ||
|
||
void main() |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,48 @@ | ||
{ | ||
"name": "docs-utils", | ||
"version": "0.0.0", | ||
"private": true, | ||
"license": "MIT", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"type": "module", | ||
"main": "./dist/index.js", | ||
"types": "./dist/index.d.ts", | ||
"module": "./dist/index.js", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/index.d.ts", | ||
"default": "./dist/index.js" | ||
} | ||
} | ||
}, | ||
"sideEffects": false, | ||
"files": [ | ||
"dist/**" | ||
], | ||
"scripts": { | ||
"build": "yarn clean && tsc", | ||
"clean": "rimraf dist", | ||
"watch": "tsc --watch" | ||
}, | ||
"dependencies": { | ||
"remark-frontmatter": "^5.0.0", | ||
"remark-parse": "^11.0.0", | ||
"remark-stringify": "^11.0.0", | ||
"to-vfile": "^8.0.0", | ||
"unified": "^11.0.4", | ||
"vfile-matter": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^20.11.20", | ||
"rimraf": "^5.0.5", | ||
"tsconfig": "*", | ||
"types": "*", | ||
"typescript": "^5.3.3" | ||
}, | ||
"engines": { | ||
"node": ">=18.17.0" | ||
} | ||
} |
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,23 @@ | ||
import { readFileSync } from "fs" | ||
|
||
const REGEX = /export const metadata = {[\s\S]*title: `(?<title>.*)`/ | ||
|
||
export function findMetadataTitle(content: string): string | undefined { | ||
const headingMatch = REGEX.exec(content) | ||
|
||
return headingMatch?.groups?.title | ||
} | ||
|
||
const HEADING_REGEX = /# (?<title>.*)/ | ||
|
||
export function findPageHeading(content: string): string | undefined { | ||
const headingMatch = HEADING_REGEX.exec(content) | ||
|
||
return headingMatch?.groups?.title | ||
} | ||
|
||
export function findPageTitle(filePath: string): string | undefined { | ||
const content = readFileSync(filePath, "utf-8") | ||
|
||
return findMetadataTitle(content) || findPageHeading(content) | ||
} |
10 changes: 5 additions & 5 deletions
10
...rehype-plugins/src/utils/get-file-slug.ts → www/packages/docs-utils/src/get-file-slug.ts
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,3 @@ | ||
export * from "./find-title.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"extends": ["tsconfig/base.json"], | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "dist", | ||
"tsBuildInfoFile": "./dist/.tsbuildinfo-client", | ||
"noEmit": false, | ||
"lib": ["es2022"], | ||
"module": "NodeNext", | ||
"moduleResolution": "NodeNext", | ||
"target": "ESNext", | ||
"declaration": true, | ||
"declarationMap": true, | ||
"esModuleInterop": true, | ||
"strict": true, | ||
"skipLibCheck": true, | ||
"resolveJsonModule": true | ||
}, | ||
"include": ["src"] | ||
} |
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
Oops, something went wrong.