From cbe7292dad050824e90e3d1e0e4f402bcc50953e Mon Sep 17 00:00:00 2001 From: Matteo Bruni <176620+matteobruni@users.noreply.github.com> Date: Thu, 9 Dec 2021 17:07:34 +0100 Subject: [PATCH 1/3] feat: added cname options for CNAME file --- .vscode/settings.json | 2 +- src/lib/output/renderer.ts | 15 +++++++++++---- src/lib/utils/options/declaration.ts | 1 + src/lib/utils/options/sources/typedoc.ts | 4 ++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 1d6018acb..5ddb847ea 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "typescript.tsdk": "./node_modules/typescript/lib", "[typescript]": { - "editor.defaultFormatter": "esbenp.prettier-vscode" + "editor.defaultFormatter": "vscode.typescript-language-features" }, "[typescriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" diff --git a/src/lib/output/renderer.ts b/src/lib/output/renderer.ts index 6235dfc09..6c7a8deb6 100644 --- a/src/lib/output/renderer.ts +++ b/src/lib/output/renderer.ts @@ -82,8 +82,8 @@ export interface RendererHooks { */ @Component({ name: "renderer", internal: true, childClass: RendererComponent }) export class Renderer extends ChildableComponent< - Application, - RendererComponent +Application, +RendererComponent > { private themes = new Map Theme>([ ["default", DefaultTheme], @@ -126,6 +126,10 @@ export class Renderer extends ChildableComponent< @BindOption("cleanOutputDir") cleanOutputDir!: boolean; + /** @internal */ + @BindOption("cname") + cname!: string; + /** @internal */ @BindOption("gaID") gaID!: string; @@ -317,8 +321,7 @@ export class Renderer extends ChildableComponent< const ctor = this.themes.get(this.themeName); if (!ctor) { this.application.logger.error( - `The theme '${ - this.themeName + `The theme '${this.themeName }' is not defined. The available themes are: ${[ ...this.themes.keys(), ].join(", ")}` @@ -376,6 +379,10 @@ export class Renderer extends ChildableComponent< } } + if (this.cname) { + fs.writeFileSync(path.join(directory, "CNAME"), this.cname); + } + return true; } } diff --git a/src/lib/utils/options/declaration.ts b/src/lib/utils/options/declaration.ts index 5b600cba9..3f6669509 100644 --- a/src/lib/utils/options/declaration.ts +++ b/src/lib/utils/options/declaration.ts @@ -91,6 +91,7 @@ export interface TypeDocOptionMap { defaultCategory: string; categoryOrder: string[]; categorizeByGroup: boolean; + cname: string; sort: SortStrategy[]; gitRevision: string; gitRemote: string; diff --git a/src/lib/utils/options/sources/typedoc.ts b/src/lib/utils/options/sources/typedoc.ts index 8d9ebd79d..55432d93d 100644 --- a/src/lib/utils/options/sources/typedoc.ts +++ b/src/lib/utils/options/sources/typedoc.ts @@ -208,6 +208,10 @@ export function addTypeDocOptions(options: Pick) { type: ParameterType.Boolean, defaultValue: true, }); + options.addDeclaration({ + name: "cname", + help: "Set the CNAME file text, it's useful for custom domains on GitHub Pages.", + }); options.addDeclaration({ name: "sort", help: "Specify the sort strategy for documented values.", From cc0e509e6e9bc5dad335561abade504fff73be24 Mon Sep 17 00:00:00 2001 From: Matteo Bruni <176620+matteobruni@users.noreply.github.com> Date: Mon, 3 Jan 2022 15:52:21 +0100 Subject: [PATCH 2/3] build: restored some files --- .vscode/settings.json | 2 +- src/lib/output/renderer.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 5ddb847ea..1d6018acb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "typescript.tsdk": "./node_modules/typescript/lib", "[typescript]": { - "editor.defaultFormatter": "vscode.typescript-language-features" + "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[typescriptreact]": { "editor.defaultFormatter": "esbenp.prettier-vscode" diff --git a/src/lib/output/renderer.ts b/src/lib/output/renderer.ts index 6c7a8deb6..371f6731f 100644 --- a/src/lib/output/renderer.ts +++ b/src/lib/output/renderer.ts @@ -82,8 +82,8 @@ export interface RendererHooks { */ @Component({ name: "renderer", internal: true, childClass: RendererComponent }) export class Renderer extends ChildableComponent< -Application, -RendererComponent + Application, + RendererComponent > { private themes = new Map Theme>([ ["default", DefaultTheme], @@ -321,7 +321,8 @@ RendererComponent const ctor = this.themes.get(this.themeName); if (!ctor) { this.application.logger.error( - `The theme '${this.themeName + `The theme '${ + this.themeName }' is not defined. The available themes are: ${[ ...this.themes.keys(), ].join(", ")}` From 3c71fa7e7e85012496c60b2466348a510ad2ca8e Mon Sep 17 00:00:00 2001 From: Matteo Bruni <176620+matteobruni@users.noreply.github.com> Date: Tue, 4 Jan 2022 18:23:09 +0100 Subject: [PATCH 3/3] build: added entry on changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 481171619..718d7ba3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ - Fixed line height of `h1` and `h2` elements being too low, #1796. +### Features + +- Added new `cname` option for GitHub Pages custom domain support, #1803 + ## v0.22.10 (2021-11-25) ### Features