Skip to content

Commit

Permalink
Merge pull request #2663 from Aryakoste/custom-js
Browse files Browse the repository at this point in the history
Added customJs option to import custom JS
  • Loading branch information
Gerrit0 committed Sep 6, 2024
2 parents 611119c + 6c36b28 commit 12ba3d5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/internationalization/translatable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ export const translatable = {
help_highlightLanguages:
"Specify the languages which will be loaded to highlight code when rendering",
help_customCss: "Path to a custom CSS file to for the theme to import",
help_customJs: "Path to a custom JS file to import",
help_markdownItOptions:
"Specify the options passed to markdown-it, the Markdown parser used by TypeDoc",
help_markdownItLoader:
Expand Down
3 changes: 3 additions & 0 deletions src/lib/output/themes/default/layouts/default.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export const defaultLayout = (
{context.options.getValue("customCss") && (
<link rel="stylesheet" href={context.relativeURL("assets/custom.css", true)} />
)}
{context.options.getValue("customJs") && (
<script defer src={context.relativeURL("assets/custom.js", true)}></script>
)}
<script defer src={context.relativeURL("assets/main.js", true)}></script>
<script async src={context.relativeURL("assets/icons.js", true)} id="tsd-icons-script"></script>
<script async src={context.relativeURL("assets/search.js", true)} id="tsd-search-script"></script>
Expand Down
1 change: 1 addition & 0 deletions src/lib/utils/options/declaration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ export interface TypeDocOptionMap {
darkHighlightTheme: ShikiTheme;
highlightLanguages: string[];
customCss: string;
customJs: string;
markdownItOptions: ManuallyValidatedOption<Record<string, unknown>>;
/**
* Will be called when TypeDoc is setting up the markdown parser to use to render markdown.
Expand Down
5 changes: 5 additions & 0 deletions src/lib/utils/options/sources/typedoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,11 @@ export function addTypeDocOptions(options: Pick<Options, "addDeclaration">) {
help: (i18n) => i18n.help_customCss(),
type: ParameterType.Path,
});
options.addDeclaration({
name: "customJs",
help: (i18n) => i18n.help_customJs(),
type: ParameterType.Path,
});
options.addDeclaration({
name: "markdownItOptions",
help: (i18n) => i18n.help_markdownItOptions(),
Expand Down

0 comments on commit 12ba3d5

Please sign in to comment.