create-landing-app 0.3.0 → 0.3.2

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.2",
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,10 @@ import { createMetadata } from "@/lib/metadata";
3
3
  import { cache } from "react";
4
4
  import MainPage from "./main-page";
5
5
 
6
- // Cache listing pagessame window as detail pages, tune via NEXT_BLOG_REVALIDATE_SECONDS
7
- export const revalidate = Number(process.env.NEXT_BLOG_REVALIDATE_SECONDS) || 86400;
6
+ // ISR: revalidate every 60s only visited pages regenerate, unvisited stay cached
7
+ // For instant updates on admin publish, use on-demand revalidation: https://nextjs.org/docs/app/building-your-application/data-fetching/incremental-static-regeneration#on-demand-revalidation-with-revalidatepath
8
+ // To disable ISR and always fetch fresh: replace with `export const dynamic = "force-dynamic"`
9
+ export const revalidate = 60;
8
10
 
9
11
  const getCategories = cache(getBlogCategories);
10
12
 
@@ -30,7 +32,7 @@ export default async function Page({
30
32
  params: Promise<{ category: string; lang: string }>;
31
33
  }) {
32
34
  const { category } = await params;
33
- const [categories, { blogs }] = await Promise.all([
35
+ const [categories, blogs] = await Promise.all([
34
36
  getCategories(),
35
37
  getBlogsByCategory({ category, pageSize: 9999 }),
36
38
  ]);
@@ -3,8 +3,10 @@ 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
+ // ISR: revalidate every 60sonly visited pages regenerate, unvisited stay cached
7
+ // For instant updates on admin publish, use on-demand revalidation: https://nextjs.org/docs/app/building-your-application/data-fetching/incremental-static-regeneration#on-demand-revalidation-with-revalidatepath
8
+ // To disable ISR and always fetch fresh: replace with `export const dynamic = "force-dynamic"`
9
+ export const revalidate = 60;
8
10
 
9
11
  export default async function Layout({
10
12
  children,
@@ -6,8 +6,10 @@ import { BlogDetailView } from "./blog-detail-view";
6
6
  import Navbar from "@/components/navs/navbar";
7
7
  import FooterSection from "@/components/sections/footer-section";
8
8
 
9
- // Cache this page's HTMLserve stale + regenerate in background after expiry
10
- export const revalidate = Number(process.env.NEXT_BLOG_REVALIDATE_SECONDS) || 86400;
9
+ // ISR: revalidate every 60sonly visited pages regenerate, unvisited stay cached
10
+ // For instant updates on admin publish, use on-demand revalidation: https://nextjs.org/docs/app/building-your-application/data-fetching/incremental-static-regeneration#on-demand-revalidation-with-revalidatepath
11
+ // To disable ISR and always fetch fresh: replace with `export const dynamic = "force-dynamic"`
12
+ export const revalidate = 60;
11
13
 
12
14
  // Pre-render top 20 blog detail pages at build time; remaining slugs render on first visit then get cached
13
15
  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
  });