generated from Luis/nextjs-python-web-template
Made client/[name] generate static pages
This commit is contained in:
@@ -2,9 +2,16 @@
|
|||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
output: "export",
|
output: "export",
|
||||||
images: { unoptimized: true },
|
images: { unoptimized: true },
|
||||||
|
distDir: "build",
|
||||||
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;
|
||||||
|
|||||||
@@ -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 ------------"
|
||||||
|
|||||||
@@ -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 openapi.json
|
||||||
|
rm -rf src/api
|
||||||
cp ${clanPkgs.clan-openapi}/openapi.json .
|
cp ${clanPkgs.clan-openapi}/openapi.json .
|
||||||
orval
|
orval
|
||||||
'';
|
'';
|
||||||
|
|||||||
21
pkgs/ui/src/app/client/[name]/page.tsx
Normal file
21
pkgs/ui/src/app/client/[name]/page.tsx
Normal 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} />;
|
||||||
|
}
|
||||||
@@ -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,
|
||||||
@@ -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",
|
||||||
|
|||||||
@@ -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"]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user