-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: download snippet generation (#7351)
* feat: download snippet generation * feat: changed approach * chore: simplify and reduce bundle size * chore: reduce bundle * chore: minor code fixes * chore: more code review * feat: introduced skeleton and animation * chore: synchronous shiki * chore: prevent internal errors * chore: attempt to handle null situations * fix: attempt to fix vercel env * fix: erroneous env usage for fetch * chore: fix select styles * chore: updated allowlist for env vars * feat: streamline detectos (only run query once) * fix: avatar rendering and avatar group margins * fix: pass ref * chore: optimized release provider memo * chore: next-image mock * Update crowdin.yml (#7353) * chore: improved loading state * Apply suggestions from code review Co-authored-by: Caner Akdas <canerakdas@gmail.com> Signed-off-by: Claudio W <cwunder@gnome.org> * chore: correct fixes * fix: unit tests * chore: final code review * fix: server component test * fix: rsc still risky for storybook --------- Signed-off-by: Claudio W <cwunder@gnome.org> Co-authored-by: Andriy Poznakhovskyy <andriy@crowdin.com> Co-authored-by: Caner Akdas <canerakdas@gmail.com>
- Loading branch information
1 parent
e56edcc
commit 8b643f6
Showing
85 changed files
with
5,170 additions
and
2,394 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
37 changes: 37 additions & 0 deletions
37
apps/site/app/[locale]/next-data/download-snippets/route.tsx
This file contains 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,37 @@ | ||
import provideDownloadSnippets from '@/next-data/providers/downloadSnippets'; | ||
import { defaultLocale } from '@/next.locales.mjs'; | ||
|
||
type DynamicStaticPaths = { locale: string }; | ||
type StaticParams = { params: Promise<DynamicStaticPaths> }; | ||
|
||
// This is the Route Handler for the `GET` method which handles the request | ||
// for generating JSON data for Download Snippets | ||
// @see https://nextjs.org/docs/app/building-your-application/routing/router-handlers | ||
export const GET = async (_: Request, props: StaticParams) => { | ||
const params = await props.params; | ||
|
||
// Retrieve all available Download snippets for a given locale if available | ||
const snippets = provideDownloadSnippets(params.locale); | ||
|
||
// We append always the default/fallback snippets when a result is found | ||
return Response.json(snippets, { | ||
status: snippets !== undefined ? 200 : 404, | ||
}); | ||
}; | ||
|
||
// This function generates the static paths that come from the dynamic segments | ||
// `[locale]/next-data/download-snippets/` this will return a default value as we don't want to | ||
// statically generate this route as it is compute-expensive. | ||
// Hence we generate a fake route just to satisfy Next.js requirements. | ||
export const generateStaticParams = async () => [ | ||
{ locale: defaultLocale.code }, | ||
]; | ||
|
||
// Enforces that this route is cached and static as much as possible | ||
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamic | ||
export const dynamic = 'force-static'; | ||
|
||
// Ensures that this endpoint is invalidated and re-executed every X minutes | ||
// so that when new deployments happen, the data is refreshed | ||
// @see https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#revalidate | ||
export const revalidate = 300; |
This file contains 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 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.