Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ function FileContainer({ name, id, selectedFile, setSelectedFile }: Props) {
console.log(id);
setSelectedFile(id);
if (selectedFile !== null) {
navigate("/editor/" + selectedFile, {
navigate("/editor/" + selectedFile, {
replace: false,
state: {
filename: name
}
}), [navigate];
filename: name,
},
}),
[navigate];
}
};

Expand Down
31 changes: 27 additions & 4 deletions next/src/pages/blog/[bid].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ const MainContainer = styled.div`
min-height: 80vh;
`;

const BlogPage: NextPage<{ data: Block[] }> = ({ data }) => {
const BlogPage: NextPage<{ data: Block[]; blogName: string }> = ({
data,
blogName,
}) => {
return (
<PageContainer>
<Navbar
Expand All @@ -32,7 +35,7 @@ const BlogPage: NextPage<{ data: Block[] }> = ({ data }) => {
/>{" "}
{/** ignore the styling */}
<MainContainer>
<BlogHeading>Blog Title</BlogHeading>
<BlogHeading>{blogName}</BlogHeading>
<Blog blocks={data} />
</MainContainer>
<Footer />
Expand All @@ -41,15 +44,35 @@ const BlogPage: NextPage<{ data: Block[] }> = ({ data }) => {
};

export const getServerSideProps: GetServerSideProps = async ({ params }) => {
// get blog data
const data = await fetch(
`http://backend:8080/api/filesystem/get/published?DocumentID=${
params && params.bid
}`,
{
method: "GET",
}
).then((res) => res.text());
return { props: { data: JSON.parse(data).Contents } };
)
.then((res) => res.text())
.then((res) => JSON.parse(res).Contents);

// get blog name
const blogName = await fetch(
`http://backend:8080/api/filesystem/info?EntityID=${params && params.bid}`,
{
method: "GET",
}
)
.then((blogInfo) => blogInfo.json())
.then((blogInfo_json) => blogInfo_json.Response.EntityName)
.catch((err) => console.log("ERROR fetching blogInfo: ", err));

return {
props: {
data: data,
blogName: blogName,
},
};
};

export default BlogPage;