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

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

View File

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

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