Skip to content

Commit

Permalink
✨ remove tag structure dependency from isPostCitable
Browse files Browse the repository at this point in the history
  • Loading branch information
ikesau committed Jan 13, 2025
1 parent f611a85 commit df340c9
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions db/model/Post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
parsePostWpApiSnapshot,
FullPost,
JsonError,
CategoryWithEntries,
WP_PostType,
FilterFnPostRestApi,
PostRestApi,
Expand Down Expand Up @@ -40,7 +39,6 @@ import {
CLOUDFLARE_IMAGES_URL,
} from "../../settings/clientSettings.js"
import { BLOG_SLUG } from "../../settings/serverSettings.js"
import { SiteNavigationStatic } from "../../site/SiteConstants.js"
import { decodeHTML } from "entities"
import { getAndLoadListedGdocPosts } from "./Gdoc/GdocFactory.js"

Expand Down Expand Up @@ -185,22 +183,10 @@ export const getFullPostByIdFromSnapshot = async (
return getFullPost(trx, postEnriched.wpApiSnapshot)
}

// TODO: I suggest that in the place where we define SiteNavigationStatic we create a Set with all the leaves and
// then this one becomes a simple lookup in the set. Probably nicest to do the set creation as a memoized function.
// kicking this can till WP posts kick the bucket
// COVID pages are the only WP pages left that are citable, grep "pageOverrides" to see more
export const isPostSlugCitable = (slug: string): boolean => {
const entries = SiteNavigationStatic.categories
return entries.some((category) => {
return (
category.entries.some((entry) => entry.slug === slug) ||
(category.subcategories ?? []).some(
(subcategory: CategoryWithEntries) => {
return subcategory.entries.some(
(subCategoryEntry) => subCategoryEntry.slug === slug
)
}
)
)
})
return slug === "coronavirus"
}

export const getPostsFromSnapshots = async (
Expand Down

0 comments on commit df340c9

Please sign in to comment.