Skip to content

Commit 41dcad4

Browse files
authored
blog: increase the weight differences if too many related posts (#353)
* blog: increase the weight differences if too many related posts * update style
1 parent abee3c7 commit 41dcad4

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

blog/supabase-alternative/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Supabase RLS Alternative
33
description: Show the limitation of Supabase RLS(Row Level Security) with a multi-tenancy SaaS example and introduce ZenStack as an alternative.
4-
tags: [supabase, rls, auth, authorization, baas, zenstack]
4+
tags: [supabase, rls, auth, authorization, baas, database, firebase, zenstack]
55
authors: jiasheng
66
date: 2024-07-24
77
image: ./cover.png

src/components/blog/post-paginator.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ export const PostPaginator = ({ posts, title }) => {
6363
</p>
6464
</Link>
6565
))}
66-
<p className="mb-4 p-0 text-xl">
67-
🚀 Ready to build high-quality, scalable Prisma apps with built-in AuthZ and instant CRUD APIs ?
66+
<p className="mt-8 mb-6 p-0 text-xl font-bold">
67+
Ready to build high-quality, scalable Prisma apps with built-in AuthZ and instant CRUD APIs ?🚀
6868
</p>
69-
<Link className="mb-4 p-0 text-xl" to="/docs/welcome">
69+
<Link className="mb-4 p-0 text-xl font-bold underline" to="/docs/welcome">
7070
Get started with ZenStack's ultimate guide to build faster and smarter
7171
</Link>
7272
</div>

src/plugins/blog-plugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function getRelatedPosts(allBlogPosts, metadata) {
3737
authors: post.metadata.authors,
3838
readingTime: post.metadata.readingTime,
3939
date: post.metadata.date,
40-
relatedWeight: post.metadata.frontMatter.tags.filter((tag) => currentTags.has(tag)).length * 3 + 1,
40+
relatedWeight: post.metadata.frontMatter.tags.filter((tag) => currentTags.has(tag)).length * 4 + 1,
4141
};
4242
});
4343

src/theme/BlogPostPage/index.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,13 @@ function getMultipleRandomPosts(relatedPosts, number) {
1616
const weightedItems = [...relatedPosts];
1717
const result = [];
1818

19+
if (weightedItems.length > 15) {
20+
weightedItems.forEach((item) => {
21+
//square the weight to increase the chance of the post being selected
22+
item.relatedWeight = Math.pow(item.relatedWeight, 2);
23+
});
24+
}
25+
1926
// Calculate the total weight
2027
let totalWeight = weightedItems.reduce((sum, item) => sum + item.relatedWeight, 0);
2128

@@ -60,8 +67,6 @@ function BlogPostPageContent({ children }) {
6067

6168
console.log('relatedPosts', relatedPosts);
6269

63-
//const url = '/blog/supabase-alternative/cover.png';
64-
6570
return (
6671
<BlogLayout
6772
toc={

0 commit comments

Comments
 (0)