diff --git a/astro.config.mjs b/astro.config.mjs index 5b7752d..b778f5c 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -11,6 +11,10 @@ export default defineConfig({ site: 'https://terminal-blog.example.com', base: '/', trailingSlash: 'ignore', + redirects: { + // for the old routes still can be accessed + "/post/[...slug]": "/blog/[...slug]" + }, build: { format: 'directory' diff --git a/src/components/Search.astro b/src/components/Search.astro index 8fbb5aa..6b0c794 100644 --- a/src/components/Search.astro +++ b/src/components/Search.astro @@ -192,7 +192,7 @@ const domain = Astro.url.host const searchItems = results.map(item => `
{new Date(post.data.pubDate).toISOString().split('T')[0]} - {post.data.title} + {post.data.title}
))} diff --git a/src/pages/post/[...slug].astro b/src/pages/blog/[...slug].astro similarity index 95% rename from src/pages/post/[...slug].astro rename to src/pages/blog/[...slug].astro index 9516bca..45598b4 100644 --- a/src/pages/post/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -40,7 +40,7 @@ if (matchedImage && !customFeaturedImage) { } const firstImageURL = await ExtractFirstImage(Content) -const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || `/post/${slug}/featured.png` || ''; +const cover = customFeaturedImage || matchedImage_src?.src || firstImageURL || `/blog/${slug}/featured.png` || ''; ---{new Date(post.data.pubDate).toISOString().split('T')[0]} - {post.data.title} + {post.data.title}
)} diff --git a/src/pages/llms.txt.js b/src/pages/llms.txt.js index b917536..396352b 100644 --- a/src/pages/llms.txt.js +++ b/src/pages/llms.txt.js @@ -29,7 +29,7 @@ async function generateMarkdownSection(collectionName, sectionTitle, baseUrl) { for (const item of sortedItems) { const { title, description, slug } = getMetaData(item); - markdown += `\n- [${title}](${baseUrl}/post/${slug}): ${description}`; + markdown += `\n- [${title}](${baseUrl}/blog/${slug}): ${description}`; } return markdown; diff --git a/src/pages/rss.xml.js b/src/pages/rss.xml.js index bdef740..28a90d4 100644 --- a/src/pages/rss.xml.js +++ b/src/pages/rss.xml.js @@ -58,7 +58,7 @@ export async function GET(context) { title: post.data.title, description: post.data.description || '', pubDate: post.data.pubDate, - link: `${baseUrl}/post/${post.slug}`, + link: `${baseUrl}/blog/${post.slug}`, content, }); diff --git a/src/pages/tags/[...tag].astro b/src/pages/tags/[...tag].astro index 3b834c1..bbff160 100644 --- a/src/pages/tags/[...tag].astro +++ b/src/pages/tags/[...tag].astro @@ -24,7 +24,7 @@ const { posts } = Astro.props; {posts.map((post: any) =>{new Date(post.data.pubDate).toISOString().split('T')[0]} - {post.data.title} + {post.data.title}
)} diff --git a/src/pages/twtxt.txt.js b/src/pages/twtxt.txt.js index aa915c8..54f6845 100644 --- a/src/pages/twtxt.txt.js +++ b/src/pages/twtxt.txt.js @@ -6,7 +6,7 @@ export async function GET(context) { posts.sort((a, b) => new Date(b.data.pubDate).getTime() - new Date(a.data.pubDate).getTime()); const twtxt = posts.map(post => ( - `${new Date(post.data.pubDate).toISOString()}\t${post.data.title} ${context.site}post/${post.slug}` + `${new Date(post.data.pubDate).toISOString()}\t${post.data.title} ${context.site}blog/${post.slug}` )).join('\n'); return new Response(twtxt, { diff --git a/staticwebapp.config.json b/staticwebapp.config.json index c56f2f2..80f5f51 100644 --- a/staticwebapp.config.json +++ b/staticwebapp.config.json @@ -1,6 +1,11 @@ { "trailingSlash": "auto", "routes": [ + { + "route": "/post/*", + "redirect": "/blog/*", + "statusCode": 302 + }, { "route": "/*", "headers": {