-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from smebberson/cloudflare-pages
Cloudflare pages
- Loading branch information
Showing
10 changed files
with
2,282 additions
and
35 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,7 @@ typings/ | |
|
||
# Next.js build output | ||
.next | ||
.vercel | ||
|
||
# Nuxt.js build / generate output | ||
.nuxt | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@fortawesome:registry=https://npm.fontawesome.com/ | ||
//npm.fontawesome.com/:_authToken=${TOKEN_FOR_FONTAWESOME} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,56 @@ | ||
# next-tailwind-fontawesome | ||
|
||
An example setup using Next.js, Tailwind CSS and Font Awesome. | ||
|
||
# Development | ||
|
||
To get started with development, follow these steps. | ||
|
||
Install dependencies: | ||
|
||
```bash | ||
yarn | ||
``` | ||
|
||
Start the development server: | ||
|
||
```bash | ||
yarn dev | ||
``` | ||
|
||
Open a browser to http://localhost:3000. As you make changes to the code, the browser will automatically update. | ||
|
||
# Cloudflare | ||
|
||
This project is configured to deploy to Cloudflare Pages Site. | ||
|
||
## Testing | ||
|
||
To test the production build locally, follow these steps. | ||
|
||
Build the website: | ||
|
||
```bash | ||
yarn build:ci | ||
``` | ||
|
||
Run wrangler to browser the website: | ||
|
||
```bash | ||
yarn dev:ci | ||
``` | ||
|
||
Open a browser to http://127.0.0.1:8788. | ||
|
||
# Template | ||
|
||
To use this repository as a template, after creating a new repository, complete the following steps. | ||
|
||
Configure the repository secrets, by going to Settings > Secrets and variables > Actions and adding the `FONTAWESOME_NPM_AUTH_TOKEN` secret. | ||
|
||
Follow the steps at [Cloudflare Docs > Pages > Deploy a Next.js site > Use the Edge Runtime](https://developers.cloudflare.com/pages/framework-guides/deploy-a-nextjs-site/#use-the-edge-runtime), with the following considerations: | ||
|
||
- The Edge Runtime has already been setup on `app/api/features` and `app/ssr`. | ||
- Yarn has been pinned to v1.22.19 using `packageManager` in `package.json`. | ||
- You'll need to ensure `.npmrc.pages` is copied across and that you setup a `TOKEN_FOR_FONTAWESOME` environment variable. | ||
- You'll need to ensure you [add the `nodejs_compat` flag](https://developers.cloudflare.com/workers/runtime-apis/nodejs#enable-nodejs-from-the-cloudflare-dashboard). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { NextResponse } from 'next/server'; | ||
|
||
import { faCode } from '@fortawesome/free-solid-svg-icons/faCode'; | ||
import { faSwatchbook } from '@fortawesome/free-solid-svg-icons/faSwatchbook'; | ||
import { faRocket } from '@fortawesome/free-solid-svg-icons/faRocket'; | ||
|
||
export const runtime = 'edge'; | ||
|
||
export const GET = () => | ||
NextResponse.json([ | ||
{ | ||
description: | ||
'Comes pre-installed with Font Awesome, Next.js, Prettier and Tailwind CSS.', | ||
icon: faCode, | ||
title: 'Development made-easy', | ||
}, | ||
{ | ||
description: | ||
'Combine Font Awesome and Tailwind CSS to create great looking pages.', | ||
icon: faSwatchbook, | ||
title: 'Stylish looks', | ||
}, | ||
|
||
{ | ||
description: | ||
'Take advantage of Next.js for lightning fast pages out of the box.', | ||
icon: faRocket, | ||
title: 'Fast performance', | ||
}, | ||
]); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Client from 'components/client'; | ||
|
||
export default function ClientPage() { | ||
return <Client />; | ||
} |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
import { faCode } from '@fortawesome/free-solid-svg-icons/faCode'; | ||
import { faSwatchbook } from '@fortawesome/free-solid-svg-icons/faSwatchbook'; | ||
import { faRocket } from '@fortawesome/free-solid-svg-icons/faRocket'; | ||
|
||
export const runtime = 'edge'; | ||
|
||
const getData = async () => { | ||
return [ | ||
{ | ||
description: | ||
'Comes pre-installed with Font Awesome, Next.js, Prettier and Tailwind CSS.', | ||
icon: faCode, | ||
title: 'Development made-easy', | ||
}, | ||
{ | ||
description: | ||
'Combine Font Awesome and Tailwind CSS to create great looking pages.', | ||
icon: faSwatchbook, | ||
title: 'Stylish looks', | ||
}, | ||
|
||
{ | ||
description: | ||
'Take advantage of Next.js for lightning fast pages out of the box.', | ||
icon: faRocket, | ||
title: 'Fast performance', | ||
}, | ||
]; | ||
}; | ||
|
||
export default async function SSR() { | ||
const features = await getData(); | ||
|
||
return ( | ||
<div className="bg-white"> | ||
<div className="relative pb-32 bg-emerald-500"> | ||
<div className="max-w-7xl mx-auto py-16 px-4 sm:py-24 sm:px-6 lg:px-8"> | ||
<div className="text-center"> | ||
<h2 className="text-base font-semibold text-emerald-900 tracking-wide uppercase"> | ||
Start strong | ||
</h2> | ||
<p className="mt-1 text-4xl font-extrabold text-white sm:text-5xl sm:tracking-tight lg:text-6xl"> | ||
Start with a strong foundation. | ||
</p> | ||
<p className="max-w-xl mt-5 mx-auto text-xl text-emerald-50"> | ||
Use this as a starting point for building websites | ||
with Next.js, Tailwind CSS and Font Awesome. Build | ||
whatever you like. | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
<section className="-mt-32 max-w-7xl mx-auto relative z-10 pb-32 px-4 sm:px-6 lg:px-8"> | ||
<h2 className="sr-only" id="features-heading"> | ||
Features | ||
</h2> | ||
<div className="grid grid-cols-1 gap-y-20 lg:grid-cols-3 lg:gap-y-0 lg:gap-x-8"> | ||
{features.map((feature, index) => ( | ||
<div | ||
className="flex flex-col bg-white rounded-2xl shadow-xl" | ||
key={index} | ||
> | ||
<div className="flex-1 relative pt-16 px-6 pb-8 md:px-8"> | ||
<div className="absolute top-0 p-5 inline-block bg-emerald-900 rounded-xl shadow-lg transform -translate-y-1/2"> | ||
<FontAwesomeIcon | ||
icon={feature.icon} | ||
className="h-6 w-6 text-white" | ||
aria-hidden="true" | ||
/> | ||
</div> | ||
<h3 className="text-xl font-medium text-gray-900"> | ||
{feature.title} | ||
</h3> | ||
<p className="mt-4 text-base text-gray-500"> | ||
{feature.description} | ||
</p> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</section> | ||
<div className="flex align-center justify-center"> | ||
<a | ||
className="bg-emerald-500 rounded-md p-4 text-xl text-white font-bold shadow-xl" | ||
href="https://github.com/smebberson/next-tailwind-fontawesome" | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
Get Started | ||
</a> | ||
</div> | ||
</div> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
'use client'; | ||
|
||
import { useEffect, useState } from 'react'; | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; | ||
|
||
export default function Client() { | ||
const [features, setFeatures] = useState([]); | ||
|
||
useEffect(() => { | ||
const fetchFeatures = async (url) => { | ||
const response = await fetch(url); | ||
const data = await response.json(); | ||
setFeatures(data); | ||
}; | ||
|
||
fetchFeatures('/api/features'); | ||
}, []); | ||
|
||
return ( | ||
<div className="bg-white"> | ||
<div className="relative pb-32 bg-emerald-500"> | ||
<div className="max-w-7xl mx-auto py-16 px-4 sm:py-24 sm:px-6 lg:px-8"> | ||
<div className="text-center"> | ||
<h2 className="text-base font-semibold text-emerald-900 tracking-wide uppercase"> | ||
Start strong | ||
</h2> | ||
<p className="mt-1 text-4xl font-extrabold text-white sm:text-5xl sm:tracking-tight lg:text-6xl"> | ||
Start with a strong foundation. | ||
</p> | ||
<p className="max-w-xl mt-5 mx-auto text-xl text-emerald-50"> | ||
Use this as a starting point for building websites | ||
with Next.js, Tailwind CSS and Font Awesome. Build | ||
whatever you like. | ||
</p> | ||
</div> | ||
</div> | ||
</div> | ||
{features.length > 0 && ( | ||
<section className="-mt-32 max-w-7xl mx-auto relative z-10 pb-32 px-4 sm:px-6 lg:px-8"> | ||
<h2 className="sr-only" id="features-heading"> | ||
Features | ||
</h2> | ||
<div className="grid grid-cols-1 gap-y-20 lg:grid-cols-3 lg:gap-y-0 lg:gap-x-8"> | ||
{features.map((feature, index) => ( | ||
<div | ||
className="flex flex-col bg-white rounded-2xl shadow-xl" | ||
key={index} | ||
> | ||
<div className="flex-1 relative pt-16 px-6 pb-8 md:px-8"> | ||
<div className="absolute top-0 p-5 inline-block bg-emerald-900 rounded-xl shadow-lg transform -translate-y-1/2"> | ||
<FontAwesomeIcon | ||
icon={feature.icon} | ||
className="h-6 w-6 text-white" | ||
aria-hidden="true" | ||
/> | ||
</div> | ||
<h3 className="text-xl font-medium text-gray-900"> | ||
{feature.title} | ||
</h3> | ||
<p className="mt-4 text-base text-gray-500"> | ||
{feature.description} | ||
</p> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</section> | ||
)} | ||
<div className="flex align-center justify-center"> | ||
<a | ||
className="bg-emerald-500 rounded-md p-4 text-xl text-white font-bold shadow-xl" | ||
href="https://github.com/smebberson/next-tailwind-fontawesome" | ||
rel="noreferrer" | ||
target="_blank" | ||
> | ||
Get Started | ||
</a> | ||
</div> | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.