Hooking codedoc's router to run code on page change
See original GitHub issueHello! 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:
- Created 2 years ago
- Comments:7 (2 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@mlota the plugin has been published to NPM!
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.