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: 2 additions & 0 deletions apps/cms/src/components/sections/highlights.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
"packages_newest",
"templates_highlighted",
"templates_newest",
"integrations_highlighted",
"integrations_newest",
"recipes_highlighted",
"recipes_newest",
"showcases_highlighted",
Expand Down
2 changes: 2 additions & 0 deletions apps/cms/types/generated/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ export interface SectionsHighlights extends Struct.ComponentSchema {
'packages_newest',
'templates_highlighted',
'templates_newest',
'integrations_highlighted',
'integrations_newest',
'recipes_highlighted',
'recipes_newest',
'showcases_highlighted',
Expand Down
3 changes: 3 additions & 0 deletions apps/web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ NEXT_PUBLIC_SEARCH_API_KEY=E8H-DDQUGhZhFWhTq263Ohd80UErhFmLIFnlQK81oeQ

CMS_BEARER_TOKEN=tobemodified

# Document ID of the CTA block to render on community content pages (user, org, template, package)
COMMUNITY_CTA_ID=

STRAPI_UI_URL=tobemodified
STRAPI_UI_TOKEN=tobemodified
NEXT_PUBLIC_STRAPI_UI_URL=tobemodified
Expand Down
29 changes: 29 additions & 0 deletions apps/web/src/features/cms/lib/community-cta.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import type { GetQueryParams } from "@repo/strapi-client";
import type { Modules, UID } from "@strapi/types";
import { cmsClient } from "@/features/cms/lib/strapi";

const contentType = "api::cta.cta" satisfies UID.ContentType;

const query = {
populate: {
image: true,
button: true,
},
} satisfies GetQueryParams<typeof contentType>;

export type CommunityCTAData = Modules.Documents.Result<
typeof contentType,
typeof query
>;

export async function fetchCommunityCTA(): Promise<CommunityCTAData | null> {
const id = process.env.COMMUNITY_CTA_ID;
if (!id) return null;

try {
const result = await cmsClient.collection(contentType).findOne(id, query);
return result.data;
} catch {
return null;
}
}
9 changes: 6 additions & 3 deletions apps/web/src/features/cms/pages/organization/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { GetQueryParams } from "@repo/strapi-client";
import type { Data, Modules, UID } from "@strapi/types";
import { fetchCommunityCTA } from "@/features/cms/lib/community-cta";
import { cmsClient } from "@/features/cms/lib/strapi";
import { OrganizationTemplate } from "@/features/cms/pages/organization";
import type { RelatedContentItems } from "@/utils/types";
Expand All @@ -21,9 +22,10 @@ type Props = {
};

const OrganizationPage = async ({ documentId }: Props) => {
const document = await cmsClient
.collection(contentType)
.findOne(documentId, query);
const [document, communityCta] = await Promise.all([
cmsClient.collection(contentType).findOne(documentId, query),
fetchCommunityCTA(),
]);

const content: RelatedContentItems = await cmsClient
.fetch(
Expand All @@ -46,6 +48,7 @@ const OrganizationPage = async ({ documentId }: Props) => {
document={document.data}
relatedContent={content}
members={members}
communityCta={communityCta}
/>
);
};
Expand Down
17 changes: 16 additions & 1 deletion apps/web/src/features/cms/pages/organization/template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,25 @@ import { Breadcrumbs } from "@/components/layout/breadcrumbs";
import { Hero, HeroSection } from "@/components/layout/hero";
import { Navigation } from "@/components/layout/navigation";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import type { CommunityCTAData } from "@/features/cms/lib/community-cta";
import { cmsImageUrl } from "@/features/cms/lib/image-url";
import type { OrganizationPageData } from "@/features/cms/pages/organization/page";
import { CTASection } from "@/features/cms/sections/cta/cta";
import type { RelatedContentItems } from "@/utils/types";

type Props = {
document: OrganizationPageData;
relatedContent: RelatedContentItems;
members: Data.ContentType<"plugin::better-auth.user">[];
communityCta?: CommunityCTAData | null;
};

const OrganizationTemplate = ({ document, members, relatedContent }: Props) => {
const OrganizationTemplate = ({
document,
members,
relatedContent,
communityCta,
}: Props) => {
const { templates, packages } = relatedContent;
const noRelatedContent = templates.length === 0 && packages.length === 0;

Expand Down Expand Up @@ -274,6 +282,13 @@ const OrganizationTemplate = ({ document, members, relatedContent }: Props) => {
</TabsContent>
</Tabs>
</Container>
{communityCta && (
<CTASection
section={
{ cta: communityCta } as unknown as Data.Component<"sections.cta">
}
/>
)}
</>
);
};
Expand Down
12 changes: 8 additions & 4 deletions apps/web/src/features/cms/pages/package/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { GetQueryParams } from "@repo/strapi-client";
import type { Modules, UID } from "@strapi/types";
import { fetchCommunityCTA } from "@/features/cms/lib/community-cta";
import { cmsClient } from "@/features/cms/lib/strapi";
import { PackageTemplate } from "@/features/cms/pages/package";

Expand Down Expand Up @@ -37,14 +38,17 @@ type Props = {
};

const PackagePage = async ({ documentId }: Props) => {
const document = await cmsClient
.collection(contentType)
.findOne(documentId, query);
const [document, communityCta] = await Promise.all([
cmsClient.collection(contentType).findOne(documentId, query),
fetchCommunityCTA(),
]);

/**
* @todo Check for any existing security scans on the latest version.
*/
return <PackageTemplate document={document.data} />;
return (
<PackageTemplate document={document.data} communityCta={communityCta} />
);
};

export { PackagePage };
13 changes: 12 additions & 1 deletion apps/web/src/features/cms/pages/package/template.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Button, Container } from "@repo/strapi-ui";
import type { Data } from "@strapi/types";
import { Download, Star } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
Expand All @@ -9,15 +10,18 @@ import { RegistryLogo } from "@/components/content/registry-logo";
import { SidebarSection } from "@/components/content/sidebar-section";
import { VersionSecurityBadge } from "@/components/content/version-info";
import { Navigation } from "@/components/layout/navigation";
import type { CommunityCTAData } from "@/features/cms/lib/community-cta";
import { cmsImageUrl } from "@/features/cms/lib/image-url";
import type { PackagePageData } from "@/features/cms/pages/package";
import { CTASection } from "@/features/cms/sections/cta/cta";
import type { Owner } from "@/utils/types";

type Props = {
document: PackagePageData;
communityCta?: CommunityCTAData | null;
};

const PackageTemplate = ({ document }: Props) => {
const PackageTemplate = ({ document, communityCta }: Props) => {
const categories = (document.categories ?? []) as {
documentId: string;
name: string;
Expand Down Expand Up @@ -177,6 +181,13 @@ const PackageTemplate = ({ document }: Props) => {
</aside>
</div>
</Container>
{communityCta && (
<CTASection
section={
{ cta: communityCta } as unknown as Data.Component<"sections.cta">
}
/>
)}
</>
);
};
Expand Down
12 changes: 8 additions & 4 deletions apps/web/src/features/cms/pages/template/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { GetQueryParams } from "@repo/strapi-client";
import type { Modules, UID } from "@strapi/types";
import { fetchCommunityCTA } from "@/features/cms/lib/community-cta";
import { cmsClient } from "@/features/cms/lib/strapi";
import { TemplateTemplate } from "@/features/cms/pages/template";

Expand Down Expand Up @@ -36,11 +37,14 @@ type Props = {
};

const TemplatePage = async ({ documentId }: Props) => {
const document = await cmsClient
.collection(contentType)
.findOne(documentId, query);
const [document, communityCta] = await Promise.all([
cmsClient.collection(contentType).findOne(documentId, query),
fetchCommunityCTA(),
]);

return <TemplateTemplate document={document.data} />;
return (
<TemplateTemplate document={document.data} communityCta={communityCta} />
);
};

export { TemplatePage };
13 changes: 12 additions & 1 deletion apps/web/src/features/cms/pages/template/template.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Button, Container } from "@repo/strapi-ui";
import type { Data } from "@strapi/types";
import { ExternalLink, Star } from "lucide-react";
import Image from "next/image";
import Link from "next/link";
Expand All @@ -7,15 +8,18 @@ import { GitProviderLogo } from "@/components/content/git-provider-logo";
import { Markdown } from "@/components/content/markdown";
import { SidebarSection } from "@/components/content/sidebar-section/sidebar-section";
import { Navigation } from "@/components/layout/navigation";
import type { CommunityCTAData } from "@/features/cms/lib/community-cta";
import { cmsImageUrl } from "@/features/cms/lib/image-url";
import type { TemplatePageData } from "@/features/cms/pages/template/page";
import { CTASection } from "@/features/cms/sections/cta/cta";
import type { Owner } from "@/utils/types";

type Props = {
document: TemplatePageData;
communityCta?: CommunityCTAData | null;
};

const TemplateTemplate = ({ document }: Props) => {
const TemplateTemplate = ({ document, communityCta }: Props) => {
const categories = (document.categories ?? []) as {
documentId: string;
name: string;
Expand Down Expand Up @@ -184,6 +188,13 @@ const TemplateTemplate = ({ document }: Props) => {
</aside>
</div>
</Container>
{communityCta && (
<CTASection
section={
{ cta: communityCta } as unknown as Data.Component<"sections.cta">
}
/>
)}
</>
);
};
Expand Down
16 changes: 12 additions & 4 deletions apps/web/src/features/cms/pages/user/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { GetQueryParams } from "@repo/strapi-client";
import type { Modules, UID } from "@strapi/types";
import { fetchCommunityCTA } from "@/features/cms/lib/community-cta";
import { cmsClient } from "@/features/cms/lib/strapi";
import { UserTemplate } from "@/features/cms/pages/user";
import type { RelatedContentItems } from "@/utils/types";
Expand All @@ -20,17 +21,24 @@ type Props = {
};

const UserPage = async ({ documentId }: Props) => {
const document = await cmsClient
.collection(contentType)
.findOne(documentId, query);
const [document, communityCta] = await Promise.all([
cmsClient.collection(contentType).findOne(documentId, query),
fetchCommunityCTA(),
]);

const content: RelatedContentItems = await cmsClient
.fetch(
`/users/${document.data.id}/related-content?populate=*&status=published`,
)
.then((res) => res.json());

return <UserTemplate document={document.data} relatedContent={content} />;
return (
<UserTemplate
document={document.data}
relatedContent={content}
communityCta={communityCta}
/>
);
};

export { UserPage };
13 changes: 12 additions & 1 deletion apps/web/src/features/cms/pages/user/template.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Container } from "@repo/strapi-ui";
import type { Data } from "@strapi/types";
import {
AppWindow,
CalendarDays,
Expand All @@ -15,16 +16,19 @@ import { Breadcrumbs } from "@/components/layout/breadcrumbs";
import { Hero, HeroSection } from "@/components/layout/hero";
import { Navigation } from "@/components/layout/navigation";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import type { CommunityCTAData } from "@/features/cms/lib/community-cta";
import { cmsImageUrl } from "@/features/cms/lib/image-url";
import type { UserPageData } from "@/features/cms/pages/user/page";
import { CTASection } from "@/features/cms/sections/cta/cta";
import type { RelatedContentItems } from "@/utils/types";

type Props = {
document: UserPageData;
relatedContent: RelatedContentItems;
communityCta?: CommunityCTAData | null;
};

const UserTemplate = ({ document, relatedContent }: Props) => {
const UserTemplate = ({ document, relatedContent, communityCta }: Props) => {
const { templates, packages } = relatedContent;
const noRelatedContent = templates.length === 0 && packages.length === 0;

Expand Down Expand Up @@ -229,6 +233,13 @@ const UserTemplate = ({ document, relatedContent }: Props) => {
</TabsContent>
</Tabs>
</Container>
{communityCta && (
<CTASection
section={
{ cta: communityCta } as unknown as Data.Component<"sections.cta">
}
/>
)}
</>
);
};
Expand Down
37 changes: 37 additions & 0 deletions apps/web/src/features/cms/sections/highlights/highlights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ async function fetchItems(query: string, amount: number) {
return { type: "template" as const, items: res.data ?? [] };
}

if (query.startsWith("integrations_")) {
const res = await cmsClient
.collection("api::integration.integration")
.find({
...featuredFilter,
sort: ["createdAt:desc"],
pagination: { limit: amount },
populate: {
logo: true,
url_alias: true,
labels: true,
},
});
return { type: "integration" as const, items: res.data ?? [] };
}

if (query.startsWith("community_")) {
const res = await cmsClient.collection("plugin::better-auth.user").find({
sort: [query === "community_newest" ? "createdAt:desc" : "name:asc"],
Expand Down Expand Up @@ -136,6 +152,27 @@ const HighlightsSection = async ({ section }: Props) => {
),
)}

{type === "integration" &&
(items as Data.ContentType<"api::integration.integration">[]).map(
(integration) => (
<ContentCard
key={integration.documentId}
image={{
src: integration.logo
? cmsImageUrl(integration.logo.url)
: "/logo-plugin.png",
alt: integration.logo?.alternativeText ?? "",
size: "S",
}}
link={integration.url_alias?.[0]?.url_path ?? "#"}
badge="Integration"
name={integration.name!}
description={integration.description ?? ""}
labels={integration.labels?.[0]}
/>
),
)}

{type === "user" &&
(items as Data.ContentType<"plugin::better-auth.user">[]).map(
(user) => (
Expand Down
Loading