question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hooking codedoc's router to run code on page change

See original GitHub issue

Hello! I’m working on a plugin to be able to render Mermaid diagrams on Codedoc.

So far I got all the necessary javascript to be included in the pages and the logic to convert the below markdown into the necessary HTML markup.

> :Mermaid
> > graph TD
> >    Start --> Stop

Mermaid works by scanning the current page, finding specific div elements and converting their contents into an SVG image. To do this, you need to run the following JS code on every page:

mermaid.initialize({startOnLoad:true});

My problem right now is that I can only run this code once, when the plugin is loaded and I insert mermaid’s <script> tag into the HTML.

Is there a way to hook into Codedoc’s router (or any other component) so I can execute the mermaid initialize function on every page change?

Thanks!

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
danielsitnikcommented, Aug 5, 2021

@mlota the plugin has been published to NPM!

2reactions
TysonMNcommented, Jun 30, 2021

That tool looks amazing. I might want to make use of this plugin.

I created this Google Analytics plugin. I think it executes on each page change.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I run code on a route change from certain pages ...
Sounds like you could either listen for changes to the current location via the history object in a parent component. history.listen
Read more >
Allow to run hooks before or after location changes #4287
First of all: thanks sirs for you great work! I would like the be able to register hooks which will be run before...
Read more >
A Complete Beginner's Guide to React Router (Including ...
In this tutorial, we are going to cover everything you need to know to get started with React Router. Setting up the project;...
Read more >
How To Handle Routing in React Apps with React Router
This tutorial will use router-tutorial as the project name. ... add a lot of code in componentDidMount methods or inside a useEffect Hook; ......
Read more >
Inline Scripts - Laravel Livewire
A full-stack framework for Laravel that takes the pain out of building dynamic UIs.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found