Skip to content

Commit 16b9389

Browse files
committed
Fix comparison generation
1 parent 2c883ce commit 16b9389

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

next.config.mjs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ const nextConfig = {
123123
source: '/blog/vector-databases-compared',
124124
destination: '/vectordatabases',
125125
permanent: true
126+
},
127+
{
128+
source: '/comparisons/:db1(pinecone|milvus|chroma|weaviate|faiss|elasticsearch|qdrant|vald|lancedb|marqo|singlestoredb|pgvector|redis|vespa|deep-lake|docarray)-vs-:db2(pinecone|milvus|chroma|weaviate|faiss|elasticsearch|qdrant|vald|lancedb|marqo|singlestoredb|pgvector|redis|vespa|deep-lake|docarray)',
129+
destination: '/vectordatabases',
130+
permanent: false
126131
}
127132
]
128133
},

src/components/ContentCard.jsx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,20 @@ export function ContentCard({ article }) {
117117
// Simple check for external links
118118
const isExternalLink = slug?.startsWith('http://') || slug?.startsWith('https://');
119119

120-
// For external links, use the slug directly
121-
// For internal links, use the slug as is - the parent component should provide the full path
122-
const href = isExternalLink ? slug : slug || '#';
120+
let calculatedHref = '#';
121+
if (isExternalLink) {
122+
calculatedHref = slug;
123+
} else if (slug) {
124+
if (type === 'comparison') {
125+
// Ensure no double slashes if slug might accidentally have one (it shouldn't from our generator)
126+
calculatedHref = `/comparisons/${slug.startsWith('/') ? slug.substring(1) : slug}`;
127+
} else {
128+
// For other internal links, assume slug is the intended href.
129+
// If it's not a full path (e.g. /blog/my-post) Link component will resolve it relatively.
130+
// If it is a full path (e.g. /blog/my-post), Link will use it as is.
131+
calculatedHref = slug;
132+
}
133+
}
123134

124135
// Format the date
125136
const formattedDate = date ? new Date(date).toLocaleDateString('en-US', {
@@ -167,7 +178,7 @@ export function ContentCard({ article }) {
167178
: "shadow-lg hover:shadow-xl border-gray-200 dark:border-gray-700"
168179
)}>
169180
{isExternalLink ? (
170-
<a href={href} target="_blank" rel="noopener noreferrer" className="group w-full">
181+
<a href={calculatedHref} target="_blank" rel="noopener noreferrer" className="group w-full">
171182
<CardContent
172183
imageSource={imageSource}
173184
title={title}
@@ -182,7 +193,7 @@ export function ContentCard({ article }) {
182193
/>
183194
</a>
184195
) : (
185-
<Link href={href} className="group w-full">
196+
<Link href={calculatedHref} className="group w-full">
186197
<CardContent
187198
imageSource={imageSource}
188199
title={title}

src/lib/comparisons.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export async function importComparison(
1313
return {
1414
...metadata,
1515
type: 'blog',
16-
slug: path.basename(comparisonFilename, '.mdx')
16+
slug: path.dirname(comparisonFilename)
1717
}
1818
}
1919

0 commit comments

Comments
 (0)