Version: 0.2.0
Last Updated: Unknown
Handles:
pages/_document.tsxpages/_app.tsxnext.config.js1import type { AppProps } from 'next/app';2import { IntlProvider } from 'react-intl';3import { useRouter } from 'next/router';4import flatten from 'flat';5import { ChakraProvider, extendTheme } from "@chakra-ui/react";6import * as locales from '../content/locale';7import '../styles/tailwind.css'89export default function MyApp({ Component, pageProps }: AppProps) {10 const router = useRouter();11 const { locale, defaultLocale, pathname } = router;12 const localeCopy = locales[locale as keyof typeof locales];13 const messages: Record<string, unknown> =14 localeCopy[pathname as keyof typeof localeCopy];15 // ensure undefined routes have correct copy16 const flattenedMessages: Record<string, string> = messages17 ? flatten(messages)18 : {};1920 return (21 <ChakraProvider22 theme={extendTheme({23 fonts: {24 heading: "var(--font-heading)",25 body: "var(--font-paragraph)",26 },27 })}28 >29 <IntlProvider30 locale={locale ?? defaultLocale ?? 'en'}31 defaultLocale={defaultLocale}32 messages={flattenedMessages}33 >34 <div className="<%= font %> <%= theme %>">35 <Component {...pageProps} />36 </div>37 </IntlProvider>38 </ChakraProvider>39 );40}
1import Document, {2 Html,3 Head,4 Main,5 NextScript,6 DocumentContext,7} from 'next/document';89class MyDocument extends Document {10 static async getInitialProps(ctx: DocumentContext) {11 const initialProps = await Document.getInitialProps(ctx);12 return { ...initialProps };13 }1415 render() {16 return (17 <Html>18 <Head>19 <link rel="preconnect" href="https://fonts.gstatic.com" />20 <% _%>21 <% if (font === 'font-lora-merriweather') { _%><link22 href="https://fonts.googleapis.com/css2?family=Lora:ital,wght@0,400;0,500;0,600;0,700;1,400;1,500;1,600;1,700&family=Merriweather:ital,wght@0,300;0,400;0,700;0,900;1,300;1,400;1,700;1,900&display=swap"23 rel="stylesheet"24 /><% } _%>25 <% if (font === 'font-domine-roboto') { _%><link26 href="https://fonts.googleapis.com/css2?family=Domine:wght@400;500;600;700&family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"27 rel="stylesheet"28 /><% } _%>29 <% if (font === 'font-hind-open-sans') { _%><link30 href="https://fonts.googleapis.com/css2?family=Hind:wght@300;400;500;600;700&family=Open+Sans:ital,wght@0,300;0,400;0,600;0,700;0,800;1,300;1,400;1,600;1,700;1,800&display=swap"31 rel="stylesheet"32 /><% } _%>33 <% %>34 </Head>35 <body>36 <Main />37 <NextScript />38 </body>39 </Html>40 );41 }42}4344export default MyDocument;
1#!/usr/bin/env node2const path = require('path');3const fs = require('fs');4const dir = __dirname;5const cwd = process.cwd();6const map = JSON.parse(7 fs.readFileSync(path.resolve(dir, './map.json'), 'utf-8')8);910let filesErr = [];1112const build = ({ dependencies, data, file, output, basedir }) => {13 dependencies.ejs.renderFile(file, data, {}, function (err, str) {14 // str => Rendered HTML string15 if (err) {16 filesErr.push(output);17 throw err;18 }1920 const outputFilePath = `${basedir}/${output}`;21 dependencies.fs.outputFileSync(outputFilePath, str);22 });23};2425module.exports = async function (options) {26 console.log('Bridging LandPad configuration files');27 try {28 const files = await options.dependencies.recursiveReaddir(dir, ['!*.ejs']);29 const basedir = options.data.basedir30 ? path.resolve(cwd, options.data.basedir)31 : cwd;3233 options.data = {34 ...options.data,35 };3637 for (const file of files) {38 let filepath = file.replace(dir + '/', '');39 console.log(`\t - Scaffolding: ${filepath}`);40 build({ ...options, file, output: map[filepath], basedir });41 }4243 return options;44 } catch (err) {45 console.error(err);46 }47};
1{2 "next.config.ejs": "next.config.js",3 "_document.ejs": "pages/_document.tsx",4 "_app.ejs": "pages/_app.tsx"5}
1module.exports = {2 i18n: {3 // These are all the locales you want to support in4 // your application5 locales: [<%_ locales.forEach(function(locale){ _%>'<%= locale %>',<%_ }); _%>],6 // This is the default locale you want to be used when visiting7 // a non-locale prefixed path e.g. `/hello`8 defaultLocale: '<%= defaultLocale %>',9 },10};