Skip to content

Commit

Permalink
Merge pull request #257 from microsoft/package-upgrade
Browse files Browse the repository at this point in the history
Refactor file loading in change-log page
  • Loading branch information
thivy authored Nov 15, 2023
2 parents 02b80de + bc7ff1d commit 5272c88
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/app/change-log/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,34 @@ import { Suspense } from "react";
export const dynamic = "force-dynamic";

export default async function Home() {
// read local file from src/app/update/page.tsx
const file = await fs.readFile(
process.cwd() + "/app/change-log/update.md",
"utf8"
);

const content = await loadContent();
return (
<Card className="h-full flex justify-center flex-1 overflow-y-scroll">
<div className="flex flex-col gap-8 py-8">
<Suspense fallback={"Getting version"}>
<VersionDisplay />
</Suspense>
<div className="prose prose-slate dark:prose-invert break-words prose-p:leading-relaxed prose-pre:p-0 max-w-4xl ">
<Markdown content={file} />
<Markdown content={content} />
</div>
</div>
</Card>
);
}

const loadContent = async () => {
if (process.env.NODE_ENV === "production") {
const response = await fetch(
"https://raw.githubusercontent.com/microsoft/azurechat/main/src/app/change-log/update.md",
{
cache: "no-cache",
}
);
return await response.text();
} else {
return await fs.readFile(
process.cwd() + "/app/change-log/update.md",
"utf8"
);
}
};

0 comments on commit 5272c88

Please sign in to comment.