This is a Next.js project bootstrapped with create-next-app.
This project uses TinaCMS and a custom middleware that allows for a multi-domain architecture.
The purpose of this repository is to host the product pages for SSW's custom software.
The YakShaver and EagleEye websites should be used as a guide for creating future product pages.
Tina branding, e.g. 'Powered By Tina' should be included in the footers.
This is enabled by default, and can be configured in the respective {product}-footer.json files.
-
Get access to the environment variables from Keeper
-
Paste the varables into your
.envfile -
Ensure you set
DEFAULT_PRODUCTenvironment variable to a valid product such as "YakShaver" or "TimePro" -
Install Dependencies
pnpm install
- Run the development server:
pnpm dev
-
Open http://localhost:3000 with your browser to see the result.
-
You can start editing the page by modifying
app/page.tsx. The page auto-updates as you edit the file.
Note: We temporarily disabled the Visual Editing feature due to this issue. To enable it, you can uncomment the
uisection intina/collectionSchema/pages.tsx.
-
Add project configuration to the
NEXT_PUBLIC_PRODUCT_LISTenvironment variable in Vercel. For example,{"product": "YakShaver", "domain": "www.yakshaver.ai"} -
Add custom domain to the Vercel. Then follow the instructions to add the configuration to your domain provider.
Context: Our file structure within our app router looks like
|- app
| |- page.tsx
| |- [product]
| |- [filename]
| |- page.tsxWhen the user serves the site a respective domain (i.e think www.YakShaver.ai), it will try to find a respective product mapping from the NEXT_PUBLIC_PRODUCT_LIST. If it successfully finds a product, it will fill the [product] dynamic mapping with the product value found from the NEXT_PUBLIC_PRODUCT_LIST. Then when it comes to serving data, our page.tsx
will use relativePath: ${product}/home.json using the specific product it found related to the domain.
This also means we have to set up the file structure for where we store our content. This is how we've organised our content structure;
|- content
|- blogs
|- footer
... other TinaCMS collections
|- pages
|- Product1
|- home.json
|- Product2
|- home.jsonNote in this instance Product1 and Product2 are just the product names such like YakShaver or TimePro
Because we are using Algolia for our search functionality you'll need to rebuild the search indices when changes are made to the docs. In order to do this complete the following steps:
- Get your changes to the docs pages merged into
main - Pull the
mainbranch on your local machine - Ensure that you have the Algolia environment variables in your env file you retrieved in the previous section (i.e. Running this project locally)
- After ensuring that you've installed the node version in the
.nvmrcfile in the project root, Run the following commandpnpm run rebuild-search-indices
We've documented how we use this middleware for our own sites and clients - Do you know how to use single codebase for multiple domains with TinaCMS and Next.js?
If you are adding a new page using one of the existing Tina collections for the site, you do not need to update the sitemap as it will automatically include the new page.
If you are however adding a new collection for a page template you'll need to update the sitemap returned by app/sitemap.xml/route.tsx to include the new collection.