Skip to content

Commit a5150da

Browse files
committed
Update pages/articles and 301 redirects
1 parent b559071 commit a5150da

3 files changed

Lines changed: 18 additions & 40 deletions

File tree

‎src/pages/articles/[...slug].astro‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import ContentLayout from '@components/Content/Layout/index.astro'
88
99
export interface Props {
1010
article: CollectionEntry<'articles'>
11-
canonicalPath?: string
1211
}
1312
1413
/** Generate static paths for all articles */
@@ -17,35 +16,23 @@ export async function getStaticPaths() {
1716
return isDev() || data.isDraft !== true
1817
})
1918
20-
const deepDiveEntries = await getCollection('deepDives', ({ data }) => {
21-
return isDev() || data.isDraft !== true
22-
})
23-
24-
const deepDiveIds = new Set(deepDiveEntries.map(entry => entry.id))
25-
2619
return articleEntries.map(article => ({
2720
params: { slug: article.id },
28-
props: {
29-
article,
30-
canonicalPath: deepDiveIds.has(article.id) ? `/deep-dive/${article.id}` : undefined,
31-
},
21+
props: { article },
3222
}))
3323
}
3424
35-
const { article, canonicalPath } = Astro.props
25+
const { article } = Astro.props
3626
const author = await getEntry(article.data.author)
3727
3828
const articleBody = article.body ?? ''
3929
const readingTime = article.data.readingTime ?? getReadingTimeLabel(articleBody)
40-
const robotsContent = canonicalPath ? 'noindex, follow' : undefined
4130
---
4231

4332
<ContentLayout
4433
author={author.data.name}
4534
article={article}
46-
{...canonicalPath && { canonicalPath }}
4735
path={`/articles/${article.id}`}
48-
{...robotsContent && { robotsContent }}
4936
section="Articles"
5037
{...readingTime && { readingTime }}
5138
/>
Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,23 @@
11
---
22
export const prerender = true
33
4-
import { type CollectionEntry, getCollection, getEntry } from 'astro:content'
4+
import { getCollection } from 'astro:content'
55
import { isDev } from '@lib/config/environmentServer'
6-
import { getReadingTimeLabel } from '@lib/markdown/utils/readingTime'
7-
import ContentLayout from '@components/Content/Layout/index.astro'
86
9-
export interface Props {
10-
article: CollectionEntry<'deepDives'>
11-
}
12-
13-
/** Generate static paths for all deep-dive articles */
7+
/**
8+
* Legacy deep-dive URLs permanently redirect to the consolidated article pages.
9+
* Vercel also 301s /deep-dive/:path* to /articles/:path* at the edge via
10+
* vercel.json; this stub keeps dev and preview behavior consistent. It can be
11+
* deleted once the Vercel redirect is verified live.
12+
*/
1413
export async function getStaticPaths() {
15-
const articleEntries = await getCollection('deepDives', ({ data }) => {
14+
const articleEntries = await getCollection('articles', ({ data }) => {
1615
return isDev() || data.isDraft !== true
1716
})
1817
return articleEntries.map(article => ({
1918
params: { slug: article.id },
20-
props: { article },
2119
}))
2220
}
2321
24-
const { article } = Astro.props
25-
const author = await getEntry(article.data.author)
26-
27-
const articleBody = article.body ?? ''
28-
const readingTime = article.data.readingTime ?? getReadingTimeLabel(articleBody)
29-
// If section const value is changed, update the ContentLayout usage of the value
30-
const section = 'Deep Dive Articles'
22+
return Astro.redirect(`/articles/${Astro.params.slug}`, 301)
3123
---
32-
33-
<ContentLayout
34-
author={author.data.name}
35-
article={article}
36-
path={`/deep-dive/${article.id}`}
37-
section={section}
38-
{...readingTime && { readingTime }}
39-
/>

‎vercel.json‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
]
2828
}
2929
],
30+
"redirects": [
31+
{
32+
"source": "/deep-dive/:path*",
33+
"destination": "/articles/:path*",
34+
"permanent": true
35+
}
36+
],
3037
"regions": ["iad1"],
3138
"trailingSlash": false
3239
}

0 commit comments

Comments
 (0)