diff --git a/src/lib/output/plugins/index.ts b/src/lib/output/plugins/index.ts index 50b003be3..18bce1ddd 100644 --- a/src/lib/output/plugins/index.ts +++ b/src/lib/output/plugins/index.ts @@ -1,5 +1,5 @@ export { AssetsPlugin } from "./AssetsPlugin"; export { JavascriptIndexPlugin } from "./JavascriptIndexPlugin"; export { MarkedLinksPlugin } from "./MarkedLinksPlugin"; -export { MarkedPlugin as MarkedPlugin } from "../themes/MarkedPlugin"; +export { MarkedPlugin } from "../themes/MarkedPlugin"; export { LegendPlugin } from "./LegendPlugin"; diff --git a/src/lib/output/renderer.ts b/src/lib/output/renderer.ts index 5f123a372..3df5cf83b 100644 --- a/src/lib/output/renderer.ts +++ b/src/lib/output/renderer.ts @@ -8,6 +8,7 @@ */ import type * as ts from "typescript"; import * as fs from "fs"; +import * as path from "path"; import type { Application } from "../application"; import type { Theme } from "./theme"; @@ -95,6 +96,10 @@ export class Renderer extends ChildableComponent< @BindOption("gaSite") gaSite!: string; + /** @internal */ + @BindOption("githubPages") + githubPages!: boolean; + /** @internal */ @BindOption("hideGenerator") hideGenerator!: boolean; @@ -301,11 +306,27 @@ export class Renderer extends ChildableComponent< fs.mkdirSync(directory, { recursive: true }); } catch (error) { this.application.logger.error( - `Could not create output directory ${directory}` + `Could not create output directory ${directory}.` ); return false; } + if (this.githubPages) { + try { + const text = + "TypeDoc added this file to prevent GitHub Pages from " + + "using Jekyll. You can turn off this behavior by setting " + + "the `githubPages` option to false."; + + fs.writeFileSync(path.join(directory, ".nojekyll"), text); + } catch (error) { + this.application.logger.warn( + "Could not create .nojekyll file." + ); + return false; + } + } + return true; } } diff --git a/src/lib/utils/options/declaration.ts b/src/lib/utils/options/declaration.ts index e1c84d173..0ed608984 100644 --- a/src/lib/utils/options/declaration.ts +++ b/src/lib/utils/options/declaration.ts @@ -86,6 +86,7 @@ export interface TypeDocOptionMap { gitRemote: string; gaID: string; gaSite: string; + githubPages: boolean; hideGenerator: boolean; hideLegend: boolean; cleanOutputDir: boolean; diff --git a/src/lib/utils/options/sources/typedoc.ts b/src/lib/utils/options/sources/typedoc.ts index 8b9f3c7a3..6c9bd135d 100644 --- a/src/lib/utils/options/sources/typedoc.ts +++ b/src/lib/utils/options/sources/typedoc.ts @@ -248,6 +248,12 @@ export function addTypeDocOptions(options: Pick) { help: "Set the site name for Google Analytics. Defaults to `auto`.", defaultValue: "auto", }); + options.addDeclaration({ + name: "githubPages", + help: "Generate a .nojekyll file to prevent 404 errors in GitHub Pages. Defaults to `true`.", + type: ParameterType.Boolean, + defaultValue: true, + }); options.addDeclaration({ name: "hideGenerator", help: "Do not print the TypeDoc link at the end of the page.",