-
Notifications
You must be signed in to change notification settings - Fork 3.2k
fix SSR of program marketplace pages #4042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
general-adhoc
wants to merge
8
commits into
program-marketplace-categories
Choose a base branch
from
marketplace-ssr-followup
base: program-marketplace-categories
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b543c82
fix SSR of program marketplace pages
general-adhoc 5bfafe9
add cache headers for client filter changes
general-adhoc 69a0739
enhance static page SEO
general-adhoc fc7c487
eliminate flash on page change of filter component
general-adhoc 9fdf678
SEO improvement for crawlers - 404 if program no longer exists
general-adhoc 28a9e13
align public marketplace program eligibility
general-adhoc 0587d93
fix featured query boolean parsing
general-adhoc 3dafee0
align marketplace static params and tighten list page query handling
pepeladeira File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 was deleted.
Oops, something went wrong.
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| import { getNetworkProgram } from "@/lib/fetchers/get-network-program"; | ||
| import { MarketplaceExternalProgramPage } from "@/ui/program-marketplace/external/marketplace-external-program-page"; | ||
| import { generateMarketplaceProgramStaticParams } from "@/ui/program-marketplace/pages/marketplace-program-page"; | ||
| import { | ||
| getMarketplaceCanonicalUrl, | ||
| getMarketplaceProgramHref, | ||
| } from "@/ui/program-marketplace/utils/urls"; | ||
| import { constructMetadata } from "@dub/utils"; | ||
| import { Metadata } from "next"; | ||
|
|
||
| export const revalidate = 3600; | ||
|
|
||
| export async function generateStaticParams() { | ||
| const programParams = await generateMarketplaceProgramStaticParams(); | ||
|
|
||
| return programParams.map(({ slug }) => ({ programSlug: slug[0] })); | ||
| } | ||
|
|
||
| export async function generateMetadata(props: { | ||
| params: Promise<{ programSlug: string }>; | ||
| }): Promise<Metadata> { | ||
| const { programSlug } = await props.params; | ||
|
|
||
| const program = await getNetworkProgram({ slug: programSlug }); | ||
|
|
||
| return constructMetadata({ | ||
| title: program ? program.name : "Program Details", | ||
| description: | ||
| program?.description || | ||
| (program | ||
| ? `Join the ${program.name} affiliate program on Dub's Partner Network.` | ||
| : `Browse and apply to the best SaaS affiliate programs on Dub's Partner Network.`), | ||
| image: program | ||
| ? program.marketplaceHeaderImage || program.logo || undefined | ||
| : undefined, | ||
| canonicalUrl: getMarketplaceCanonicalUrl( | ||
| getMarketplaceProgramHref(programSlug), | ||
| ), | ||
| }); | ||
| } | ||
|
|
||
| export default async function MarketplaceProgramDetailPage(props: { | ||
| params: Promise<{ programSlug: string }>; | ||
| }) { | ||
| const { programSlug } = await props.params; | ||
|
|
||
| return <MarketplaceExternalProgramPage programSlug={programSlug} />; | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { MarketplaceExternalListPage } from "@/ui/program-marketplace/external/marketplace-external-list-page"; | ||
| import { getMarketplaceCanonicalUrl } from "@/ui/program-marketplace/utils/urls"; | ||
| import { constructMetadata } from "@dub/utils"; | ||
| import { Metadata } from "next"; | ||
|
|
||
| // Rendered dynamically so the actual (filtered/sorted/paged) view is produced | ||
| // server-side and hydrates in place — no fallback swap. | ||
| export const dynamic = "force-dynamic"; | ||
|
|
||
| export function generateMetadata(): Metadata { | ||
| return constructMetadata({ | ||
| title: "All Affiliate Programs", | ||
| description: "Browse all affiliate programs on Dub.", | ||
| canonicalUrl: getMarketplaceCanonicalUrl("/marketplace/all"), | ||
| }); | ||
| } | ||
|
|
||
| export default async function MarketplaceAllPage(props: { | ||
| searchParams: Promise<{ [key: string]: string | string[] | undefined }>; | ||
| }) { | ||
| const searchParams = await props.searchParams; | ||
|
|
||
| return ( | ||
| <MarketplaceExternalListPage slug={["all"]} searchParams={searchParams} /> | ||
| ); | ||
| } |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| import { PROGRAM_CATEGORIES_MAP } from "@/lib/network/program-categories"; | ||
| import { MarketplaceExternalListPage } from "@/ui/program-marketplace/external/marketplace-external-list-page"; | ||
| import { | ||
| getMarketplaceCanonicalUrl, | ||
| slugToCategory, | ||
| } from "@/ui/program-marketplace/utils/urls"; | ||
| import { constructMetadata } from "@dub/utils"; | ||
| import { Metadata } from "next"; | ||
| import { notFound } from "next/navigation"; | ||
|
|
||
| // Rendered dynamically so the actual (filtered/sorted/paged) view is produced | ||
| // server-side and hydrates in place — no fallback swap. | ||
| export const dynamic = "force-dynamic"; | ||
|
|
||
| export async function generateMetadata(props: { | ||
| params: Promise<{ categorySlug: string }>; | ||
| }): Promise<Metadata> { | ||
| const year = new Date().getFullYear(); | ||
| const { categorySlug } = await props.params; | ||
| const category = slugToCategory(categorySlug); | ||
|
|
||
| if (!category) { | ||
| return constructMetadata({ title: "Programs" }); | ||
| } | ||
|
|
||
| const categoryMeta = PROGRAM_CATEGORIES_MAP[category]; | ||
| const label = categoryMeta?.label ?? category.replaceAll("_", " "); | ||
|
|
||
| return constructMetadata({ | ||
| title: `Best ${label} Affiliate Programs in ${year}`, | ||
| description: | ||
| categoryMeta?.listPageDescription ?? | ||
| `Browse and apply to ${label.toLowerCase()} affiliate programs on Dub's Partner Network.`, | ||
| canonicalUrl: getMarketplaceCanonicalUrl(`/marketplace/c/${categorySlug}`), | ||
| }); | ||
| } | ||
|
|
||
| export default async function MarketplaceCategoryPage(props: { | ||
| params: Promise<{ categorySlug: string }>; | ||
| searchParams: Promise<{ [key: string]: string | string[] | undefined }>; | ||
| }) { | ||
| const { categorySlug } = await props.params; | ||
| const searchParams = await props.searchParams; | ||
|
|
||
| const category = slugToCategory(categorySlug); | ||
|
|
||
| if (!category) { | ||
| notFound(); | ||
| } | ||
|
|
||
| return ( | ||
| <MarketplaceExternalListPage | ||
| slug={["c", categorySlug]} | ||
| fixedCategory={category} | ||
| searchParams={searchParams} | ||
| /> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import { MarketplaceExternalHomePage } from "@/ui/program-marketplace/external/marketplace-external-home-page"; | ||
| import { getMarketplaceCanonicalUrl } from "@/ui/program-marketplace/utils/urls"; | ||
| import { constructMetadata } from "@dub/utils"; | ||
| import { Metadata } from "next"; | ||
|
|
||
| export const revalidate = 3600; | ||
|
|
||
| export function generateMetadata(): Metadata { | ||
| const year = new Date().getFullYear(); | ||
|
|
||
| return constructMetadata({ | ||
| title: `Best SaaS Affiliate Programs in ${year}`, | ||
| description: `Browse and apply to the best SaaS affiliate programs on Dub's Partner Network.`, | ||
| canonicalUrl: getMarketplaceCanonicalUrl("/marketplace"), | ||
| }); | ||
| } | ||
|
|
||
| export default function MarketplaceHomePage() { | ||
| return <MarketplaceExternalHomePage />; | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| // Cache the public marketplace endpoints at the edge so repeated queries (each | ||
| // filter combination keys on its URL) are absorbed by the CDN instead of hitting | ||
| // the DB. Short browser TTL, longer edge TTL — same pattern as `/api/links/metatags`. | ||
| export const PUBLIC_MARKETPLACE_CACHE_HEADERS = { | ||
| "Cache-Control": "public, max-age=300", | ||
| "Vercel-CDN-Cache-Control": "s-maxage=3600, stale-while-revalidate=86400", | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unifying detail page and sitemap public marketplace eligibility with the following locations:
get-public-network-programs.tsget-public-network-program-filter-counts.tsapi/network/programs/count/route.ts