shuding / nextra

Simple, powerful and flexible site generation framework with everything you love from Next.js.
https://nextra.site
MIT License
11.74k stars 1.27k forks source link

Issue: Feedback for “Theme Configuration” #2078

Open manojadams opened 1 year ago

manojadams commented 1 year ago

Following example to change head tags does not work:

import { useRouter } from 'next/router'
import { useConfig } from 'nextra-theme-docs'

export default {
  head: () => {
    const { asPath, defaultLocale, locale } = useRouter()
    const { frontMatter } = useConfig()
    const url =
      'https://my-app.com' +
      (defaultLocale === locale ? asPath : `/${locale}${asPath}`)

    return (
      <>
        <meta property="og:url" content={url} />
        <meta property="og:title" content={frontMatter.title || 'Nextra'} />
        <meta
          property="og:description"
          content={frontMatter.description || 'The next site builder'}
        />
      </>
    )
  }
}
adduserwyw commented 9 months ago

You can check this example config here, it works: https://github.com/shuding/nextra/issues/2311#issuecomment-1735810350