Replace configs names: origin & basePathname

This commit is contained in:
prototypa
2022-09-01 00:48:31 -04:00
parent bc4a0ad8dd
commit 88c69d0aae
4 changed files with 12 additions and 12 deletions

View File

@ -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.",

View File

@ -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);
}
};