Created
March 29, 2022 18:28
-
-
Save flavienbonvin/d680f467e419634c319f55d725758453 to your computer and use it in GitHub Desktop.
NextJS optimisation gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const ServiceBadge = dynamic(() => import(‘../Molecules/ServiceBadge’)) | |
const ServiceHeader = ({service, title}: Props) => { | |
const router = useRouter() | |
const isMobile = useBreakpointValue([true, null, false], ‘base’) | |
return ( | |
<HStack> | |
<BackButton onClick={() => router.replace(ROUTE_ROOT)} /> | |
{isMobile && <ServiceBadge {…service} />} | |
<Heading>{title}</Heading> | |
</HStack> | |
) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleLogout = async () => { | |
await supabase.auth.signOut() | |
setUser(null) | |
const showToast = await import('../../utils/showToast').then(mod => mod.showToast) | |
showToast(keys.logout_success, 'success') | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const getStaticProps: GetStaticProps = async () => { | |
const examples = (await import(‘../api/model/examples’)).fetchModelExamples | |
const categories = (await import(‘../api/model/example-categories’)).fetchModelExampleCategories | |
const modelExamples = (await examples(FRENCH_MODEL.language)) ?? ‘’ | |
const modelExampleCategories = (await categories()) ?? ‘’ | |
return { | |
props: { | |
modelExamplesParam: JSON.stringify(modelExamples), | |
modelExampleCategoriesParam: JSON.stringify(modelExampleCategories), | |
revalidate: 900, | |
}, | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const withPlugins = require('next-compose-plugins') | |
const {withPlausibleProxy} = require('next-plausible') | |
const withBundleAnalyzer = require('@next/bundle-analyzer') | |
const nextTranslate = require('next-translate') | |
const plausiblePlugin = withPlausibleProxy | |
const bundleAnalyzer = withBundleAnalyzer({enabled: process.env.ANALYZE === 'true'}) | |
const nextConfig = { | |
i18n: { | |
locales: ['en', 'fr', 'de'], | |
defaultLocale: 'en', | |
localeDetection: false, | |
}, | |
reactStrictMode: true, | |
images: { | |
formats: ['image/avif', 'image/webp'], | |
domains: ['uploads-ssl.webflow.com', 'images.unsplash.com'], | |
}, | |
} | |
module.exports = withPlugins([[plausiblePlugin, bundleAnalyzer], nextTranslate], nextConfig) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment