diff --git a/lib/parse-notes.ts b/lib/parse-notes.ts index b0c76f5d..9aab185f 100644 --- a/lib/parse-notes.ts +++ b/lib/parse-notes.ts @@ -73,21 +73,26 @@ export const getNote = async (slug: string): Promise => { }, }); + // next-mdx-remote v4 doesn't (yet?) minify compiled JSX output, see: + // https://github.com/hashicorp/next-mdx-remote/pull/211#issuecomment-1013658514 + // ...so for now do it manually (and conservatively) with terser when building for production. + const compiledSource = + process.env.NEXT_PUBLIC_VERCEL_ENV === "production" + ? ( + await minify(source.compiledSource, { + ecma: 2018, + module: true, + parse: { bare_returns: true }, + compress: { defaults: true }, + sourceMap: false, + }) + ).code + : source.compiledSource; + return { frontMatter, source: { - // next-mdx-remote v4 doesn't (yet?) minify compiled JSX output, see: - // https://github.com/hashicorp/next-mdx-remote/pull/211#issuecomment-1013658514 - // ...so do it manually (and conservatively) with terser for now. - compiledSource: ( - await minify(source.compiledSource, { - ecma: 2018, - module: true, - parse: { bare_returns: true }, - compress: { defaults: true }, - sourceMap: false, - }) - ).code, + compiledSource, }, }; }; diff --git a/lib/seo.ts b/lib/seo.ts index feff1c00..15a356b0 100644 --- a/lib/seo.ts +++ b/lib/seo.ts @@ -15,7 +15,7 @@ import meJpg from "../public/static/images/me.jpg"; export const defaultSeo: DefaultSeoProps = { defaultTitle: `${config.siteName} – ${config.shortDescription}`, - titleTemplate: `%s – ${config.siteName}`, // appends `– siteName` to title provided by each page + titleTemplate: `%s – ${config.siteName}`, // appends `– siteName` to title provided by each page (except home) description: config.longDescription, openGraph: { site_name: config.siteName, diff --git a/package.json b/package.json index 784a84fa..4e61446c 100644 --- a/package.json +++ b/package.json @@ -46,7 +46,7 @@ "is-absolute-url": "^4.0.1", "markdown-to-jsx": "^7.1.6", "modern-normalize": "^1.1.0", - "next": "12.0.10", + "next": "12.0.11-canary.3", "next-compose-plugins": "^2.2.1", "next-mdx-remote": "4.0.0-rc.1", "next-seo": "^5.1.0", diff --git a/pages/_app.tsx b/pages/_app.tsx index b55e794e..156c0ff1 100644 --- a/pages/_app.tsx +++ b/pages/_app.tsx @@ -56,6 +56,7 @@ const App = ({ Component, pageProps }: AppProps) => { return ( <> + {/* all SEO config is in ./lib/seo.ts except for canonical URLs, which require access to next router */}