Made client/[name] generate static pages #61

Merged
merge-bot merged 2 commits from Qubasa-main into main 2024-01-23 11:21:36 +00:00
8 changed files with 46 additions and 14 deletions

View File

@@ -58,7 +58,8 @@ jobs:
git commit -am "update ui-assets.nix" git commit -am "update ui-assets.nix"
echo "Current branch: $GITHUB_REF_NAME" echo "Current branch: $GITHUB_REF_NAME"
git push origin HEAD:$GITHUB_REF_NAME git push origin HEAD:"$GITHUB_REF_NAME"
echo "Done uploading"
fi fi
else else
echo "No UI files changed. Skipping asset build and push" echo "No UI files changed. Skipping asset build and push"

View File

@@ -5,6 +5,12 @@ const nextConfig = {
eslint: { eslint: {
dirs: ["src"], dirs: ["src"],
}, },
generateBuildId: async () => {
// This could be anything, using the latest git hash
return process.env.NEXT_BUILD_ID;
},
outputFileTracing: true,
reactStrictMode: true,
}; };
module.exports = nextConfig; module.exports = nextConfig;

View File

@@ -70,6 +70,7 @@ in
# nextjs chaches some stuff in $HOME # nextjs chaches some stuff in $HOME
built.override.preBuild = '' built.override.preBuild = ''
export HOME=./home export HOME=./home
export NEXT_BUILD_ID=$(git log -1 --pretty=format:"%H")
echo "----------- GENERATE API TS ------------" echo "----------- GENERATE API TS ------------"

View File

@@ -8,7 +8,7 @@ pkgs.mkShell {
fmod.config.floco.settings.nodePackage fmod.config.floco.settings.nodePackage
]; ];
shellHook = '' shellHook = ''
ID=${pkg.built.tree} export ID=${pkg.built.tree}
currID=$(cat .floco/.node_modules_id 2> /dev/null) currID=$(cat .floco/.node_modules_id 2> /dev/null)
mkdir -p .floco mkdir -p .floco
@@ -22,10 +22,11 @@ pkgs.mkShell {
ln -sf ${pkgs.roboto}/share/fonts ./src ln -sf ${pkgs.roboto}/share/fonts ./src
export PATH="$PATH:$(realpath ./node_modules)/.bin" export PATH="$PATH:$(realpath ./node_modules)/.bin"
export NEXT_BUILD_ID=$(git log -1 --pretty=format:"%H")
# re-generate the api code # re-generate the api code
rm -rf src/api openapi.json rm -f --interactive=never openapi.json
rm -rf src/api
cp ${clanPkgs.clan-openapi}/openapi.json . cp ${clanPkgs.clan-openapi}/openapi.json .
orval orval
''; '';

View File

@@ -0,0 +1,21 @@
import Client from "@/app/client/client";
import { menuEntityEntries } from "@/components/sidebar";
export const dynamic = "error";
export const dynamicParams = false;
/*
The generateStaticParams function can be used in combination with dynamic route segments
to statically generate routes at build time instead of on-demand at request time.
During next dev, generateStaticParams will be called when you navigate to a route.
During next build, generateStaticParams runs before the corresponding Layouts or Pages are generated.
https://nextjs.org/docs/app/api-reference/functions/generate-static-params
*/
export function generateStaticParams() {
return menuEntityEntries.map((entry) => ({
name: entry.label,
}));
}
export default function Page({ params }: { params: { name: string } }) {
return <Client params={params} />;
}

View File

@@ -105,14 +105,10 @@ const AttachButton = ({
); );
}; };
export default function Client({ export default function Client({ params }: { params: { name: string } }) {
params, const { name } = params;
}: {
params: { client_name: string };
}) {
const { client_name } = params;
const { entity: entity } = useGetEntityByNameOrDid(client_name); const { entity: entity } = useGetEntityByNameOrDid(name);
const { const {
data: services, data: services,
isLoading: services_loading, isLoading: services_loading,

View File

@@ -33,7 +33,7 @@ type MenuEntry = {
subMenuEntries?: MenuEntry[]; subMenuEntries?: MenuEntry[];
}; };
const menuEntityEntries: MenuEntry[] = [ export const menuEntityEntries: MenuEntry[] = [
{ {
icon: <PersonIcon />, icon: <PersonIcon />,
label: "C1", label: "C1",
@@ -60,7 +60,7 @@ const menuEntityEntries: MenuEntry[] = [
}, },
]; ];
const menuEntries: MenuEntry[] = [ export const menuEntries: MenuEntry[] = [
{ {
icon: <HomeIcon />, icon: <HomeIcon />,
label: "Home", label: "Home",

View File

@@ -25,6 +25,12 @@
"@API/*": ["./src/api/*"] "@API/*": ["./src/api/*"]
} }
}, },
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], "include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts",
"build/types/**/*.ts"
],
"exclude": ["node_modules"] "exclude": ["node_modules"]
} }