Closed dimaMachina closed 1 year ago
π‘ Also, we need to find a way to ignore accessing _meta
file since Next.js will treat it as page.
Example: accessing /docs/_meta
route should return a 404 error
I like the idea! Allowing _meta
to be JavaScript brings more dynamicity indeed. And I'm a big fan of the type safety feature. Although I assume that it will be a bit tricky to support anything other than _meta.js
, because we need the data inside the loader logic which is Node.js and can't make it easy to support TS and JSX there (and ESM too).
Like you said, the Next.js routing is also a problem. I think we can explore a solution here and if it's doable, 100% agree that we should add it!
Although I assume that it will be a bit tricky to support anything other than _meta.js
You are right, I guess _meta.mjs
will be a better extension since Next.js will treat .js
files under the /pages
directory as Page and since it's not exporting React component, Next.js throw an error
I didn't find a way to ignore _meta.js
to treating as a page π
can't make it easy to support TS and JSX there (and ESM too)
I think for now we can skip support TypeScript and use JSDoc comment for validations types, it's better than nothing
The main blocking problem for now, is to figure out how to import _meta.mjs
when there are React components inside or JSX markup
And also we make JSON.stringify
of pageMap
(with content of meta file) here
I didn't find a way to ignore _meta.js to treating as a page π
I started to think again about this because I want to land this feature for remote MDX + versioning. I think I got an idea implementation, but it relies on _meta.js
and some changes to i18n (https://github.com/shuding/nextra/issues/1152).
I guess we can just make _meta.js a Next.js page (so we got .js, .jsx and .tsx support), and inject rewrites to force /_meta routes being /404.
First of all why?
main
blockmain
blockhttps://github.com/dotansimha/graphql-yoga/blob/1b018c3d2d347d3ca02eb0ca0175025325db6886/website/theme.config.tsx#L51-L64
to have possibility to sort sidebar items with the default eslint rule
sort-keys
and with eslint comment/* eslint sort-keys: error */
and omit installation of some JSON plugin to do ithave type safe
_meta
file since we can importMeta
type and have autocompleteExample: current
_meta
file with included some top and bottom content will looks likebefore
https://github.com/shuding/nextra/blob/1a029e615a851d6ad7c1ad4238f455fee551b030/examples/swr-site/pages/docs/advanced/_meta.en-US.json#L1-L13
after
@shuding any thoughts? :)