Skip to content

Commit

Permalink
Merge pull request #58 from AElfProject/feature/nextjs-15
Browse files Browse the repository at this point in the history
Feature/nextjs 15
  • Loading branch information
yongenaelf authored Nov 14, 2024
2 parents 889464a + 7497ea6 commit 793b6c3
Show file tree
Hide file tree
Showing 9 changed files with 684 additions and 176 deletions.
19 changes: 14 additions & 5 deletions app/github.com/[user]/[repo]/tree/[branch]/[...path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,20 @@ const getData = async ({ path, user, repo, branch }: Params) => {
return response;
};

export default async function Page({
params: { path, user, repo, branch },
}: {
params: Params;
}) {
export default async function Page(
props: {
params: Promise<Params>;
}
) {
const params = await props.params;

const {
path,
user,
repo,
branch
} = params;

const data = await getData({ path, user, repo, branch });

return (
Expand Down
8 changes: 7 additions & 1 deletion app/share/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { SharePageComponent } from "./_sharepagecomponent";

export default function Page({ params: { id } }: { params: { id: string } }) {
export default async function Page(props: { params: Promise<{ id: string }> }) {
const params = await props.params;

const {
id
} = params;

return (
<SharePageComponent id={id} />
);
Expand Down
16 changes: 11 additions & 5 deletions app/tutorials/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ import GenerateTemplate from "@/components/tutorial/generate-template";
import GenerateTemplateSolidity from "@/components/tutorial/generate-template-solidity";
import "./page.scss";

export default async function Page({
params: { id },
}: {
params: { id: string };
}) {
export default async function Page(
props: {
params: Promise<{ id: string }>;
}
) {
const params = await props.params;

const {
id
} = params;

let res = { default: "" };
try {
res = await import("./_content/" + id + "/" + id + ".mdx");
Expand Down
11 changes: 9 additions & 2 deletions app/workspace/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use client";
"use client";;
import { use } from "react";

import TopBottom from "@/components/top-bottom";
import {
Expand All @@ -10,7 +11,13 @@ import Cli from "@/components/workspace/cli";
import Editor from "@/components/workspace/editor";
import LeftSide from "@/components/left-side";

export default function Page({params: {id}}: {params: {id: string}}) {
export default function Page(props: {params: Promise<{id: string}>}) {
const params = use(props.params);

const {
id
} = params;

return (
<ResizablePanelGroup direction="horizontal" className="border">
<LeftSide name={id} />
Expand Down
6 changes: 1 addition & 5 deletions app/workspaces/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { WorkspaceForm } from "@/components/new-workspace-form";
import { FileUpload } from "@/components/workspace/file-upload";
import { getTemplateNames } from "@/data/template";
import dynamic from "next/dynamic";

const Existing = dynamic(() => import("@/components/workspace/existing"), {
ssr: false,
});
import Existing from "@/components/workspace/existing";

export default async function Page() {
const templateOptions = await getTemplateNames();
Expand Down
7 changes: 5 additions & 2 deletions lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,12 @@ export function getSolidityEnabled() {
}

export function getFaucetUrl() {
return process.env["NEXT_PUBLIC_FAUCET_API_URL"];
// https://nextjs.org/docs/app/building-your-application/configuring/environment-variables#bundling-environment-variables-for-the-browser:~:text=Note%20that%20dynamic%20lookups%20will%20not%20be%20inlined%2C%20such%20as%3A
const varName = "NEXT_PUBLIC_FAUCET_API_URL";
return process.env[varName];
}

export function getGoogleCaptchaSitekey() {
return process.env["NEXT_PUBLIC_GOOGLE_CAPTCHA_SITEKEY"];
const varName = "NEXT_PUBLIC_GOOGLE_CAPTCHA_SITEKEY";
return process.env[varName];
}
Loading

0 comments on commit 793b6c3

Please sign in to comment.