Skip to content

Commit

Permalink
fix: Use TypeDoc 'defineTheme' to register docusaurus theme
Browse files Browse the repository at this point in the history
  • Loading branch information
tgreyuk committed Jan 9, 2022
1 parent 2c22b84 commit ab5878d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-typedoc/src/options.ts
Expand Up @@ -18,6 +18,7 @@ const DEFAULT_PLUGIN_OPTIONS: PluginOptions = {
plugin: ['none'],
watch: false,
indexSlug: undefined,
theme: 'docusaurus',
};

export const getPluginOptions = (
Expand Down
4 changes: 3 additions & 1 deletion packages/docusaurus-plugin-typedoc/src/plugin.ts
Expand Up @@ -4,6 +4,8 @@ import { Application } from 'typedoc';
import { load } from 'typedoc-plugin-markdown';
import { getPluginOptions } from './options';
import { bootstrap, removeDir } from './render';

import { DocusaurusTheme } from './theme';
import { PluginOptions } from './types';

// store list of plugin ids when running multiple instances
Expand All @@ -29,7 +31,7 @@ export default function pluginDocusaurus(

const app = new Application();

app.options.setValue('theme', path.resolve(__dirname));
app.renderer.defineTheme('docusaurus', DocusaurusTheme);

load(app);

Expand Down
8 changes: 7 additions & 1 deletion packages/docusaurus-plugin-typedoc/src/render.ts
Expand Up @@ -19,7 +19,13 @@ export const bootstrap = (app: Application, options: PluginOptions) => {
app.bootstrap(options);
};

async function render(project: ProjectReflection, outputDirectory: string) {
export async function render(
project: ProjectReflection,
outputDirectory: string,
) {
if (!this.prepareTheme()) {
return;
}
const output = new RendererEvent(
RendererEvent.BEGIN,
outputDirectory,
Expand Down
1 change: 1 addition & 0 deletions packages/docusaurus-plugin-typedoc/src/types.ts
Expand Up @@ -15,6 +15,7 @@ export interface PluginOptions {
hidePageTitle: boolean;
entryDocument: string;
indexSlug?: string;
theme?: string;
}

export interface FrontMatter {
Expand Down
Expand Up @@ -39,6 +39,7 @@ Object {
"position": null,
"readmeLabel": "Readme",
},
"theme": "docusaurus",
"watch": false,
}
`;

0 comments on commit ab5878d

Please sign in to comment.