-
Notifications
You must be signed in to change notification settings - Fork 712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to include custom js? #2650
Comments
Currently only via a plugin which uses a hook to add it to the page like https://typedoc.org/api/documents/Renderer.Custom_Themes.html#md:hooks I've been meaning to add a |
Hello @Gerrit0 I would like to work on this issue. |
Go for it! |
@Aryakoste thanks for your work on this, but maybe it would be nice to have something like "customJs": {
src: "./dist/index.js",
type: "module"
} it seems the way this is currently implemented this only allows for non-esm scripts? @Gerrit0 would you like me to open another issue for this or re-open this issue? |
I'm becoming really wary of adding too much behavior via options - TypeDoc already has so many... This is also really easy to do with a plugin... import { Application, JSX } from "typedoc";
import fs from "fs";
import path from "path";
/** @param {Application} app */
export function load(app) {
app.renderer.hooks.on("head.end", (ctx) =>
JSX.createElement("script", { src: ctx.relativeURL("./assets/custom.js"), type: "module" }),
);
app.renderer.on("beginRender", (event) => {
fs.copyFileSync("path/to/custom.js", path.join(event.outputDirectory, "assets/custom.js"));
});
} If we add an option for |
absolutely, I get that. I mean I would probably re-use the lib.dom.ts declarations and do something like customJs: Array<
Partial<
PickByValueType<HTMLScriptElement, string | number | boolean>
> & {src: string}
> so that consumers can specify any valid script attribute at the cost of being able to specify a string only. But speaking of plugins: is there a guide to plugin development somewhere? (beside the advice to look at existing plugins) |
Unfortunately that API would require a hardcoded special case in the options parser, which is not something I want to add. There are a number of similar options that it'd be convenient to have within objects, but the parser as is doesn't lend itself to it. |
For plugin docs, there is the internal-docs folder in this repository and https://typedoc.org/guides/development/ |
Search terms
include js, include script, custom script source
Question
I'm developing a webcomponent library and I noticed that HTML that is inlined in the documentation is rendered. Would be quite nice to have the webcomponents render but for that I'd have to include the bundled script somehow. Is there a way to do that?
The text was updated successfully, but these errors were encountered: