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 = { export const SITE = {
name: "Example", name: "Example",
domain: "https://example.com", origin: "https://example.com",
baseUrl: "/", // Change this if you need to deploy to Github Pages, for example basePathname: "/", // Change this if you need to deploy to Github Pages, for example
title: "Example - This is the homepage title of Example", title: "Example - This is the homepage title of Example",
description: "This is the homepage description 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 // https://astro.build/config
export default defineConfig({ export default defineConfig({
// Astro uses this full URL to generate your sitemap and canonical URLs in your final build // Astro uses this full URL to generate your sitemap and canonical URLs in your final build
site: SITE.domain, site: SITE.origin,
base: SITE.baseUrl, base: SITE.basePathname,
output: "static", output: "static",

View File

@ -1,8 +1,8 @@
export const SITE = { export const SITE = {
name: "AstroWind", name: "AstroWind",
domain: "https://astrowind.vercel.app", origin: "https://astrowind.vercel.app",
baseUrl: "/", basePathname: "/",
title: "AstroWind — Your website with Astro + Tailwind CSS", 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.", 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 trimSlash = (s) => trim(trim(s, "/"));
const createPath = (...params) => "/" + params.filter((el) => !!el).join("/") 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)); 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 CATEGORY_BASE = cleanSlug(BLOG?.category?.slug);
export const TAG_BASE = cleanSlug(BLOG?.tag?.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") => { export const getPermalink = (slug = "", type = "page") => {
const _slug = cleanSlug(slug); const _slug = cleanSlug(slug);
switch (type) { switch (type) {
case "category": case "category":
return createPath(baseUrl, CATEGORY_BASE, _slug) return createPath(basePathname, CATEGORY_BASE, _slug)
case "tag": case "tag":
return createPath(baseUrl, TAG_BASE, _slug) return createPath(basePathname, TAG_BASE, _slug)
case "post": case "post":
return createPath(baseUrl, BLOG.postsWithoutBlogSlug ? "" : BLOG_BASE, _slug); return createPath(basePathname, BLOG.postsWithoutBlogSlug ? "" : BLOG_BASE, _slug);
case "page": case "page":
default: default:
return createPath(baseUrl, _slug); return createPath(basePathname, _slug);
} }
}; };