-
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.
add schema editor component and hook up add
- Loading branch information
Showing
13 changed files
with
392 additions
and
192 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import { type Plugin, PluginPage } from "@/components/plugin-page"; | ||
import { getPluginData, getPlugins } from "@/lib/registry"; | ||
import type { Metadata } from "next"; | ||
import { NextPage } from "next"; | ||
import { notFound, useRouter } from "next/navigation"; | ||
|
@@ -20,51 +21,12 @@ const Page = async ({ params }: { params: { slug: string[] } }) => { | |
return <PluginPage {...pluginData} versions={versions} />; | ||
}; | ||
|
||
/** | ||
* Returns versions in descending order | ||
* | ||
* @param title The title of the plugin | ||
* @param version The version of the plugin. If not provided, the latest version is returned | ||
*/ | ||
const getPluginData = async ( | ||
title: string, | ||
version?: string, | ||
): Promise<Plugin> => { | ||
const versions = [ | ||
{ version: "0.1.2", date: new Date() }, | ||
{ version: "0.1.1", date: new Date() }, | ||
{ version: "0.1.0", date: new Date() }, | ||
]; | ||
|
||
return { | ||
title, | ||
version: | ||
versions.find((v) => v.version === version)?.version ?? | ||
versions[0].version, | ||
versions, | ||
configSchema: | ||
'{"properties": { "config": { "properties": { "ip": { "description": "The ip address of the device to connect to.", "items": [ { "format": "uint8", "minimum": 0.0, "type": "integer" }, { "format": "uint8", "minimum": 0.0, "type": "integer" }, { "format": "uint8", "minimum": 0.0, "type": "integer" }, { "format": "uint8", "minimum": 0.0, "type": "integer" } ], "maxItems": 4, "minItems": 4, "type": "array" } }, "required": [ "ip" ], "type": "object" }, "plugin": { "const": "[email protected]" }},"required": [ "plugin", "config"],"type": "object"}', | ||
author: "Alex Lyon", | ||
source: "https://github.com/arlyon/litehouse", | ||
capabilities: ["http-client"], | ||
homepage: "https://github.com/arlyon/litehouse", | ||
description: "A real cool plugin!", | ||
size: 60345, | ||
}; | ||
}; | ||
|
||
const getPlugins = async (): Promise< | ||
{ title: string; versions: string[] }[] | ||
> => { | ||
return [{ title: "tasmota", versions: ["0.1.2", "0.1.1", "0.1.0"] }]; | ||
}; | ||
|
||
export default Page; | ||
|
||
export async function generateStaticParams() { | ||
const results = (await getPlugins()).flatMap((page) => | ||
[undefined, ...page.versions].map((version) => ({ | ||
slug: [page.title, version].filter((x) => x !== undefined), | ||
slug: [page.title, version?.version].filter((x) => x !== undefined), | ||
})), | ||
); | ||
return results; | ||
|
@@ -82,8 +44,6 @@ export async function generateMetadata({ | |
pluginData.versions.find((v) => v.version === params.slug[1]) ?? | ||
pluginData.versions[0]; | ||
|
||
console.log(params); | ||
|
||
// if (page == null) notFound(); | ||
|
||
return { | ||
|
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
Binary file not shown.
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
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
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
Oops, something went wrong.