Does Docusaurus have any sort of sitewide register?

26 Views Asked by At

I've been tasked with migrating my team's docs from Jekyll to Docusaurus. In Jekyll, I wrote a bunch of plugins that rely heavily on its register API (site.data, context.registers, and other hashes) to pass around a variety of data. One application of that was writing IDs and locations of various objects to the register in order to generate relative paths to them in links. Thus, I could use IDs in links instead of paths, meaning that if I changed the title of a page, the heading label, the figure caption, etc., and/or moved the page elsewhere in the structure, my links would not break; instead, they would regenerate the path and the label using updated register entries.

I do not seem to be able to find any universally accessible data register in Docusaurus API so I'd like to know if one exists at all. A similar discussion on GitHub indicates that other people have requested a feature like that but it's not been worked on.

Thank you all in advance!

1

There are 1 best solutions below

0
Рауль Каримов On

Found it: setGlobalData seemingly allows to perform the targeted manipulations.

https://docusaurus.io/docs/next/api/plugin-methods/lifecycle-apis#setGlobalData