diff --git a/package.json b/package.json
index ac141b9..54322ee 100644
--- a/package.json
+++ b/package.json
@@ -18,8 +18,8 @@
"@tailwindcss/typography": "^0.5.4",
"astro": "^1.0.0",
"astro-icon": "^0.7.3",
+ "limax": "^3.0.0",
"reading-time": "^1.5.0",
- "slugify": "^1.6.5",
"subfont": "^6.9.0"
}
}
diff --git a/src/components/widgets/BlogList.astro b/src/components/widgets/BlogList.astro
index 2896137..e3563d0 100644
--- a/src/components/widgets/BlogList.astro
+++ b/src/components/widgets/BlogList.astro
@@ -1,12 +1,12 @@
---
import BlogListItem from "~/components/widgets/BlogListItem.astro";
-const { page } = Astro.props;
+const { posts } = Astro.props;
---
{
- page.data.map((post) => (
+ posts.map((post) => (
-
diff --git a/src/pages/[...blog]/[...page].astro b/src/pages/[...blog]/[...page].astro
index de1a7a5..4762143 100644
--- a/src/pages/[...blog]/[...page].astro
+++ b/src/pages/[...blog]/[...page].astro
@@ -31,9 +31,9 @@ const meta = {
News and step-by-step guides about
- AstroWind
+ AstroWind
-
+
\ No newline at end of file
diff --git a/src/pages/[...blog]/[slug].astro b/src/pages/[...blog]/[slug].astro
index 13fe0ad..55b42d6 100644
--- a/src/pages/[...blog]/[slug].astro
+++ b/src/pages/[...blog]/[slug].astro
@@ -1,6 +1,6 @@
---
import { SITE, BLOG } from "~/config.mjs";
-import { getCanonical, getPermalink } from "~/utils/permalinks";
+import { getCanonical, getPermalink, cleanSlug, BLOG_BASE } from "~/utils/permalinks";
import { fetchPosts } from "~/utils/fetchPosts";
import { findImage } from "~/utils/findImage";
import Layout from "~/layouts/PageLayout.astro";
@@ -13,7 +13,7 @@ export async function getStaticPaths() {
const posts = await fetchPosts();
return posts.map((post) => ({
- params: { slug: post.slug, blog: BLOG.postsWithoutBlogSlug ? undefined : BLOG?.slug || undefined },
+ params: { slug: cleanSlug(post.slug), blog: BLOG.postsWithoutBlogSlug ? undefined : BLOG_BASE || undefined },
props: { post },
}));
}
diff --git a/src/pages/[...categories]/[category]/[...page].astro b/src/pages/[...categories]/[category]/[...page].astro
index cc5f695..ecada44 100644
--- a/src/pages/[...categories]/[category]/[...page].astro
+++ b/src/pages/[...categories]/[category]/[...page].astro
@@ -5,7 +5,7 @@ import { fetchPosts } from "~/utils/fetchPosts";
import Layout from "~/layouts/BlogLayout.astro";
import BlogList from "~/components/widgets/BlogList.astro";
import Pagination from "~/components/widgets/Pagination.astro";
-import { getCanonical, getPermalink, getSlug, CATEGORY_BASE } from "~/utils/permalinks";
+import { getCanonical, getPermalink, cleanSlug, CATEGORY_BASE } from "~/utils/permalinks";
export async function getStaticPaths({ paginate }) {
@@ -20,7 +20,7 @@ export async function getStaticPaths({ paginate }) {
return Array.from(categories).map((category) => (
paginate(posts.filter((post) => typeof post.category === "string" && category === post.category.toLowerCase()), {
- params: { category: getSlug(category), categories: CATEGORY_BASE || undefined },
+ params: { category: cleanSlug(category), categories: CATEGORY_BASE || undefined },
pageSize: BLOG.postsPerPage,
props: { category }
})
@@ -42,6 +42,6 @@ const meta = {
Category: {category}
-
+
\ No newline at end of file
diff --git a/src/pages/[...tags]/[tag]/[...page].astro b/src/pages/[...tags]/[tag]/[...page].astro
index dc45b49..f8b717e 100644
--- a/src/pages/[...tags]/[tag]/[...page].astro
+++ b/src/pages/[...tags]/[tag]/[...page].astro
@@ -4,7 +4,7 @@ import { fetchPosts } from "~/utils/fetchPosts";
import Layout from "~/layouts/BlogLayout.astro";
import BlogList from "~/components/widgets/BlogList.astro";
import Pagination from "~/components/widgets/Pagination.astro";
-import { getCanonical, getPermalink, getSlug, TAG_BASE } from "~/utils/permalinks";
+import { getCanonical, getPermalink, cleanSlug, TAG_BASE } from "~/utils/permalinks";
export async function getStaticPaths({ paginate }) {
@@ -19,7 +19,7 @@ export async function getStaticPaths({ paginate }) {
return Array.from(tags).map((tag) => (
paginate(posts.filter((post) => Array.isArray(post.tags) && post.tags.includes(tag)), {
- params: { tag: getSlug(tag), tags: TAG_BASE || undefined },
+ params: { tag: cleanSlug(tag), tags: TAG_BASE || undefined },
pageSize: BLOG.postsPerPage,
props: { tag },
})
@@ -41,6 +41,6 @@ const meta = {
Tag: {tag}
-
+
\ No newline at end of file
diff --git a/src/utils/permalinks.js b/src/utils/permalinks.js
index 7d96a4f..a43b48d 100644
--- a/src/utils/permalinks.js
+++ b/src/utils/permalinks.js
@@ -1,4 +1,4 @@
-import slugify from 'slugify'
+import slugify from 'limax';
import { SITE, BLOG } from "~/config.mjs";
const trim = (str, ch) => {
@@ -10,16 +10,16 @@ const trim = (str, ch) => {
return (start > 0 || end < str.length) ? str.substring(start, end) : str;
}
-const trimSlash = (s) => trim(s, "/");
+const trimSlash = (s) => trim(trim(s, "/"));
const createPath = (...params) => "/" + params.filter((el) => !!el).join("/")
const baseUrl = trimSlash(SITE.baseUrl);
-export const BLOG_BASE = slugify(trimSlash(BLOG.slug), { lower: true });
-export const CATEGORY_BASE = slugify(trim(BLOG?.category?.slug), { lower: true });
-export const TAG_BASE = slugify(trim(BLOG?.tag?.slug), { lower: true });
+export const cleanSlug = (text) => slugify(trimSlash(text));
-const cleanSlug = (slug) => trimSlash(slug);
+export const BLOG_BASE = cleanSlug(BLOG.slug);
+export const CATEGORY_BASE = cleanSlug(BLOG?.category?.slug);
+export const TAG_BASE = cleanSlug(BLOG?.tag?.slug);
export const getCanonical = (path = "") => new URL(path, SITE.domain);
@@ -46,6 +46,4 @@ export const getBlogPermalink = () => getPermalink(BLOG_BASE);
export const getHomePermalink = () => {
const permalink = getPermalink();
return permalink !== "/" ? permalink + "/" : permalink;
-}
-
-export const getSlug = (text) => slugify(text);
\ No newline at end of file
+}
\ No newline at end of file