Giter VIP home page Giter VIP logo

Comments (9)

Gerrit0 avatar Gerrit0 commented on September 12, 2024 1

One can be easily constructed from the code in 1b55285

$ typedoc --plugin ./analytics.mjs
// @ts-check
// Apache License 2.0 - https://github.com/TypeStrong/typedoc/blob/master/LICENSE
import td from "typedoc";

/** @param {td.Application} app */
export function load(app) {
    app.options.addDeclaration({
        name: "gaID",
        help: "Set the Google Analytics tracking ID and activate tracking code",
        type: td.ParameterType.String,
    });

    app.renderer.hooks.on("body.end", () => {
        const gaID = app.options.getValue("gaID");
        if (gaID) {
            const script = `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${gaID}');
`.trim();
            return td.JSX.createElement(td.JSX.Fragment, null, [
                td.JSX.createElement("script", {
                    async: true,
                    src: "https://www.googletagmanager.com/gtag/js?id=" + gaID,
                }),
                td.JSX.createElement("script", null, td.JSX.createElement(td.JSX.Raw, { html: script })),
            ]);
        }
        return td.JSX.createElement(td.JSX.Fragment, null);
    });
}

from typedoc.

Gerrit0 avatar Gerrit0 commented on September 12, 2024 1

Fixed with TypeStrong/typedoc-site@c43e28b, thanks

from typedoc.

euberdeveloper avatar euberdeveloper commented on September 12, 2024

Are you aware of any google analytics plugin? I would like to migrate

from typedoc.

euberdeveloper avatar euberdeveloper commented on September 12, 2024

I think in the official docs website, gaId is still specified as a possible option

from typedoc.

euberdeveloper avatar euberdeveloper commented on September 12, 2024

One can be easily constructed from the code in 1b55285

$ typedoc --plugin ./analytics.mjs
// @ts-check
// Apache License 2.0 - https://github.com/TypeStrong/typedoc/blob/master/LICENSE
import td from "typedoc";

/** @param {td.Application} app */
export function load(app) {
    app.options.addDeclaration({
        name: "gaID",
        help: "Set the Google Analytics tracking ID and activate tracking code",
        type: td.ParameterType.String,
    });

    app.renderer.hooks.on("body.end", () => {
        const gaID = app.options.getValue("gaID");
        if (gaID) {
            const script = `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${gaID}');
`.trim();
            return td.JSX.createElement(td.JSX.Fragment, null, [
                td.JSX.createElement("script", {
                    async: true,
                    src: "https://www.googletagmanager.com/gtag/js?id=" + gaID,
                }),
                td.JSX.createElement("script", null, td.JSX.createElement(td.JSX.Raw, { html: script })),
            ]);
        }
        return td.JSX.createElement(td.JSX.Fragment, null);
    });
}

Hello, this plugin has been done today, it can be found here: https://www.npmjs.com/package/typedoc-plugin-ga

Feedback would be nice, also, can it be added to typedoc's documentation, in the plugins' list?

from typedoc.

Gerrit0 avatar Gerrit0 commented on September 12, 2024

It will automatically be picked up when the site rebuilds tonight

from typedoc.

euberdeveloper avatar euberdeveloper commented on September 12, 2024

It didn't appear

from typedoc.

Gerrit0 avatar Gerrit0 commented on September 12, 2024

Ah, that's because you don't have a peerDependency declared. Setting it to 0.26.x will make it show up.

from typedoc.

euberdeveloper avatar euberdeveloper commented on September 12, 2024

Oh ok, I had it as dev, thanks

from typedoc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.