Skip to content

Commit efcddce

Browse files
feat: exclude devto and hashnode posts that first appeared on networkandcode.github.io
1 parent 7cca69d commit efcddce

7 files changed

Lines changed: 47 additions & 94 deletions

File tree

src/data/cv.json

Lines changed: 2 additions & 2 deletions
Large diffs are not rendered by default.

src/data/devtoArticles.json

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -653,73 +653,5 @@
653653
"reading_time_minutes": 5,
654654
"positive_reactions_count": 10,
655655
"comments_count": 2
656-
},
657-
{
658-
"id": 917875,
659-
"title": "Setup an IAM user in AWS via CLI",
660-
"description": "Hey all, 👋 we shall see the following in this post: 📜 Create a group Attach policies ✍️ to the...",
661-
"url": "https://dev.to/aws-builders/aws-iam-setup-user-via-cli-45bb",
662-
"published_at": "2021-12-05T11:19:02Z",
663-
"tag_list": [
664-
"aws",
665-
"iam",
666-
"jq",
667-
"security"
668-
],
669-
"cover_image": null,
670-
"reading_time_minutes": 4,
671-
"positive_reactions_count": 7,
672-
"comments_count": 0
673-
},
674-
{
675-
"id": 897816,
676-
"title": "Launch AWS EC2 instances the hard way with CLI",
677-
"description": "Hey All 👋, in this post we shall launch 3 AWS EC2 instances and test SSH connectivity to those... We...",
678-
"url": "https://dev.to/aws-builders/aws-ec2-launch-instances-the-hard-way-with-cli-2ga3",
679-
"published_at": "2021-11-14T12:11:43Z",
680-
"tag_list": [
681-
"aws",
682-
"ec2",
683-
"linux",
684-
"kubernetes"
685-
],
686-
"cover_image": null,
687-
"reading_time_minutes": 6,
688-
"positive_reactions_count": 6,
689-
"comments_count": 0
690-
},
691-
{
692-
"id": 865633,
693-
"title": "Setup an AWS EKS cluster and deploy OWASP juice shop",
694-
"description": "Let's setup an EKS cluster and then install the OWASP Juice Shop on it using kubernetes manifests. ...",
695-
"url": "https://dev.to/aws-builders/aws-eks-setup-cluster-and-deploy-owasp-juice-shop-214j",
696-
"published_at": "2021-10-16T09:00:00Z",
697-
"tag_list": [
698-
"kubernetes",
699-
"aws",
700-
"owasp",
701-
"eks"
702-
],
703-
"cover_image": null,
704-
"reading_time_minutes": 6,
705-
"positive_reactions_count": 7,
706-
"comments_count": 0
707-
},
708-
{
709-
"id": 863227,
710-
"title": "Bootstrap a Kubernetes cluster with RKE",
711-
"description": "Rancher Kubernetes Engine ( RKE ) is a popular tool using which we can bootstrap kubernetes clusters...",
712-
"url": "https://dev.to/networkandcode/kubernetes-bootstrap-a-cluster-with-rke-1f9n",
713-
"published_at": "2021-10-14T07:56:52Z",
714-
"tag_list": [
715-
"kubernetes",
716-
"rancher",
717-
"linode",
718-
"linux"
719-
],
720-
"cover_image": null,
721-
"reading_time_minutes": 4,
722-
"positive_reactions_count": 5,
723-
"comments_count": 0
724656
}
725657
]

src/data/hashnodeArticles.json

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,6 @@
2727
"published_at": "2022-06-11",
2828
"description": "Introduction Appwrite is a backend server that can be leveraged for integrating services such as authentication, storage, database etc. to our frontend application. It can be launc..."
2929
},
30-
{
31-
"id": "https://networkandcode.hashnode.dev/run-owasp-juice-shop-as-a-kubernetes-service",
32-
"title": "Run OWASP juice shop as a Kubernetes service",
33-
"url": "https://networkandcode.hashnode.dev/run-owasp-juice-shop-as-a-kubernetes-service",
34-
"published_at": "2021-08-07",
35-
"description": "This article first appeared on https://networkandcode.github.io/owasp/juice/shop/2021/08/08/owasp-juice-shop-run-as-kubernetes-service.html Hello, we shall run the OWASP juice shop..."
36-
},
3730
{
3831
"id": "https://networkandcode.hashnode.dev/online-shop-with-nextjs-and-harperdb",
3932
"title": "Online shop with NextJS and HarperDB",

src/lib/syncDevTo.ts

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,25 @@ export function syncDevToPosts(): AstroIntegration {
4444
const dataFilePath = path.resolve(process.cwd(), 'src/data/devtoArticles.json');
4545

4646
if (Array.isArray(articles) && articles.length > 0) {
47-
const formatted: DevToArticle[] = articles.map((art: any) => ({
48-
id: art.id,
49-
title: art.title,
50-
description: art.description || '',
51-
url: art.url,
52-
published_at: art.published_at,
53-
tag_list: art.tag_list || [],
54-
cover_image: art.cover_image || null,
55-
reading_time_minutes: art.reading_time_minutes,
56-
positive_reactions_count: art.positive_reactions_count,
57-
comments_count: art.comments_count,
58-
}));
47+
const formatted: DevToArticle[] = articles
48+
.filter((art: any) => {
49+
const desc = (art.description || '').toLowerCase();
50+
const canon = (art.canonical_url || '').toLowerCase();
51+
// Exclude posts that first appeared on networkandcode.github.io
52+
return !desc.includes('networkandcode.github.io') && !canon.includes('networkandcode.github.io');
53+
})
54+
.map((art: any) => ({
55+
id: art.id,
56+
title: art.title,
57+
description: art.description || '',
58+
url: art.url,
59+
published_at: art.published_at,
60+
tag_list: art.tag_list || [],
61+
cover_image: art.cover_image || null,
62+
reading_time_minutes: art.reading_time_minutes,
63+
positive_reactions_count: art.positive_reactions_count,
64+
comments_count: art.comments_count,
65+
}));
5966

6067
fs.writeFileSync(dataFilePath, JSON.stringify(formatted, null, 2), 'utf-8');
6168
console.log(`[sync-devto] Synced ${formatted.length} DEV.to articles metadata to src/data/devtoArticles.json`);

src/lib/syncHashnode.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,18 @@ export function syncHashnodePosts(): AstroIntegration {
4646
const descMatch = itemContent.match(/<description><!\[CDATA\[([\s\S]*?)\]\]><\/description>/);
4747
const guidMatch = itemContent.match(/<guid[^>]*>(.*?)<\/guid>/);
4848

49-
let description = '';
49+
let rawDescription = '';
5050
if (descMatch) {
51-
description = descMatch[1].replace(/<[^>]+>/g, '').replace(/\s+/g, ' ').trim().slice(0, 180) + '...';
51+
rawDescription = descMatch[1].replace(/<[^>]+>/g, '').replace(/\s+/g, ' ').trim();
5252
}
5353

54+
// Rule: Exclude posts that first appeared on networkandcode.github.io
55+
if (rawDescription.toLowerCase().includes('networkandcode.github.io') || rawDescription.toLowerCase().includes('first appeared on https://networkandcode')) {
56+
continue;
57+
}
58+
59+
const description = rawDescription.length > 180 ? rawDescription.slice(0, 180) + '...' : rawDescription;
60+
5461
if (titleMatch && linkMatch) {
5562
items.push({
5663
id: guidMatch ? guidMatch[1] : linkMatch[1],

src/pages/blog/index.astro

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,13 @@ const processedLocalPosts: PostItem[] = localPosts.map((post) => {
5858
};
5959
});
6060
61-
const processedDevToPosts: PostItem[] = (devtoData as any[]).map((art) => {
61+
const processedDevToPosts: PostItem[] = (devtoData as any[])
62+
.filter((art) => {
63+
const desc = (art.description || '').toLowerCase();
64+
const url = (art.url || '').toLowerCase();
65+
return !desc.includes('networkandcode.github.io') && !url.includes('networkandcode.github.io');
66+
})
67+
.map((art) => {
6268
const dateStr = art.published_at ? art.published_at.slice(0, 10) : '2024-01-01';
6369
const tagsStr = (art.tag_list || []).join(' ').toLowerCase();
6470
const textStr = (art.title + ' ' + tagsStr).toLowerCase();
@@ -89,7 +95,13 @@ const processedDevToPosts: PostItem[] = (devtoData as any[]).map((art) => {
8995
};
9096
});
9197
92-
const processedHashnodePosts: PostItem[] = (hashnodeData as any[]).map((art) => {
98+
const processedHashnodePosts: PostItem[] = (hashnodeData as any[])
99+
.filter((art) => {
100+
const desc = (art.description || '').toLowerCase();
101+
const url = (art.url || '').toLowerCase();
102+
return !desc.includes('networkandcode.github.io') && !url.includes('networkandcode.github.io');
103+
})
104+
.map((art) => {
93105
const dateStr = art.published_at ? art.published_at.slice(0, 10) : '2022-06-01';
94106
const textStr = (art.title + ' ' + (art.description || '')).toLowerCase();
95107

src/pages/index.astro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ const coreCompetencies = [
3535
}
3636
];
3737
38-
const totalPosts = posts.length + (devtoData as any[]).length + (hashnodeData as any[]).length;
38+
const validDevTo = (devtoData as any[]).filter(a => !((a.description || '').toLowerCase().includes('networkandcode.github.io')));
39+
const validHashnode = (hashnodeData as any[]).filter(a => !((a.description || '').toLowerCase().includes('networkandcode.github.io')));
40+
const totalPosts = posts.length + validDevTo.length + validHashnode.length;
3941
const totalVideos = youtubeVideos.length;
4042
const totalCerts = accreditations.length;
4143
const totalAwards = awardsAndCertificates.length;

0 commit comments

Comments
 (0)