Fix permalinks with trailing slash in paginations
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
---
|
||||
import { Icon } from 'astro-icon';
|
||||
import { getPermalink } from '~/utils/permalinks';
|
||||
const { prevUrl, nextUrl, prevText = 'Newer posts', nextText = 'Older posts' } = Astro.props;
|
||||
---
|
||||
|
||||
@ -8,7 +9,7 @@ const { prevUrl, nextUrl, prevText = 'Newer posts', nextText = 'Older posts' } =
|
||||
<div class="container flex">
|
||||
<div class="flex flex-row mx-auto container justify-between">
|
||||
<a
|
||||
href={prevUrl}
|
||||
href={getPermalink(prevUrl, "raw")}
|
||||
class={`btn px-2 font-medium text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white shadow-none mr-2
|
||||
${!prevUrl ? 'invisible' : ''}`}
|
||||
>
|
||||
@ -18,7 +19,7 @@ const { prevUrl, nextUrl, prevText = 'Newer posts', nextText = 'Older posts' } =
|
||||
</div>
|
||||
</a>
|
||||
<a
|
||||
href={nextUrl}
|
||||
href={getPermalink(nextUrl, "raw")}
|
||||
class={`btn px-2 font-medium text-gray-600 hover:text-gray-900 dark:text-gray-400 dark:hover:text-white shadow-none ${
|
||||
!nextUrl ? 'invisible' : ''
|
||||
}`}
|
||||
|
@ -42,6 +42,9 @@ export const getPermalink = (slug = '', type = 'page') => {
|
||||
case 'post':
|
||||
return createPath(basePathname, POST_BASE, _slug);
|
||||
|
||||
case 'raw':
|
||||
return createPath(basePathname, trimSlash(slug));
|
||||
|
||||
case 'page':
|
||||
default:
|
||||
return createPath(basePathname, _slug);
|
||||
|
Reference in New Issue
Block a user