refactor: remove unused Taxonomy type
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import type { PaginateFunction } from 'astro';
|
import type { PaginateFunction } from 'astro';
|
||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from 'astro:content';
|
||||||
import type { CollectionEntry } from 'astro:content';
|
import type { CollectionEntry } from 'astro:content';
|
||||||
import type { Post, Taxonomy } from '~/types';
|
import type { Post } from '~/types';
|
||||||
import { APP_BLOG } from 'astrowind:config';
|
import { APP_BLOG } from 'astrowind:config';
|
||||||
import { cleanSlug, trimSlash, BLOG_BASE, POST_PERMALINK_PATTERN, CATEGORY_BASE, TAG_BASE } from './permalinks';
|
import { cleanSlug, trimSlash, BLOG_BASE, POST_PERMALINK_PATTERN, CATEGORY_BASE, TAG_BASE } from './permalinks';
|
||||||
|
|
||||||
@@ -243,7 +243,7 @@ export const getStaticPathsBlogTag = async ({ paginate }: { paginate: PaginateFu
|
|||||||
/** */
|
/** */
|
||||||
export async function getRelatedPosts(originalPost: Post, maxResults: number = 4): Promise<Post[]> {
|
export async function getRelatedPosts(originalPost: Post, maxResults: number = 4): Promise<Post[]> {
|
||||||
const allPosts = await fetchPosts();
|
const allPosts = await fetchPosts();
|
||||||
const originalTagsSet = new Set(originalPost.tags ? originalPost.tags.map(tag => tag.slug) : []);
|
const originalTagsSet = new Set(originalPost.tags ? originalPost.tags.map((tag) => tag.slug) : []);
|
||||||
|
|
||||||
const postsWithScores = allPosts.reduce((acc: { post: Post; score: number }[], iteratedPost: Post) => {
|
const postsWithScores = allPosts.reduce((acc: { post: Post; score: number }[], iteratedPost: Post) => {
|
||||||
if (iteratedPost.slug === originalPost.slug) return acc;
|
if (iteratedPost.slug === originalPost.slug) return acc;
|
||||||
@@ -254,7 +254,7 @@ export async function getRelatedPosts(originalPost: Post, maxResults: number = 4
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (iteratedPost.tags) {
|
if (iteratedPost.tags) {
|
||||||
iteratedPost.tags.forEach(tag => {
|
iteratedPost.tags.forEach((tag) => {
|
||||||
if (originalTagsSet.has(tag.slug)) {
|
if (originalTagsSet.has(tag.slug)) {
|
||||||
score += 1;
|
score += 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user