Skip to content
Merged
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
2 changes: 1 addition & 1 deletion apps/www/app/(marketing)/showcase/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default async function PagePage({ params }: PageProps) {
</h3>
<ShowcaseCard
title={doc.title ?? ""}
href={page.url}
href={doc.href ?? page.url}
image={doc.image ?? ""}
affiliation={doc.affiliation ?? ""}
/>
Expand Down
13 changes: 13 additions & 0 deletions apps/www/components/sections/showcase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ import { ChevronRightIcon } from "@radix-ui/react-icons"
import { showcaseSource } from "@/lib/source"
import { Marquee } from "@/registry/magicui/marquee"

function isExternalHref(href: string) {
try {
const url = new URL(href)
return url.protocol === "http:" || url.protocol === "https:"
} catch {
return false
}
}

export interface ShowcaseCardProps {
title: string
image: string
Expand All @@ -17,9 +26,13 @@ export function ShowcaseCard({
href,
affiliation,
}: ShowcaseCardProps) {
const isExternal = isExternalHref(href)
return (
<Link
href={href}
prefetch={isExternal ? false : undefined}
rel={isExternal ? "noopener noreferrer" : undefined}
target={isExternal ? "_blank" : undefined}
className="group relative flex cursor-pointer flex-col gap-2 overflow-hidden"
>
<Image
Expand Down
1 change: 1 addition & 0 deletions apps/www/source.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const showcase = defineDocs({
schema: frontmatterSchema.extend({
affiliation: z.string().optional(),
featured: z.boolean().optional().default(false),
href: z.string().url().optional(),
image: z.string().optional(),
}),
},
Expand Down
Loading