the-guild-org / docs

https://the-guild-components-storybook.vercel.app/
42 stars 15 forks source link

Figure out how to set `<title />` for dynamic pages that don't exist on disk #467

Closed dimaMachina closed 1 year ago

dimaMachina commented 2 years ago

In Envelop all plugins retrieved with remote-mdx via getStaticPaths/getStaticProps in plugins/[name].mdx file.

Need find a workaround to set title since frontMatter.title is undefined and there is no first heading#

P.S. tried with NextHead but title rollbacks to frontMatter.title/first heading# that is undefined

export const PluginPage = () => {
  const { compiledSource, title } = useSSG()
  return (
    <>
      <Head>
        <title>{title}</title>
      </Head>
      <MDXRemote compiledSource={compiledSource} components={{ PackageCmd }} />
    </>
  )
}

https://user-images.githubusercontent.com/7361780/193795822-46b31d56-c31b-4144-8380-22be8f6e7bd4.mov

Maybe we need to fix it in nextra

https://github.com/shuding/nextra/blob/a04c128c240fdc1fd43f8f1bb6961a0eb99872eb/packages/nextra-theme-docs/src/components/head.tsx#L23

to not render title tag if title is falsy

dimaMachina commented 1 year ago

fixed by https://github.com/n1ru4l/envelop/pull/1731