create-landing-app 0.3.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/nextjs/base/.env.example +0 -1
- package/templates/nextjs/optional/sections/blog/files/app/[lang]/blogs/(list)/[category]/page.tsx +3 -3
- package/templates/nextjs/optional/sections/blog/files/app/[lang]/blogs/(list)/layout.tsx +2 -2
- package/templates/nextjs/optional/sections/blog/files/app/[lang]/blogs/detail/[slugNews]/page.tsx +1 -1
- package/templates/nextjs/optional/sections/blog/files/components/blogs/blog-component.tsx +10 -1
package/package.json
CHANGED
package/templates/nextjs/optional/sections/blog/files/app/[lang]/blogs/(list)/[category]/page.tsx
CHANGED
|
@@ -3,8 +3,8 @@ import { createMetadata } from "@/lib/metadata";
|
|
|
3
3
|
import { cache } from "react";
|
|
4
4
|
import MainPage from "./main-page";
|
|
5
5
|
|
|
6
|
-
// Cache listing pages —
|
|
7
|
-
export const revalidate =
|
|
6
|
+
// Cache listing pages for 24h — adjust this value to tune staleness
|
|
7
|
+
export const revalidate = 86400;
|
|
8
8
|
|
|
9
9
|
const getCategories = cache(getBlogCategories);
|
|
10
10
|
|
|
@@ -30,7 +30,7 @@ export default async function Page({
|
|
|
30
30
|
params: Promise<{ category: string; lang: string }>;
|
|
31
31
|
}) {
|
|
32
32
|
const { category } = await params;
|
|
33
|
-
const [categories,
|
|
33
|
+
const [categories, blogs] = await Promise.all([
|
|
34
34
|
getCategories(),
|
|
35
35
|
getBlogsByCategory({ category, pageSize: 9999 }),
|
|
36
36
|
]);
|
|
@@ -3,8 +3,8 @@ import FooterSection from "@/components/sections/footer-section";
|
|
|
3
3
|
import LayoutBlogs from "@/components/navs/layout-blogs";
|
|
4
4
|
import { getBlogCategories } from "@/lib/blog-api";
|
|
5
5
|
|
|
6
|
-
// Nav categories are static data — cache
|
|
7
|
-
export const revalidate =
|
|
6
|
+
// Nav categories are static data — cache for 24h
|
|
7
|
+
export const revalidate = 86400;
|
|
8
8
|
|
|
9
9
|
export default async function Layout({
|
|
10
10
|
children,
|
package/templates/nextjs/optional/sections/blog/files/app/[lang]/blogs/detail/[slugNews]/page.tsx
CHANGED
|
@@ -7,7 +7,7 @@ import Navbar from "@/components/navs/navbar";
|
|
|
7
7
|
import FooterSection from "@/components/sections/footer-section";
|
|
8
8
|
|
|
9
9
|
// Cache this page's HTML — serve stale + regenerate in background after expiry
|
|
10
|
-
export const revalidate =
|
|
10
|
+
export const revalidate = 86400;
|
|
11
11
|
|
|
12
12
|
// Pre-render top 20 blog detail pages at build time; remaining slugs render on first visit then get cached
|
|
13
13
|
export async function generateStaticParams() {
|
|
@@ -13,12 +13,21 @@ async function fetchBlogs(category: string): Promise<Blog[]> {
|
|
|
13
13
|
return data.blogs;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export default function BlogComponent({
|
|
16
|
+
export default function BlogComponent({
|
|
17
|
+
category,
|
|
18
|
+
categories = [],
|
|
19
|
+
blogs: initialBlogs,
|
|
20
|
+
}: {
|
|
21
|
+
category: string;
|
|
22
|
+
categories?: BlogCategory[];
|
|
23
|
+
blogs?: Blog[];
|
|
24
|
+
}) {
|
|
17
25
|
const isMobile = useIsMobile();
|
|
18
26
|
|
|
19
27
|
const { data, isError, isPending } = useQuery<Blog[]>({
|
|
20
28
|
queryKey: ["/blogs/list-all", { category }],
|
|
21
29
|
queryFn: () => fetchBlogs(category),
|
|
30
|
+
initialData: initialBlogs,
|
|
22
31
|
retry: 0,
|
|
23
32
|
refetchOnWindowFocus: false,
|
|
24
33
|
});
|