I have started to dig deeper in my application and I want to know if there is a way to get an exported variable from a page.js/ts/tsx
from a component.
My idea is to have a menu component that will scan all page.js
within the app directory (i am using nextjs) and look in the files for an exported constant, for example:
page.js
export const ToMenu = {
title: 'Home',
icon: null,
parent: null
}
export default function HomePage() {.......
Then in my menu components I will search for all variables ToMenu
and preapare an array to update my menu automatically.
Not sure if this is possible but I got the idea from the nextjs export const metadata
that will tell the nextjs where to place that specific information! maybe this way I can build the menu automatically because sometimes I build new pages and forgot to put them in the existing menu