Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
20 changes: 14 additions & 6 deletions src/pages/meta/plugins/group-[cls].svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ export const prerender = false

export async function GET({ request, params }: { request: any; params: { cls: string } }) {
const cls = params.cls
const metadata = await $fetchApiCached<PluginMetadata>(`/plugins/metadata/group/${cls}`)
if (!cls || cls === "undefined" || cls === "null") {
return new Response("Not found", { status: 404 })
}

const category = "Plugins"
const title = metadata.title
const description = metadata.description
const image = metadata.icon
let metadata: PluginMetadata
try {
metadata = await $fetchApiCached<PluginMetadata>(`/plugins/metadata/group/${cls}`)
} catch {
return new Response("Not found", { status: 404 })
}

const svgString = generate(request, category as string, title as string, image, description)
if (!metadata?.title) {
return new Response("Not found", { status: 404 })
}

const svgString = generate(request, "Plugins", metadata.title, metadata.icon, metadata.description)

return new Response(svgString, {
headers: {
Expand Down
7 changes: 5 additions & 2 deletions src/utils/plugins/buildPluginPageProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,11 @@ export function buildPluginPageProps(input: BuildPluginPagePropsInput) {
),
)

const ogImage = effectiveSubGroup
? `/meta/plugins/group-${subgroups.find((r) => slugify(r.title) === effectiveSubGroup)?.subGroup}.svg`
const matchedSubGroup = effectiveSubGroup
? subgroups.find((r) => slugify(r.title) === effectiveSubGroup)?.subGroup
: undefined
const ogImage = matchedSubGroup
? `/meta/plugins/group-${matchedSubGroup}.svg`
: `/meta/plugins/${pluginType ?? pluginName}.svg`

const prunedRootPlugin = rootPlugin ? prunePluginsForSidebar([rootPlugin])[0] : undefined
Expand Down
Loading