Skip to content

Commit

Permalink
updated dynamic route
Browse files Browse the repository at this point in the history
  • Loading branch information
jzakotnik committed Jul 30, 2021
1 parent cbfb6cb commit 15a7b95
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
31 changes: 31 additions & 0 deletions nextjs/mwe/pages/[id].js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { useState } from "react";

export default function profile({ id }) {
console.log("Rendering page..");
console.log(id.id);
return <p>hallo {id}</p>;
}

export function getProfileData(id) {
console.log(id);
// Combine the data with the id
return id;
}

export async function getStaticPaths() {
const paths = [{ params: { id: "jureUUID" } }];
return {
paths,
fallback: false,
};
}

export async function getStaticProps({ params }) {
const id = getProfileData(params.id);
console.log("Get Static Props content: " + id);
return {
props: {
id,
},
};
}
5 changes: 5 additions & 0 deletions nextjs/mwe/pages/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useState } from "react";
import { useRouter } from "next/router";
import Avatar from "@material-ui/core/Avatar";
import Button from "@material-ui/core/Button";
import CssBaseline from "@material-ui/core/CssBaseline";
Expand Down Expand Up @@ -67,6 +68,10 @@ export default function Home() {
setDayselection({ ...dayselection, [evt.target.name]: evt.target.checked });
};

const router = useRouter();
const { pid } = router.query;
console.log(pid);

return (
<Grid container component="main" sx={{ height: "100vh" }}>
<CssBaseline />
Expand Down

0 comments on commit 15a7b95

Please sign in to comment.