nextra
nextra copied to clipboard
is it possible to create a variable that can be accessed under the scope of all the mdx files inside pages/?
Hello, I would like to know if it is possible to declare a variable (maybe in _app.js
?) that its content can be accessed inside all the documents (.mdx files) inside the pages/
folder.
currently im importing this variable at the top of all the .mdx files like this:
import index from "path/to/index.json"
import Link from "next/link"
some text with <Link href={index["link-1"]}>some link here</Link>
I would like to be able to have index
and Link
be globally available under the scope of all the .mdx files inside the pages/
folder so that I only need to do this inside an .mdx file
some text with <Link href={index["link-1"]}>some link here</Link>
for Link
question it can be done via https://nextra.site/docs/docs-theme/theme-configuration#mdx-components option
for index
- not sure what is a proper way to do it, maybe to assign it to globalThis
variable aka globalThis.myVar = index
in _app.js?