|
3 | 3 | import { cacheTag, revalidateTag } from "next/cache"; |
4 | 4 | import { pgClient } from "@/backend/persistence/clients"; |
5 | 5 | import { slugify } from "@/lib/slug-helper.util"; |
6 | | -import { removeMarkdownSyntax, removeUndefinedFromObject, generateRandomString } from "@/lib/utils"; |
| 6 | +import { |
| 7 | + removeMarkdownSyntax, |
| 8 | + removeUndefinedFromObject, |
| 9 | + generateRandomString, |
| 10 | + resolveArticleExcerpt, |
| 11 | +} from "@/lib/utils"; |
7 | 12 | import { addDays } from "date-fns"; |
8 | 13 | import * as sk from "sqlkit"; |
9 | 14 | import { and, desc, eq, like, neq, or } from "sqlkit"; |
@@ -299,6 +304,7 @@ export async function deleteArticle(article_id: string) { |
299 | 304 | where: eq("id", article_id), |
300 | 305 | }); |
301 | 306 |
|
| 307 | + revalidateTag("tags-list", "max"); |
302 | 308 | return deletedArticles?.rows?.[0]; |
303 | 309 | } catch (error) { |
304 | 310 | handleActionException(error); |
@@ -427,7 +433,7 @@ export async function userArticleFeed( |
427 | 433 | response["nodes"] = response["nodes"].map((article) => { |
428 | 434 | return { |
429 | 435 | ...article, |
430 | | - excerpt: article.excerpt ?? removeMarkdownSyntax(article.body), |
| 436 | + excerpt: resolveArticleExcerpt(article.excerpt, article.body), |
431 | 437 | }; |
432 | 438 | }); |
433 | 439 |
|
@@ -498,7 +504,7 @@ export async function articlesByTag( |
498 | 504 | cover_image: row.cover_image, |
499 | 505 | body: row.body, |
500 | 506 | created_at: new Date(row.created_at), |
501 | | - excerpt: row.excerpt ?? removeMarkdownSyntax(row.body), |
| 507 | + excerpt: resolveArticleExcerpt(row.excerpt, row.body), |
502 | 508 | user: { |
503 | 509 | id: row.user_id, |
504 | 510 | name: row.user_name, |
@@ -702,6 +708,7 @@ export async function setArticlePublished( |
702 | 708 | if (articles?.rows?.[0] && !is_published) { |
703 | 709 | deleteArticleById(article_id); |
704 | 710 | } |
| 711 | + revalidateTag("tags-list", "max"); |
705 | 712 | return articles?.rows?.[0]; |
706 | 713 | } catch (error) { |
707 | 714 | return handleActionException(error); |
|
0 commit comments