mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 11:29:33 +08:00
fix: add trailing slash to links to avoid extra redirects (#246)
Add trailing slash to links for improved consistency with RSS links and to avoid unnecessary redirects. --------- Co-authored-by: satnaing <satnaingdev@gmail.com>
This commit is contained in:
@@ -44,7 +44,7 @@ breadcrumbList[0] === "tags" &&
|
|||||||
</li>
|
</li>
|
||||||
) : (
|
) : (
|
||||||
<li>
|
<li>
|
||||||
<a href={`/${breadcrumb}`}>{breadcrumb}</a>
|
<a href={`/${breadcrumb}/`}>{breadcrumb}</a>
|
||||||
<span aria-hidden="true">»</span>
|
<span aria-hidden="true">»</span>
|
||||||
</li>
|
</li>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -56,23 +56,23 @@ const { activeNav } = Astro.props;
|
|||||||
</button>
|
</button>
|
||||||
<ul id="menu-items" class="display-none sm:flex">
|
<ul id="menu-items" class="display-none sm:flex">
|
||||||
<li>
|
<li>
|
||||||
<a href="/posts" class={activeNav === "posts" ? "active" : ""}>
|
<a href="/posts/" class={activeNav === "posts" ? "active" : ""}>
|
||||||
Posts
|
Posts
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/tags" class={activeNav === "tags" ? "active" : ""}>
|
<a href="/tags/" class={activeNav === "tags" ? "active" : ""}>
|
||||||
Tags
|
Tags
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="/about" class={activeNav === "about" ? "active" : ""}>
|
<a href="/about/" class={activeNav === "about" ? "active" : ""}>
|
||||||
About
|
About
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<LinkButton
|
<LinkButton
|
||||||
href="/search"
|
href="/search/"
|
||||||
className={`focus-outline p-3 sm:p-1 ${
|
className={`focus-outline p-3 sm:p-1 ${
|
||||||
activeNav === "search" ? "active" : ""
|
activeNav === "search" ? "active" : ""
|
||||||
} flex`}
|
} flex`}
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ export default function SearchBar({ searchList }: Props) {
|
|||||||
{searchResults &&
|
{searchResults &&
|
||||||
searchResults.map(({ item, refIndex }) => (
|
searchResults.map(({ item, refIndex }) => (
|
||||||
<Card
|
<Card
|
||||||
href={`/posts/${item.slug}`}
|
href={`/posts/${item.slug}/`}
|
||||||
frontmatter={item.data}
|
frontmatter={item.data}
|
||||||
key={`${refIndex}-${item.slug}`}
|
key={`${refIndex}-${item.slug}`}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ const { tag, size = "sm" } = Astro.props;
|
|||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
href={`/tags/${tag}`}
|
href={`/tags/${tag}/`}
|
||||||
transition:name={tag}
|
transition:name={tag}
|
||||||
class={`${size === "sm" ? "text-sm" : "text-lg"} pr-2 group`}
|
class={`${size === "sm" ? "text-sm" : "text-lg"} pr-2 group`}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const { currentPage, totalPages, paginatedPosts } = Astro.props;
|
|||||||
<ul>
|
<ul>
|
||||||
{
|
{
|
||||||
paginatedPosts.map(({ data, slug }) => (
|
paginatedPosts.map(({ data, slug }) => (
|
||||||
<Card href={`/posts/${slug}`} frontmatter={data} />
|
<Card href={`/posts/${slug}/`} frontmatter={data} />
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -32,8 +32,8 @@ const { currentPage, totalPages, paginatedPosts } = Astro.props;
|
|||||||
<Pagination
|
<Pagination
|
||||||
{currentPage}
|
{currentPage}
|
||||||
{totalPages}
|
{totalPages}
|
||||||
prevUrl={`/posts${currentPage - 1 !== 1 ? "/" + (currentPage - 1) : ""}`}
|
prevUrl={`/posts${currentPage - 1 !== 1 ? "/" + (currentPage - 1) : ""}/`}
|
||||||
nextUrl={`/posts/${currentPage + 1}`}
|
nextUrl={`/posts/${currentPage + 1}/`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Footer noMarginTop={totalPages > 1} />
|
<Footer noMarginTop={totalPages > 1} />
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ const { currentPage, totalPages, paginatedPosts, tag, tagName } = Astro.props;
|
|||||||
<ul>
|
<ul>
|
||||||
{
|
{
|
||||||
paginatedPosts.map(({ data, slug }) => (
|
paginatedPosts.map(({ data, slug }) => (
|
||||||
<Card href={`/posts/${slug}`} frontmatter={data} />
|
<Card href={`/posts/${slug}/`} frontmatter={data} />
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
@@ -41,8 +41,8 @@ const { currentPage, totalPages, paginatedPosts, tag, tagName } = Astro.props;
|
|||||||
{totalPages}
|
{totalPages}
|
||||||
prevUrl={`/tags/${tag}${
|
prevUrl={`/tags/${tag}${
|
||||||
currentPage - 1 !== 1 ? "/" + (currentPage - 1) : ""
|
currentPage - 1 !== 1 ? "/" + (currentPage - 1) : ""
|
||||||
}`}
|
}/`}
|
||||||
nextUrl={`/tags/${tag}/${currentPage + 1}`}
|
nextUrl={`/tags/${tag}/${currentPage + 1}/`}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Footer noMarginTop={totalPages > 1} />
|
<Footer noMarginTop={totalPages > 1} />
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ const socialCount = SOCIALS.filter(social => social.active).length;
|
|||||||
<ul>
|
<ul>
|
||||||
{featuredPosts.map(({ data, slug }) => (
|
{featuredPosts.map(({ data, slug }) => (
|
||||||
<Card
|
<Card
|
||||||
href={`/posts/${slug}`}
|
href={`/posts/${slug}/`}
|
||||||
frontmatter={data}
|
frontmatter={data}
|
||||||
secHeading={false}
|
secHeading={false}
|
||||||
/>
|
/>
|
||||||
@@ -98,7 +98,7 @@ const socialCount = SOCIALS.filter(social => social.active).length;
|
|||||||
({ data, slug }, index) =>
|
({ data, slug }, index) =>
|
||||||
index < 4 && (
|
index < 4 && (
|
||||||
<Card
|
<Card
|
||||||
href={`/posts/${slug}`}
|
href={`/posts/${slug}/`}
|
||||||
frontmatter={data}
|
frontmatter={data}
|
||||||
secHeading={false}
|
secHeading={false}
|
||||||
/>
|
/>
|
||||||
@@ -110,7 +110,7 @@ const socialCount = SOCIALS.filter(social => social.active).length;
|
|||||||
}
|
}
|
||||||
|
|
||||||
<div class="all-posts-btn-wrapper">
|
<div class="all-posts-btn-wrapper">
|
||||||
<LinkButton href="/posts">
|
<LinkButton href="/posts/">
|
||||||
All Posts
|
All Posts
|
||||||
<svg xmlns="http://www.w3.org/2000/svg"
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
><path
|
><path
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export async function GET() {
|
|||||||
description: SITE.desc,
|
description: SITE.desc,
|
||||||
site: SITE.website,
|
site: SITE.website,
|
||||||
items: sortedPosts.map(({ data, slug }) => ({
|
items: sortedPosts.map(({ data, slug }) => ({
|
||||||
link: `posts/${slug}`,
|
link: `posts/${slug}/`,
|
||||||
title: data.title,
|
title: data.title,
|
||||||
description: data.description,
|
description: data.description,
|
||||||
pubDate: new Date(data.modDatetime ?? data.pubDatetime),
|
pubDate: new Date(data.modDatetime ?? data.pubDatetime),
|
||||||
|
|||||||
Reference in New Issue
Block a user