-
-
- {typeMeta.label}
-
-
-
+
+
+
+ {typeMeta.label}
+
+
+
-
- {item.data.description && (
-
- {item.data.description}
-
+ {item.data.description && (
+
+ {item.data.description}
+
+ )}
+
+
+ {/* Client or Author info */}
+ {'client' in item.data && item.data.client && (
+
+ Client: {item.data.client}
+
)}
-
- {/* Client or Author info */}
- {'client' in item.data && item.data.client && (
-
- Client: {item.data.client}
-
- )}
-
- {/* Additional tags */}
- {item.data.tags && item.data.tags.length > 1 && (
-
- )}
-
+ {/* Additional tags */}
+ {item.data.tags && item.data.tags.length > 1 && (
+
+ )}
-
+
)
})}
@@ -278,7 +323,7 @@ const section = 'Tags'
No content found for this tag.
-
+
Browse other tags
diff --git a/src/pages/tags/index.astro b/src/pages/tags/index.astro
index 245b4957c..3bc7d4448 100644
--- a/src/pages/tags/index.astro
+++ b/src/pages/tags/index.astro
@@ -3,7 +3,6 @@ import { getCollection } from 'astro:content'
import { Picture } from 'astro:assets'
import { isDev, isProd } from '@lib/config/environmentServer'
import BaseLayout from '@layouts/BaseLayout.astro'
-import { exceptions } from '@content/_tagList'
// Get all content collections with tags
const allArticles = await getCollection('articles', ({ data }) => {
@@ -25,24 +24,20 @@ const allContent = [
...allServices.map(item => ({ ...item, type: 'service' })),
].sort((a, b) => new Date(b.data.publishDate).getTime() - new Date(a.data.publishDate).getTime())
-// Extract all unique tags from all content
-const allTags = Array.from(new Set(allContent.flatMap(item => item.data.tags || []))).filter(
- tag => tag
-) // Remove any undefined/null tags
-
-// Function to get display name for tags
-const getTagDisplayName = (tag: string) => {
- return exceptions[tag as keyof typeof exceptions] || tag
-}
+const allTags = await getCollection('tags')
// Function to get content preview for a specific tag
-const getContentPreviewForTag = (tag: string, limit: number = 4) => {
+function getContentPreviewForTag(tag: string, limit: number = 4) {
return allContent.filter(item => item.data.tags && item.data.tags.includes(tag)).slice(0, limit)
}
+const tagsWithContent = allTags.filter(tag => {
+ return getContentPreviewForTag(tag.data.slug, 1).length > 0
+})
+
const pageDescription = 'Webstack Builders Services List'
const pageTitle = 'All Tags'
-const path = '/tags/'
+const path = '/tags'
const section = 'Tags'
---
@@ -64,16 +59,19 @@ const section = 'Tags'
{
- allTags.sort().map(tag => {
- const contentPreview = getContentPreviewForTag(tag, 4)
- const displayName = getTagDisplayName(tag)
+ tagsWithContent
+ .sort((a, b) => a.data.displayName.localeCompare(b.data.displayName, 'en'))
+ .map(tag => {
+ const tagSlug = tag.data.slug
+ const contentPreview = getContentPreviewForTag(tagSlug, 4)
+ const displayName = tag.data.displayName
return (