Skip to content

Commit

Permalink
docs: Use BASE_TD_URL env to replace typedoc base url in generated ty…
Browse files Browse the repository at this point in the history
…pedocs

Useful for local development when using links from README
  • Loading branch information
FoxxMD committed Mar 28, 2024
1 parent 89cb556 commit 072c24c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"description": "A typed, opinionated, batteries-included, Pino-based logging solution for backend TS/JS projects",
"scripts": {
"typedoc": "typedoc --plugin typedoc-plugin-missing-exports --plugin typedoc-plugin-replace-text --plugin typedoc-plugin-inline-sources --media ./assets",
"typedoc:watch": "typedoc --plugin typedoc-plugin-missing-exports --plugin typedoc-plugin-replace-text --plugin typedoc-plugin-inline-sources --media ./assets --watch",
"build": "tsc",
"prepare": "tshy",
"test": "mocha --reporter spec --recursive ./tests/*.test.ts",
Expand Down
24 changes: 18 additions & 6 deletions typedoc.config.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
const replacements = [
{
pattern: "\/assets\/",
replace: "media://"
}
];
const baseUrl = process.env.BASE_TD_URL;
if(baseUrl !== undefined && baseUrl.trim() !== '') {
const cleaned = baseUrl.replace(/^["']/, '').replace(/["']$/, '');
replacements.push(
{
pattern: "https:\/\/foxxmd.github.io\/logging",
replace: cleaned
}
);
}

/** @type { import('typedoc').TypeDocOptionMap & import('typedoc-plugin-replace-text').Config } */
module.exports ={
name: "@foxxmd/logging Docs",
Expand All @@ -16,11 +33,6 @@ module.exports ={
},
replaceText: {
inIncludedFiles: true,
replacements: [
{
pattern: "\/assets\/",
replace: "media://"
}
]
replacements
}
}

0 comments on commit 072c24c

Please sign in to comment.