mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 05:39:11 +03:00
force-static
This commit is contained in:
1 parent
1718795529
commit
1783287f97
4 files changed
+7
-28
No files matched your search
@@ -1,11 +1,10 @@
|
||||
import { draftMode } from 'next/headers'
|
||||
import BlogPostClient from './BlogPostClient'
|
||||
import { getAllPostSlugs, getPostdata, getSortedPosts } from 'lib/posts'
|
||||
import { getAllCMSPostSlugs, getCMSPostBySlug } from 'lib/get-cms-posts'
|
||||
import { draftMode } from 'next/headers'
|
||||
|
||||
import type { Blog, BlogData, PostReturnType } from 'types/post'
|
||||
|
||||
import BlogPostClient from './BlogPostClient'
|
||||
|
||||
type MatterReturn = {
|
||||
data: BlogData
|
||||
content: string
|
||||
|
||||
@@ -14,7 +14,7 @@ export async function generateStaticParams() {
|
||||
return categories.map((category: string) => ({ category }))
|
||||
}
|
||||
|
||||
export const revalidate = 600
|
||||
export const dynamic = 'force-static'
|
||||
|
||||
export async function generateMetadata({ params }: { params: Params }): Promise<Metadata> {
|
||||
const capitalizedCategory = startCase(params.category.replaceAll('-', ' '))
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
import fs from 'fs'
|
||||
import type { Metadata } from 'next'
|
||||
import { generateRss } from 'lib/rss'
|
||||
import BlogClient from './BlogClient'
|
||||
import { getSortedPosts } from 'lib/posts'
|
||||
import { getAllCMSPosts } from 'lib/get-cms-posts'
|
||||
import BlogClient from './BlogClient'
|
||||
import type { Metadata } from 'next'
|
||||
|
||||
export const dynamic = 'force-static'
|
||||
|
||||
@@ -33,25 +31,7 @@ export default async function BlogPage() {
|
||||
return dateB - dateA
|
||||
})
|
||||
|
||||
// Generate RSS feed from static posts
|
||||
const rss = generateRss(allPostsData)
|
||||
try {
|
||||
fs.writeFileSync('./public/rss.xml', rss)
|
||||
} catch {}
|
||||
|
||||
// Generate PlanetPG author feeds
|
||||
try {
|
||||
const planetPgPosts = allPostsData.filter((post: any) => post.tags?.includes('planetpg'))
|
||||
const planetPgAuthors = planetPgPosts.map((post: any) => post.author.split(','))
|
||||
const uniquePlanetPgAuthors = new Set(([] as string[]).concat(...(planetPgAuthors as any)))
|
||||
uniquePlanetPgAuthors.forEach((author) => {
|
||||
const authorPosts = planetPgPosts.filter((post: any) => post.author.includes(author))
|
||||
if (authorPosts.length > 0) {
|
||||
const authorRss = generateRss(authorPosts, author as string)
|
||||
fs.writeFileSync(`./public/planetpg-${author}-rss.xml`, authorRss)
|
||||
}
|
||||
})
|
||||
} catch {}
|
||||
// RSS writing moved out of runtime to avoid tracing the entire public directory into serverless bundles
|
||||
|
||||
return <BlogClient blogs={allPostsData as any} />
|
||||
}
|
||||
@@ -14,7 +14,7 @@ export async function generateStaticParams() {
|
||||
return tags.map((tag: string) => ({ tag }))
|
||||
}
|
||||
|
||||
export const revalidate = 600
|
||||
export const dynamic = 'force-static'
|
||||
|
||||
export async function generateMetadata({ params }: { params: Params }): Promise<Metadata> {
|
||||
const capitalizedTag = startCase(params.tag.replaceAll('-', ' '))
|
||||
|
||||
Reference in new issue
Block a user