Skip to content

Commit cbe7292

Browse files
committed
feat: added cname options for CNAME file
1 parent 3f0dbea commit cbe7292

File tree

4 files changed

+17
-5
lines changed

4 files changed

+17
-5
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"typescript.tsdk": "./node_modules/typescript/lib",
33
"[typescript]": {
4-
"editor.defaultFormatter": "esbenp.prettier-vscode"
4+
"editor.defaultFormatter": "vscode.typescript-language-features"
55
},
66
"[typescriptreact]": {
77
"editor.defaultFormatter": "esbenp.prettier-vscode"

src/lib/output/renderer.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ export interface RendererHooks {
8282
*/
8383
@Component({ name: "renderer", internal: true, childClass: RendererComponent })
8484
export class Renderer extends ChildableComponent<
85-
Application,
86-
RendererComponent
85+
Application,
86+
RendererComponent
8787
> {
8888
private themes = new Map<string, new (renderer: Renderer) => Theme>([
8989
["default", DefaultTheme],
@@ -126,6 +126,10 @@ export class Renderer extends ChildableComponent<
126126
@BindOption("cleanOutputDir")
127127
cleanOutputDir!: boolean;
128128

129+
/** @internal */
130+
@BindOption("cname")
131+
cname!: string;
132+
129133
/** @internal */
130134
@BindOption("gaID")
131135
gaID!: string;
@@ -317,8 +321,7 @@ export class Renderer extends ChildableComponent<
317321
const ctor = this.themes.get(this.themeName);
318322
if (!ctor) {
319323
this.application.logger.error(
320-
`The theme '${
321-
this.themeName
324+
`The theme '${this.themeName
322325
}' is not defined. The available themes are: ${[
323326
...this.themes.keys(),
324327
].join(", ")}`
@@ -376,6 +379,10 @@ export class Renderer extends ChildableComponent<
376379
}
377380
}
378381

382+
if (this.cname) {
383+
fs.writeFileSync(path.join(directory, "CNAME"), this.cname);
384+
}
385+
379386
return true;
380387
}
381388
}

src/lib/utils/options/declaration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ export interface TypeDocOptionMap {
9191
defaultCategory: string;
9292
categoryOrder: string[];
9393
categorizeByGroup: boolean;
94+
cname: string;
9495
sort: SortStrategy[];
9596
gitRevision: string;
9697
gitRemote: string;

src/lib/utils/options/sources/typedoc.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,10 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
208208
type: ParameterType.Boolean,
209209
defaultValue: true,
210210
});
211+
options.addDeclaration({
212+
name: "cname",
213+
help: "Set the CNAME file text, it's useful for custom domains on GitHub Pages.",
214+
});
211215
options.addDeclaration({
212216
name: "sort",
213217
help: "Specify the sort strategy for documented values.",

0 commit comments

Comments
 (0)