From 88c69d0aaebdde184cebdc3d04a110cd90d9d6c6 Mon Sep 17 00:00:00 2001 From: prototypa Date: Thu, 1 Sep 2022 00:48:31 -0400 Subject: [PATCH] Replace configs names: origin & basePathname --- README.md | 4 ++-- astro.config.mjs | 4 ++-- src/config.mjs | 4 ++-- src/utils/permalinks.js | 12 ++++++------ 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 4b526ad..dabaad3 100644 --- a/README.md +++ b/README.md @@ -129,8 +129,8 @@ Basic configuration file: `./src/config.mjs` export const SITE = { name: "Example", - domain: "https://example.com", - baseUrl: "/", // Change this if you need to deploy to Github Pages, for example + origin: "https://example.com", + basePathname: "/", // Change this if you need to deploy to Github Pages, for example title: "Example - This is the homepage title of Example", description: "This is the homepage description of Example", diff --git a/astro.config.mjs b/astro.config.mjs index 773cc81..9837445 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -14,8 +14,8 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url)); // https://astro.build/config export default defineConfig({ // Astro uses this full URL to generate your sitemap and canonical URLs in your final build - site: SITE.domain, - base: SITE.baseUrl, + site: SITE.origin, + base: SITE.basePathname, output: "static", diff --git a/src/config.mjs b/src/config.mjs index 7d17344..7c23e9e 100644 --- a/src/config.mjs +++ b/src/config.mjs @@ -1,8 +1,8 @@ export const SITE = { name: "AstroWind", - domain: "https://astrowind.vercel.app", - baseUrl: "/", + origin: "https://astrowind.vercel.app", + basePathname: "/", title: "AstroWind — Your website with Astro + Tailwind CSS", description: "🚀 AstroWind is a free and ready to start template to make your website using Astro and Tailwind CSS.", diff --git a/src/utils/permalinks.js b/src/utils/permalinks.js index a43b48d..ce86706 100644 --- a/src/utils/permalinks.js +++ b/src/utils/permalinks.js @@ -13,7 +13,7 @@ const trim = (str, ch) => { const trimSlash = (s) => trim(trim(s, "/")); const createPath = (...params) => "/" + params.filter((el) => !!el).join("/") -const baseUrl = trimSlash(SITE.baseUrl); +const basePathname = trimSlash(SITE.basePathname); export const cleanSlug = (text) => slugify(trimSlash(text)); @@ -21,24 +21,24 @@ 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); +export const getCanonical = (path = "") => new URL(path, SITE.origin); export const getPermalink = (slug = "", type = "page") => { const _slug = cleanSlug(slug); switch (type) { case "category": - return createPath(baseUrl, CATEGORY_BASE, _slug) + return createPath(basePathname, CATEGORY_BASE, _slug) case "tag": - return createPath(baseUrl, TAG_BASE, _slug) + return createPath(basePathname, TAG_BASE, _slug) case "post": - return createPath(baseUrl, BLOG.postsWithoutBlogSlug ? "" : BLOG_BASE, _slug); + return createPath(basePathname, BLOG.postsWithoutBlogSlug ? "" : BLOG_BASE, _slug); case "page": default: - return createPath(baseUrl, _slug); + return createPath(basePathname, _slug); } };