Skip to content

Commit

Permalink
feat: Statically generate everything (#446)
Browse files Browse the repository at this point in the history
* feat: Statically generate everything

* Fix tests
  • Loading branch information
typeofweb committed Dec 20, 2022
1 parent f4556bc commit f77fcbe
Show file tree
Hide file tree
Showing 9 changed files with 10,361 additions and 8,928 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/nextjs_bundle_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ on:

defaults:
run:
# change this if your nextjs app does not live at the root of the repo
working-directory: ./

jobs:
analyze:
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
NEXT_PUBLIC_API_URL: https://staging-api.devfaq.pl

steps:
- uses: actions/checkout@v2

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ concurrency:
cancel-in-progress: true

on: [pull_request]

jobs:
build_and_test:
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
NEXT_PUBLIC_API_URL: https://staging-api.devfaq.pl

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion apps/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"@tanstack/react-query-devtools": "4.20.4",
"client-only": "0.0.1",
"easymde": "2.18.0",
"next": "13.0.8-canary.0",
"next": "13.0.8-canary.1",
"next-mdx-remote": "4.2.0",
"openapi-typescript-fetch": "1.1.3",
"prismjs": "1.29.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ReactNode } from "react";
import { PAGE_SIZE } from "../../../../../lib/constants";
import { technologies, Technology } from "../../../../../lib/technologies";
import { getAllQuestions } from "../../../../../services/questions.service";

export default function QuestionsTechnologyLayout({ children }: { children: ReactNode }) {
return children;
}

export async function generateStaticParams() {
const params = await Promise.all(
technologies.map(async (technology) => {
const response = await getAllQuestions({ category: technology, limit: 0 });
return Array.from({ length: Math.ceil(response.data.meta.total / PAGE_SIZE) }, (_, idx) => {
return { technology, page: String(idx + 1) };
});
}),
);
return params.flat();
}
3 changes: 3 additions & 0 deletions apps/app/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const firaCode = Fira_Code({
variable: "--font-fira-code",
});

export const revalidate = 60;
export const dynamic = "error";

export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="pl" className={`${firaSans.variable} ${firaCode.variable}`}>
Expand Down
4 changes: 4 additions & 0 deletions apps/app/src/lib/fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ fetcher.configure({
baseUrl: process.env.NEXT_PUBLIC_API_URL,
init: {
credentials: "include",
next: {
revalidate: 60,
},
cache: "force-cache",
},
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"build": "turbo run build",
"start": "turbo run start",
"dev": "turbo run dev --parallel",
"test": "FORCE_COLOR=1 turbo run test",
"lint": "turbo run lint --parallel",
Expand Down
Loading

0 comments on commit f77fcbe

Please sign in to comment.