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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-landing-app",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Create a production-ready Next.js landing page with one command",
5
5
  "type": "module",
6
6
  "bin": {
@@ -9,7 +9,6 @@ NEXT_PUBLIC_GA_ID=
9
9
  # Expected endpoints: GET /blogs?applicationFilter=..., GET /blogs/:slug, GET /categories
10
10
  NEXT_PUBLIC_BLOG_API=
11
11
  BLOG_API_APPLICATION=ndachain
12
- NEXT_BLOG_REVALIDATE_SECONDS=86400
13
12
 
14
13
  # S3 / Storage (optional)
15
14
  NEXT_PUBLIC_S3_DOMAIN=
@@ -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 — same window as detail pages, tune via NEXT_BLOG_REVALIDATE_SECONDS
7
- export const revalidate = Number(process.env.NEXT_BLOG_REVALIDATE_SECONDS) || 86400;
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, { blogs }] = await Promise.all([
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 window tunable via NEXT_BLOG_REVALIDATE_SECONDS
7
- export const revalidate = Number(process.env.NEXT_BLOG_REVALIDATE_SECONDS) || 86400;
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,
@@ -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 = Number(process.env.NEXT_BLOG_REVALIDATE_SECONDS) || 86400;
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({ category, categories = [] }: { category: string; categories?: BlogCategory[] }) {
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
  });