packer-cn/website/pages/_app.js

73 lines
2.6 KiB
JavaScript
Raw Normal View History

2020-03-18 18:46:47 -04:00
import './style.css'
import '@hashicorp/nextjs-scripts/lib/nprogress/style.css'
import ProductSubnav from 'components/subnav'
2020-03-18 18:46:47 -04:00
import MegaNav from '@hashicorp/react-mega-nav'
import Footer from 'components/footer'
2020-03-18 18:46:47 -04:00
import Error from './_error'
import Head from 'next/head'
import HashiHead from '@hashicorp/react-head'
import Router from 'next/router'
import NProgress from '@hashicorp/nextjs-scripts/lib/nprogress'
import createConsentManager from '@hashicorp/nextjs-scripts/lib/consent-manager'
import { ErrorBoundary } from '@hashicorp/nextjs-scripts/lib/bugsnag'
import useAnchorLinkAnalytics from '@hashicorp/nextjs-scripts/lib/anchor-link-analytics'
2020-03-18 18:46:47 -04:00
NProgress({ Router })
const { ConsentManager, openConsentManager } = createConsentManager({
preset: 'oss',
2020-03-18 18:46:47 -04:00
})
export default function App({ Component, pageProps }) {
useAnchorLinkAnalytics()
2020-03-18 18:46:47 -04:00
return (
<ErrorBoundary FallbackComponent={Error}>
<HashiHead
is={Head}
title="Packer by HashiCorp"
siteName="Packer by HashiCorp"
description="Packer is a free and open source tool for creating golden images for multiple
platforms from a single source configuration."
image="https://www.packer.io/img/og-image.png"
icon={[{ href: '/favicon.ico' }]}
preload={[
{ href: '/fonts/klavika/medium.woff2', as: 'font' },
{ href: '/fonts/gilmer/light.woff2', as: 'font' },
{ href: '/fonts/gilmer/regular.woff2', as: 'font' },
{ href: '/fonts/gilmer/medium.woff2', as: 'font' },
{ href: '/fonts/gilmer/bold.woff2', as: 'font' },
{ href: '/fonts/metro-sans/book.woff2', as: 'font' },
{ href: '/fonts/metro-sans/regular.woff2', as: 'font' },
{ href: '/fonts/metro-sans/semi-bold.woff2', as: 'font' },
{ href: '/fonts/metro-sans/bold.woff2', as: 'font' },
{ href: '/fonts/dejavu/mono.woff2', as: 'font' },
]}
/>
<MegaNav product="Packer" />
<ProductSubnav />
<div className="content">
<Component {...pageProps} />
</div>
<Footer openConsentManager={openConsentManager} />
<ConsentManager />
</ErrorBoundary>
)
}
2020-03-18 18:46:47 -04:00
App.getInitialProps = async ({ Component, ctx }) => {
let pageProps = {}
2020-03-18 18:46:47 -04:00
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx)
} else if (Component.isMDXComponent) {
// fix for https://github.com/mdx-js/mdx/issues/382
const mdxLayoutComponent = Component({}).props.originalType
if (mdxLayoutComponent.getInitialProps) {
pageProps = await mdxLayoutComponent.getInitialProps(ctx)
}
2020-03-18 18:46:47 -04:00
}
return { pageProps }
2020-03-18 18:46:47 -04:00
}