Skip to content

Commit 12ba3d5

Browse files
authored
Merge pull request #2663 from Aryakoste/custom-js
Added customJs option to import custom JS
2 parents 611119c + 6c36b28 commit 12ba3d5

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

src/lib/internationalization/translatable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ export const translatable = {
242242
help_highlightLanguages:
243243
"Specify the languages which will be loaded to highlight code when rendering",
244244
help_customCss: "Path to a custom CSS file to for the theme to import",
245+
help_customJs: "Path to a custom JS file to import",
245246
help_markdownItOptions:
246247
"Specify the options passed to markdown-it, the Markdown parser used by TypeDoc",
247248
help_markdownItLoader:

src/lib/output/themes/default/layouts/default.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export const defaultLayout = (
2828
{context.options.getValue("customCss") && (
2929
<link rel="stylesheet" href={context.relativeURL("assets/custom.css", true)} />
3030
)}
31+
{context.options.getValue("customJs") && (
32+
<script defer src={context.relativeURL("assets/custom.js", true)}></script>
33+
)}
3134
<script defer src={context.relativeURL("assets/main.js", true)}></script>
3235
<script async src={context.relativeURL("assets/icons.js", true)} id="tsd-icons-script"></script>
3336
<script async src={context.relativeURL("assets/search.js", true)} id="tsd-search-script"></script>

src/lib/utils/options/declaration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ export interface TypeDocOptionMap {
138138
darkHighlightTheme: ShikiTheme;
139139
highlightLanguages: string[];
140140
customCss: string;
141+
customJs: string;
141142
markdownItOptions: ManuallyValidatedOption<Record<string, unknown>>;
142143
/**
143144
* Will be called when TypeDoc is setting up the markdown parser to use to render markdown.

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,11 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
329329
help: (i18n) => i18n.help_customCss(),
330330
type: ParameterType.Path,
331331
});
332+
options.addDeclaration({
333+
name: "customJs",
334+
help: (i18n) => i18n.help_customJs(),
335+
type: ParameterType.Path,
336+
});
332337
options.addDeclaration({
333338
name: "markdownItOptions",
334339
help: (i18n) => i18n.help_markdownItOptions(),

0 commit comments

Comments
 (0)