Simple one-page static site displaying a "disabled" version of a website, featuring configurable basic text content.
The client app is bootstrapped using NextJS v14.2.4. It uses the NextJS pages router since it only publishes static content.
The following dependencies are used for this project. Feel free to experiment using othere dependencies and versions.
- Windows 10 64-bit OS
- nvm version 1.1.12 (for Windows)
- NodeJS LTS v20.15.0
- node v20.15.0
- npm 10.7.0
- NextJS 14.2.4
- TailwindCSS 3.4.1
- React 18
-
Clone this repository.
git clone https://github.com/weaponsforge/disable-site.git
-
Install dependencies.
cd client npm install
-
Set up the environment variables. Create a
.env
file inside the /client directory with reference to the.env.example
file.Variable Name Description NEXT_PUBLIC_BASE_PATH Root directory path name that NextJS uses for assets, media and client-side routing for the app.
Set its value to blank''
when working on development mode in localhost.
Set its value to the sub-directory name where the exported NextJS app is to be deployed, i.e./<YOUR_REPOSITORY_NAME>
when deploying on a repository (sub-directory) of a root GitHub Pages site, i.e, onhttps://<YOUR_GITHUB_USERNAME>.github.io/<YOUR_REPOSITORY_NAME>
-
Run the client app in development mode on localhost.
cd client npm run dev
-
Create a new page with custom modal dialog text.
-
Create a new page component under the
/src/pages
directory. -
Export
getStaticProps()
function from the new page component. The function should construct and return thetitle
,background
andparagaraphs[]
key-value pairs.export async function getStaticProps () { return { props: { title: "Hello, World!", background: "/images/rg_inazuma2.jpg", paragraphs: [ { id: 0, content: "Sample text 1" }, { id: 1, content: "Sample text 2" }, ... ] } } }
-
Import and use the
NoticePage
component into the component created from the previous step. It should receive thetitle
.backgroud
andparagraphs
props from thegetStaticProps()
function, and pass them to theNoticePage
component. For example:function App ({ title, paragraphs, background }) { return ( <NoticePage title={title} paragraphs={paragraphs} background={background} Component={LinkTo} /> ) }
-
Follow these steps for manually deploying the static site to Firebase Hosting.
Create the GitHub Actions Secrets described in the GitHub Actions section to automatically deploy the dev
branch to Firebase Hosting on every new push or update to the dev
branch.
- Firebase project with Firebase Hosting pre-configured and set-up.
- Firebase CLI (Firebase Admin)
- Installed preferrably using the
"npm install -g firebase-tools"
command.
- Installed preferrably using the
- Open the
firebaserc
file in the client directory. - Replace the
"<FIREBASE_PROJECT_NAME>"
key with a target Firebase project. - Replace the
"<FIREBASE_HOSTING_NAME_UNDER_FIREBASE_PROJECT>"
key with a target Firebase Hosting name under the"<FIREBASE_PROJECT_NAME>"
. - Build the static site.
npm run build
- Login to your Firebase account using the Firebase CLI.
firebase login
- Deploy the static site.
firebase deploy --only hosting
Add the following GitHub Actions "Secrets" for deploying the development app to Firebase Hosting
GitHub Secret Name | Description |
---|---|
NEXT_PUBLIC_BASE_PATH | GitHub repository name. Review the NEXT_PUBLIC_BASE_PATH under the Installation section for more information. |
FIREBASE_PROJECT | Firebase project ID |
FIREBASE_HOSTING | Firebase Hosting name under the FIREBASE_PROJECT |
FIREBASE_TOKEN | Firebase CI token used for deploying the /client app to Firebase Hosting. This is obtained by signing-in to the firebase CLI with "firebase login:ci" . |
Starts the local NextJS app in development mode on localhost.
Builds the static site into the "out"
directory.
Serves the static build output of the "npm run build"
script on http://localhost:3000
Checks lint errors.
Fixes lint errors.
Generates a sentence containing random words.
@weaponsforge
20240708