Skip to content

Commit

Permalink
feat: actually fuck it dont cache for now, next is buggy with it
Browse files Browse the repository at this point in the history
  • Loading branch information
ashgw committed Feb 10, 2024
1 parent 4f1f6b3 commit 7e6835b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/app/actions/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@ import { pub, nextJS } from '@/lib/env';
import type { BlogData } from '@/lib/types/mdx';
import { Maybe } from '@/lib/types/global';
import { BLOG_API_URI } from '@/lib/constants';


const VALIDATE_EVERY_SECS = 7200;
const SITE_URL =
nextJS.NEXT_NODE_ENV == 'production' ? pub.SITE_URL_PROD : pub.SITE_URL_DEV;

export async function getPost(slug: string): Promise<Maybe<BlogData>> {
try {
const response = await fetch(SITE_URL + BLOG_API_URI, {
next: { revalidate: VALIDATE_EVERY_SECS },
cache: 'force-cache',
});

if (response.status == 200) {
const result: { blogs: BlogData[] } = await response.json();
let blogPost = result.blogs.find((p) => p?.filenameSlug === slug);
Expand All @@ -30,8 +29,9 @@ export async function getPost(slug: string): Promise<Maybe<BlogData>> {
export async function getBlogPosts(): Promise<Maybe<BlogData[]>> {
try {
const response = await fetch(SITE_URL + BLOG_API_URI, {
next: { revalidate: VALIDATE_EVERY_SECS },
cache: 'force-cache',
});

if (response.status == 200) {
const result: { blogs: BlogData[] } = await response.json();
return result.blogs;
Expand Down

0 comments on commit 7e6835b

Please sign in to comment.