-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '30-24-09-format' into 01/09/24-no-unsafe-optional-chaining
- Loading branch information
Showing
49 changed files
with
6,721 additions
and
7,095 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,73 @@ | ||
import { fetchMetadata } from "frames.js/next"; | ||
import { Metadata } from "next"; | ||
import WebappFrame from "@/app/_components/WebappFrame"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { fetchMetadata } from 'frames.js/next'; | ||
import { Metadata } from 'next'; | ||
import WebappFrame from '@/app/_components/WebappFrame'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
interface generateMetadataProps { | ||
params: { | ||
projectName: string; | ||
strategyName: string; | ||
deployment: string; | ||
}; | ||
params: { | ||
projectName: string; | ||
strategyName: string; | ||
deployment: string; | ||
}; | ||
} | ||
|
||
export async function generateMetadata({ | ||
params, | ||
}: generateMetadataProps): Promise<Metadata> { | ||
// get all dirs in the project name and find the one that ends with the project name | ||
const allDirs = fs.readdirSync( | ||
path.join(process.cwd(), "public", "_strategies", params.projectName) | ||
); | ||
export async function generateMetadata({ params }: generateMetadataProps): Promise<Metadata> { | ||
// get all dirs in the project name and find the one that ends with the project name | ||
const allDirs = fs.readdirSync( | ||
path.join(process.cwd(), 'public', '_strategies', params.projectName) | ||
); | ||
|
||
const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName)); | ||
const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName)); | ||
|
||
if (!strategyDir) { | ||
throw new Error( | ||
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}` | ||
); | ||
} | ||
return { | ||
other: { | ||
...(await fetchMetadata( | ||
new URL( | ||
`/frames/${params.projectName}/${params.strategyName}/${params.deployment}`, | ||
process.env.VERCEL_URL | ||
? `https://${process.env.VERCEL_URL}` | ||
: "http://localhost:3000" | ||
) | ||
)), | ||
}, | ||
}; | ||
if (!strategyDir) { | ||
throw new Error( | ||
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}` | ||
); | ||
} | ||
return { | ||
other: { | ||
...(await fetchMetadata( | ||
new URL( | ||
`/frames/${params.projectName}/${params.strategyName}/${params.deployment}`, | ||
process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : 'http://localhost:3000' | ||
) | ||
)) | ||
} | ||
}; | ||
} | ||
|
||
interface homeProps { | ||
params: { | ||
projectName: string; | ||
strategyName: string; | ||
deployment: string; | ||
}; | ||
params: { | ||
projectName: string; | ||
strategyName: string; | ||
deployment: string; | ||
}; | ||
} | ||
|
||
export default async function Home({ params }: homeProps) { | ||
// get all dirs in the project name and find the one that ends with the project name | ||
const allDirs = fs.readdirSync( | ||
path.join(process.cwd(), "public", "_strategies", params.projectName) | ||
); | ||
// get all dirs in the project name and find the one that ends with the project name | ||
const allDirs = fs.readdirSync( | ||
path.join(process.cwd(), 'public', '_strategies', params.projectName) | ||
); | ||
|
||
const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName)); | ||
const strategyDir = allDirs.find((dir) => dir.endsWith(params.strategyName)); | ||
|
||
if (!strategyDir) { | ||
throw new Error( | ||
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}` | ||
); | ||
} | ||
if (!strategyDir) { | ||
throw new Error( | ||
`No directory found for strategy: ${params.strategyName} in project: ${params.projectName}` | ||
); | ||
} | ||
|
||
const filePath = path.join( | ||
process.cwd(), | ||
"public", | ||
"_strategies", | ||
params.projectName, | ||
strategyDir, | ||
`${params.strategyName}.rain` | ||
); | ||
const dotrainText = fs.readFileSync(filePath, "utf8"); | ||
const filePath = path.join( | ||
process.cwd(), | ||
'public', | ||
'_strategies', | ||
params.projectName, | ||
strategyDir, | ||
`${params.strategyName}.rain` | ||
); | ||
const dotrainText = fs.readFileSync(filePath, 'utf8'); | ||
|
||
return ( | ||
<WebappFrame | ||
dotrainText={dotrainText} | ||
deploymentOption={params.deployment} | ||
/> | ||
); | ||
return <WebappFrame dotrainText={dotrainText} deploymentOption={params.deployment} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,46 @@ | ||
import { fetchMetadata } from "frames.js/next"; | ||
import { Metadata } from "next"; | ||
import WebappFrame from "../../_components/WebappFrame"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
import { fetchMetadata } from 'frames.js/next'; | ||
import { Metadata } from 'next'; | ||
import WebappFrame from '../../_components/WebappFrame'; | ||
import fs from 'fs'; | ||
import path from 'path'; | ||
|
||
interface generateMetadataProps { | ||
params: { | ||
projectName: string; | ||
strategyName: string; | ||
}; | ||
params: { | ||
projectName: string; | ||
strategyName: string; | ||
}; | ||
} | ||
|
||
export async function generateMetadata({ | ||
params, | ||
}: generateMetadataProps): Promise<Metadata> { | ||
return { | ||
other: { | ||
...(await fetchMetadata( | ||
new URL( | ||
`/frames/${params.projectName}/${params.strategyName}`, | ||
process.env.VERCEL_URL | ||
? `https://${process.env.VERCEL_URL}` | ||
: "http://localhost:3000" | ||
) | ||
)), | ||
}, | ||
}; | ||
export async function generateMetadata({ params }: generateMetadataProps): Promise<Metadata> { | ||
return { | ||
other: { | ||
...(await fetchMetadata( | ||
new URL( | ||
`/frames/${params.projectName}/${params.strategyName}`, | ||
process.env.VERCEL_URL ? `https://${process.env.VERCEL_URL}` : 'http://localhost:3000' | ||
) | ||
)) | ||
} | ||
}; | ||
} | ||
|
||
interface homeProps { | ||
params: { | ||
projectName: string; | ||
strategyName: string; | ||
}; | ||
params: { | ||
projectName: string; | ||
strategyName: string; | ||
}; | ||
} | ||
|
||
export default async function Home({ params }: homeProps) { | ||
const filePath = path.join( | ||
process.cwd(), | ||
"public", | ||
"_strategies", | ||
params.projectName, | ||
params.strategyName, | ||
`${params.strategyName}.rain` | ||
); | ||
const dotrainText = fs.readFileSync(filePath, "utf8"); | ||
const filePath = path.join( | ||
process.cwd(), | ||
'public', | ||
'_strategies', | ||
params.projectName, | ||
params.strategyName, | ||
`${params.strategyName}.rain` | ||
); | ||
const dotrainText = fs.readFileSync(filePath, 'utf8'); | ||
|
||
return <WebappFrame dotrainText={dotrainText} deploymentOption={null} />; | ||
return <WebappFrame dotrainText={dotrainText} deploymentOption={null} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,27 @@ | ||
import { retrieveProjectData } from "../_services/buildProjectHome"; | ||
import { StrategyCard } from "../_components/StrategyCard"; | ||
import Markdown from "react-markdown"; | ||
import rehypeRaw from "rehype-raw"; | ||
import { retrieveProjectData } from '../_services/buildProjectHome'; | ||
import { StrategyCard } from '../_components/StrategyCard'; | ||
import Markdown from 'react-markdown'; | ||
import rehypeRaw from 'rehype-raw'; | ||
|
||
interface homeProps { | ||
params: { | ||
projectName: string; | ||
}; | ||
params: { | ||
projectName: string; | ||
}; | ||
} | ||
|
||
export default async function ProjectHome({ params }: homeProps) { | ||
const projectData = await retrieveProjectData(params.projectName); | ||
const projectData = await retrieveProjectData(params.projectName); | ||
|
||
return ( | ||
<div className="flex flex-col lg:grid grid-cols-4 xl:grid-cols-5 flex-grow w-full"> | ||
<div className="col-span-2 prose p-8 h-full"> | ||
<Markdown rehypePlugins={[rehypeRaw]}> | ||
{projectData.webappMDText} | ||
</Markdown> | ||
</div> | ||
<div className="flex flex-col gap-y-4 col-span-2 xl:col-span-3 justify-start bg-gray-50 p-8 border-lg border-gray-100"> | ||
{projectData.yamlDatas.map((data) => ( | ||
<StrategyCard data={data} /> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
return ( | ||
<div className="flex flex-col lg:grid grid-cols-4 xl:grid-cols-5 flex-grow w-full"> | ||
<div className="col-span-2 prose p-8 h-full"> | ||
<Markdown rehypePlugins={[rehypeRaw]}>{projectData.webappMDText}</Markdown> | ||
</div> | ||
<div className="flex flex-col gap-y-4 col-span-2 xl:col-span-3 justify-start bg-gray-50 p-8 border-lg border-gray-100"> | ||
{projectData.yamlDatas.map((data) => ( | ||
<StrategyCard data={data} /> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,31 @@ | ||
"use client"; | ||
'use client'; | ||
|
||
import { useRouter } from "nextjs-toploader/app"; | ||
import { Button } from "flowbite-react"; | ||
import { YamlData } from "../_types/yamlData"; | ||
import { useRouter } from 'nextjs-toploader/app'; | ||
import { Button } from 'flowbite-react'; | ||
import { YamlData } from '../_types/yamlData'; | ||
|
||
export const DeploymentCard = ({ | ||
deployment, | ||
slug, | ||
deployment, | ||
slug | ||
}: { | ||
deployment: YamlData["gui"]["deployments"][0]; | ||
slug: string; | ||
deployment: YamlData['gui']['deployments'][0]; | ||
slug: string; | ||
}) => { | ||
const router = useRouter(); | ||
const currentHostname = window.location.hostname; | ||
const handleClick = () => { | ||
router.push(`${slug}/${deployment.deployment}`); | ||
}; | ||
const router = useRouter(); | ||
const currentHostname = window.location.hostname; | ||
const handleClick = () => { | ||
router.push(`${slug}/${deployment.deployment}`); | ||
}; | ||
|
||
return ( | ||
<div className="border rounded-lg p-4 flex flex-col gap-y-8 bg-white justify-between"> | ||
<div className="flex flex-col gap-y-4"> | ||
<div className="text-lg font-semibold">{deployment.name}</div> | ||
<div className="text-gray-500">{deployment.description}</div> | ||
</div> | ||
<Button color="primary" size="sm" onClick={handleClick}> | ||
Deploy | ||
</Button> | ||
</div> | ||
); | ||
return ( | ||
<div className="border rounded-lg p-4 flex flex-col gap-y-8 bg-white justify-between"> | ||
<div className="flex flex-col gap-y-4"> | ||
<div className="text-lg font-semibold">{deployment.name}</div> | ||
<div className="text-gray-500">{deployment.description}</div> | ||
</div> | ||
<Button color="primary" size="sm" onClick={handleClick}> | ||
Deploy | ||
</Button> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.