Skip to content

Commit cdfd572

Browse files
avivkellerefekrskl
andauthored
chore: remove blog data from providers, cache snippets (#8243)
* chore: remove blog data from providers, cache snippets * fixup! * Update apps/site/util/blog.ts Co-authored-by: Efe <dogukankrskl@gmail.com> Signed-off-by: Aviv Keller <me@aviv.sh> * fixup! --------- Signed-off-by: Aviv Keller <me@aviv.sh> Co-authored-by: Efe <dogukankrskl@gmail.com>
1 parent 3bf2753 commit cdfd572

File tree

20 files changed

+257
-279
lines changed

20 files changed

+257
-279
lines changed

apps/site/app/[locale]/feed/[feed]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { NextResponse } from 'next/server';
22

3-
import provideWebsiteFeeds from '#site/next-data/providers/websiteFeeds';
43
import { siteConfig } from '#site/next.json.mjs';
54
import { defaultLocale } from '#site/next.locales.mjs';
5+
import { getFeeds } from '#site/util/feeds';
66

77
type DynamicStaticPaths = { locale: string; feed: string };
88
type StaticParams = { params: Promise<DynamicStaticPaths> };
@@ -14,7 +14,7 @@ export const GET = async (_: Request, props: StaticParams) => {
1414
const params = await props.params;
1515

1616
// Generate the Feed for the given feed type (blog, releases, etc)
17-
const websiteFeed = provideWebsiteFeeds(params.feed);
17+
const websiteFeed = getFeeds(params.feed);
1818

1919
return new NextResponse(websiteFeed, {
2020
headers: { 'Content-Type': 'application/xml' },

apps/site/components/Blog/BlogPostCard/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type BlogPostCardProps = {
1515
category: BlogCategory;
1616
description?: string;
1717
authors?: Array<string>;
18-
date?: Date;
18+
date?: string | Date;
1919
slug?: string;
2020
};
2121

apps/site/components/withBlogCrossLinks.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import type { FC } from 'react';
22

33
import { getClientContext } from '#site/client-context';
44
import CrossLink from '#site/components/Common/CrossLink';
5-
import getBlogData from '#site/next-data/blogData';
65
import type { BlogCategory } from '#site/types';
6+
import { getBlogData } from '#site/util/blog';
77

88
const WithBlogCrossLinks: FC = () => {
99
const { pathname } = getClientContext();

apps/site/components/withDownloadSection.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useLocale } from 'next-intl';
1+
import { getLocale } from 'next-intl/server';
22
import type { FC, PropsWithChildren } from 'react';
33

44
import { getClientContext } from '#site/client-context';
@@ -12,21 +12,22 @@ import {
1212

1313
import type { NodeRelease } from '../types';
1414

15-
// By default the translated languages do not contain all the download snippets
16-
// Hence we always merge any translated snippet with the fallbacks for missing snippets
17-
const fallbackSnippets = provideDownloadSnippets(defaultLocale.code);
18-
1915
type WithDownloadSectionProps = PropsWithChildren<{
2016
releases: Array<NodeRelease>;
2117
}>;
2218

23-
const WithDownloadSection: FC<WithDownloadSectionProps> = ({
19+
const WithDownloadSection: FC<WithDownloadSectionProps> = async ({
2420
releases,
2521
children,
2622
}) => {
27-
const locale = useLocale();
23+
const locale = await getLocale();
24+
25+
const snippets = await provideDownloadSnippets(locale);
26+
27+
// By default the translated languages do not contain all the download snippets
28+
// Hence we always merge any translated snippet with the fallbacks for missing snippets
29+
const fallbackSnippets = await provideDownloadSnippets(defaultLocale.code);
2830

29-
const snippets = provideDownloadSnippets(locale);
3031
const { pathname } = getClientContext();
3132

3233
// Some available translations do not have download snippets translated or have them partially translated

apps/site/layouts/Blog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import BlogHeader from '#site/components/Blog/BlogHeader';
66
import WithBlogCategories from '#site/components/withBlogCategories';
77
import WithFooter from '#site/components/withFooter';
88
import WithNavBar from '#site/components/withNavBar';
9-
import getBlogData from '#site/next-data/blogData';
109
import type { BlogCategory } from '#site/types';
10+
import { getBlogData } from '#site/util/blog';
1111

1212
import styles from './layouts.module.css';
1313

apps/site/next-data/blogData.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

apps/site/next-data/generators/blogData.mjs

Lines changed: 0 additions & 116 deletions
This file was deleted.

apps/site/next-data/providers/blogData.ts

Lines changed: 0 additions & 69 deletions
This file was deleted.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import { cache } from 'react';
1+
'use cache';
22

33
import generateDownloadSnippets from '#site/next-data/generators/downloadSnippets.mjs';
44

5-
const downloadSnippets = await generateDownloadSnippets();
5+
const provideDownloadSnippets = async (language: string) => {
6+
const downloadSnippets = await generateDownloadSnippets();
67

7-
const provideDownloadSnippets = cache((language: string) => {
88
if (downloadSnippets.has(language)) {
99
return downloadSnippets.get(language)!;
1010
}
1111

1212
return [];
13-
});
13+
};
1414

1515
export default provideDownloadSnippets;

apps/site/next-data/providers/websiteFeeds.ts

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)