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
4 changes: 4 additions & 0 deletions apps/origin/app/[category]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Cta from "@/components/cta";
import PageGrid from "@/components/page-grid";
import PageHeader from "@/components/page-header";
import { categories, getCategory } from "@/config/components";
import { absoluteUrl } from "@/lib/canonical";
import { getComponentsByNames } from "@/lib/utils";

type Props = {
Expand All @@ -26,10 +27,12 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
);

const isSingleComponent = components.length === 1;
const alternates = { canonical: absoluteUrl(`/${category.slug}`) };

// Custom title and description for event-calendar
if (category.slug === "event-calendar") {
return {
alternates,
description:
"An event calendar component built with React and Tailwind CSS. Originally built in v0 and currently in early alpha stage.",
title:
Expand All @@ -38,6 +41,7 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
}

return {
alternates,
description: isSingleComponent
? `A beautiful and accessible ${category.name.toLowerCase()} component built with React and Tailwind CSS.`
: `A collection of beautiful and accessible ${category.name.toLowerCase()} components built with React and Tailwind CSS.`,
Expand Down
2 changes: 2 additions & 0 deletions apps/origin/app/easings/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import type { Metadata } from "next";
import Easings from "./easings";
import PageHeader from "@/components/page-header";
import { absoluteUrl } from "@/lib/canonical";

export const metadata: Metadata = {
alternates: { canonical: absoluteUrl("/easings") },
description:
"A collection of easing utility classes to enhance your Tailwind CSS animations and transitions.",
title: "Tailwind CSS Easing Classes - coss.com origin",
Expand Down
6 changes: 6 additions & 0 deletions apps/origin/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import type { Metadata } from "next";
import Image from "next/image";
import Link from "next/link";
import SearchButton from "@/components/search-button";
import { SubscribeBottom } from "@/components/subscribe-form";
import { categories } from "@/config/components";
import { absoluteUrl } from "@/lib/canonical";

export const metadata: Metadata = {
alternates: { canonical: absoluteUrl("/") },
};

export default function Page() {
return (
Expand Down
3 changes: 3 additions & 0 deletions apps/origin/app/search/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ import type { Metadata } from "next";
import { Suspense } from "react";
import ComponentsContainer from "./components-container";
import PageHeader from "@/components/page-header";
import { absoluteUrl } from "@/lib/canonical";

export const metadata: Metadata = {
// Filtered views (?tags=…) are the same page.
alternates: { canonical: absoluteUrl("/search") },
description: "Search for components in the UI library.",
title: "Search a UI component",
};
Expand Down
9 changes: 5 additions & 4 deletions apps/origin/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import type { MetadataRoute } from "next";
import { categories } from "@/config/components";
import { absoluteUrl } from "@/lib/canonical";

export default function sitemap(): MetadataRoute.Sitemap {
const home = {
url: "https://coss.com/origin",
url: absoluteUrl("/"),
};
const search = {
url: "https://coss.com/origin/search",
url: absoluteUrl("/search"),
};
const easings = {
url: "https://coss.com/origin/easings",
url: absoluteUrl("/easings"),
};
const categoryPages = categories.map((category) => ({
url: `https://coss.com/origin/${category.slug}`,
url: absoluteUrl(`/${category.slug}`),
}));

return [home, ...categoryPages, search, easings];
Expand Down
44 changes: 40 additions & 4 deletions apps/origin/components/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,50 @@
const COSS_URL = "https://coss.com";

/** coss.com's pages worth knowing about, linked from the footer. */
const COSS_LINKS = [
{ href: "/products", label: "Products" },
{ href: "/products/email", label: "Email API" },
{ href: "/products/sms", label: "SMS API" },
{ href: "/products/scheduling", label: "Scheduling API" },
{ href: "/docs", label: "Docs" },
{ href: "/blog", label: "Blog" },
];

export default function Footer() {
return (
<footer className="relative mt-16 py-8 before:absolute before:-inset-x-32 before:top-0 before:h-px before:bg-[linear-gradient(to_right,--theme(--color-border/.3),--theme(--color-border)_200px,--theme(--color-border)_calc(100%-200px),--theme(--color-border/.3))] md:mt-20">
<div
aria-hidden="true"
className="before:absolute before:-top-px before:-left-12 before:z-10 before:-ml-px before:size-[3px] before:bg-ring/50 after:absolute after:-top-px after:-right-12 after:z-10 after:-mr-px after:size-[3px] after:bg-ring/50"
/>
<div className="flex justify-between gap-2 max-sm:flex-col max-sm:text-center">
<p className="text-muted-foreground text-sm">
&copy; {new Date().getFullYear()} coss.com
</p>
<div className="flex justify-between gap-x-8 gap-y-3 text-muted-foreground text-sm max-sm:text-center max-md:flex-col">
<div className="flex flex-col gap-1">
<p>
Free and open source, funded by{" "}
<a
className="font-medium text-foreground underline-offset-4 hover:underline"
href={`${COSS_URL}/`}
>
coss.com
</a>
: one API for email, SMS, scheduling and more.
</p>
<p>&copy; {new Date().getFullYear()} coss.com</p>
</div>
<nav aria-label="coss.com">
<ul className="flex flex-wrap gap-x-4 gap-y-1 max-sm:justify-center">
{COSS_LINKS.map((link) => (
<li key={link.href}>
<a
className="underline-offset-4 hover:text-foreground hover:underline"
href={`${COSS_URL}${link.href}`}
>
{link.label}
</a>
</li>
))}
</ul>
</nav>
</div>
</footer>
);
Expand Down
3 changes: 2 additions & 1 deletion apps/origin/components/top-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { ArrowUpRightIcon } from "lucide-react";

export default function TopBanner() {
const gatewayOrigin = process.env.NEXT_PUBLIC_COSS_UI_URL || "";
const gatewayHome = gatewayOrigin ? `${gatewayOrigin}/` : "/";
// No trailing slash: coss.com/ui/ redirects to coss.com/ui, the canonical.
const gatewayHome = gatewayOrigin ? gatewayOrigin.replace(/\/$/, "") : "/";

return (
<div className="dark relative bg-zinc-900 px-4 text-foreground/80">
Expand Down
12 changes: 12 additions & 0 deletions apps/origin/lib/canonical.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/** Where this app is served in production (its basePath on coss.com). */
export const SITE_URL = "https://coss.com/origin";

/**
* A page's absolute URL on coss.com, exactly as the sitemap lists it: the
* basePath included, no trailing slash. Pages use it as their canonical, so
* copies of a page (query strings, preview deployments) all point search
* engines at one URL.
*/
export function absoluteUrl(path = "/"): string {
return path === "/" ? SITE_URL : `${SITE_URL}${path}`;
}
18 changes: 12 additions & 6 deletions apps/ui/app/api/raw/[...slug]/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import fs from "node:fs/promises";
import path from "node:path";
import { type NextRequest, NextResponse } from "next/server";
import { absoluteUrl } from "@/lib/canonical";

export async function GET(
_request: NextRequest,
Expand Down Expand Up @@ -37,13 +38,18 @@ export async function GET(
content = await fs.readFile(mdPath, "utf-8");
}

const headers: Record<string, string> = {
"Cache-Control": "public, max-age=3600",
"Content-Type": "text/plain; charset=utf-8",
};
// `/docs/<page>.md` is a copy of the docs page: point search engines at it.
if (slug[0] === "docs") {
const page = `/${slug.join("/")}`.replace(/\.mdx?$/, "");
headers.Link = `<${absoluteUrl(page)}>; rel="canonical"`;
}

// Return raw markdown with appropriate headers
return new NextResponse(content, {
headers: {
"Cache-Control": "public, max-age=3600",
"Content-Type": "text/plain; charset=utf-8",
},
});
return new NextResponse(content, { headers });
} catch {
return NextResponse.json({ error: "File not found" }, { status: 404 });
}
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/app/chat/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { SiteFooter } from "@coss/ui/shared/site-footer";
import type { Metadata } from "next";
import { ChatShowcase } from "./chat-showcase";
import { absoluteUrl } from "@/lib/canonical";

export const metadata: Metadata = {
alternates: { canonical: absoluteUrl("/chat") },
title: "Chat UI — Make room for conversation — coss ui",
description:
"Beautifully crafted React chat components. Explore replies, reactions, mentions, and every state in between. Built with Base UI, Tailwind CSS, and Motion.",
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/app/docs/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ScrollArea } from "@/registry/default/ui/scroll-area";
import { DocsCopyPage } from "@/components/docs-copy-page";
import { DocsTableOfContents } from "@/components/docs-toc";
import { SiteFooter } from "@/components/site-footer";
import { absoluteUrl } from "@/lib/canonical";
import { source } from "@/lib/source";
import { mdxComponents } from "@/mdx-components";

Expand Down Expand Up @@ -36,6 +37,7 @@ export async function generateMetadata(props: {
}

return {
alternates: { canonical: absoluteUrl(page.url) },
description: doc.description,
title: `${doc.title} - coss ui`,
};
Expand Down
2 changes: 2 additions & 0 deletions apps/ui/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import { getCategoryThumbnail } from "@/components/category-thumbnails";
import { PrimitivesBlueprint } from "@/components/primitives-blueprint";
import { PrimitivesMotion } from "@/components/primitives-motion";
import { categories } from "@/config/categories";
import { absoluteUrl } from "@/lib/canonical";
import { PAGES_NEW } from "@/lib/docs";

const description =
"Accessible React components we use to build Cal.com, powered by Base UI and styled with Tailwind CSS. Designed for developers and AI, with source code you can make your own.";
const particleCount = particles.length;

export const metadata: Metadata = {
alternates: { canonical: absoluteUrl("/") },
description,
title: "A modern React UI component library – coss ui",
};
Expand Down
3 changes: 3 additions & 0 deletions apps/ui/app/particles/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ import { ParticlesDisplay } from "./particles-display";
import SearchContainer from "./search-container";
import { ParticlesBlueprint } from "@/components/particles-blueprint";
import { ParticlesMotion } from "@/components/particles-motion";
import { absoluteUrl } from "@/lib/canonical";

const particleCount = particles.length;

const description = `Explore ${particleCount} ready-to-use UI patterns built from coss ui components. Copy the code, customize the details, and make them part of your product.`;

export const metadata: Metadata = {
// Filtered views (?tags=…) are the same page.
alternates: { canonical: absoluteUrl("/particles") },
description,
title: "Build more with Particles – coss ui",
};
Expand Down
9 changes: 5 additions & 4 deletions apps/ui/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import type { MetadataRoute } from "next";
import { absoluteUrl } from "@/lib/canonical";
import { source } from "@/lib/source";

export default function sitemap(): MetadataRoute.Sitemap {
const pages = source.getPages();

return [
{ url: "https://coss.com/ui" },
{ url: "https://coss.com/ui/particles" },
{ url: "https://coss.com/ui/chat" },
{ url: absoluteUrl("/") },
{ url: absoluteUrl("/particles") },
{ url: absoluteUrl("/chat") },
...pages.map((page) => ({
url: `https://coss.com/ui${page.url}`,
url: absoluteUrl(page.url),
})),
];
}
35 changes: 32 additions & 3 deletions apps/ui/components/site-footer.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
export function SiteFooter() {
const gatewayOrigin = process.env.NEXT_PUBLIC_COSS_URL || "https://coss.com";
const gatewayHome = `${gatewayOrigin.replace(/\/$/, "")}/`;
const gatewayOrigin = (
process.env.NEXT_PUBLIC_COSS_URL || "https://coss.com"
).replace(/\/$/, "");
const gatewayHome = `${gatewayOrigin}/`;
const linkClassName = "font-medium underline-offset-4 hover:underline";

return (
<footer className="flex flex-col gap-0.5">
Expand All @@ -15,7 +18,7 @@ export function SiteFooter() {
<p className="text-muted-foreground text-sm">
Built by and for the team of{" "}
<a
className="font-medium underline-offset-4 hover:underline"
className={linkClassName}
href="https://cal.com"
rel="noopener noreferrer"
target="_blank"
Expand All @@ -25,6 +28,32 @@ export function SiteFooter() {
, Inc. — the leading commercial open source company
(&ldquo;coss&rdquo;).
</p>
<p className="text-muted-foreground text-sm">
The same team builds{" "}
<a className={linkClassName} href={gatewayHome}>
coss.com
</a>
: one API for{" "}
<a className={linkClassName} href={`${gatewayOrigin}/products/email`}>
email
</a>
,{" "}
<a className={linkClassName} href={`${gatewayOrigin}/products/sms`}>
SMS
</a>
,{" "}
<a
className={linkClassName}
href={`${gatewayOrigin}/products/scheduling`}
>
scheduling
</a>{" "}
and{" "}
<a className={linkClassName} href={`${gatewayOrigin}/products`}>
more
</a>
.
</p>
</footer>
);
}
11 changes: 11 additions & 0 deletions apps/ui/lib/canonical.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { appConfig } from "@/lib/config";

/**
* A page's absolute URL on coss.com, exactly as the sitemap lists it: the
* basePath included, no trailing slash. Pages use it as their canonical, so
* copies of a page (query strings, preview deployments, raw Markdown) all
* point search engines at one URL.
*/
export function absoluteUrl(path = "/"): string {
return path === "/" ? appConfig.url : `${appConfig.url}${path}`;
}
Loading
Loading