Replace SITE_CONFIG, UI_CONFIG, METADATA_CONFIG... to SITE, UI, METADATA...

This commit is contained in:
prototypa
2023-08-22 22:22:53 -04:00
parent 9d23150832
commit da8ef74b38
21 changed files with 83 additions and 83 deletions

View File

@@ -1,7 +1,7 @@
import { getCollection } from 'astro:content';
import type { CollectionEntry } from 'astro:content';
import type { Post } from '~/types';
import { APP_BLOG_CONFIG } from '~/utils/config';
import { APP_BLOG } from '~/utils/config';
import { cleanSlug, trimSlash, BLOG_BASE, POST_PERMALINK_PATTERN, CATEGORY_BASE, TAG_BASE } from './permalinks';
const generatePermalink = async ({
@@ -103,18 +103,18 @@ const load = async function (): Promise<Array<Post>> {
let _posts: Array<Post>;
/** */
export const isBlogEnabled = APP_BLOG_CONFIG.isEnabled;
export const isBlogListRouteEnabled = APP_BLOG_CONFIG.list.isEnabled;
export const isBlogPostRouteEnabled = APP_BLOG_CONFIG.post.isEnabled;
export const isBlogCategoryRouteEnabled = APP_BLOG_CONFIG.category.isEnabled;
export const isBlogTagRouteEnabled = APP_BLOG_CONFIG.tag.isEnabled;
export const isBlogEnabled = APP_BLOG.isEnabled;
export const isBlogListRouteEnabled = APP_BLOG.list.isEnabled;
export const isBlogPostRouteEnabled = APP_BLOG.post.isEnabled;
export const isBlogCategoryRouteEnabled = APP_BLOG.category.isEnabled;
export const isBlogTagRouteEnabled = APP_BLOG.tag.isEnabled;
export const blogListRobots = APP_BLOG_CONFIG.list.robots;
export const blogPostRobots = APP_BLOG_CONFIG.post.robots;
export const blogCategoryRobots = APP_BLOG_CONFIG.category.robots;
export const blogTagRobots = APP_BLOG_CONFIG.tag.robots;
export const blogListRobots = APP_BLOG.list.robots;
export const blogPostRobots = APP_BLOG.post.robots;
export const blogCategoryRobots = APP_BLOG.category.robots;
export const blogTagRobots = APP_BLOG.tag.robots;
export const blogPostsPerPage = APP_BLOG_CONFIG?.postsPerPage;
export const blogPostsPerPage = APP_BLOG?.postsPerPage;
/** */
export const fetchPosts = async (): Promise<Array<Post>> => {

View File

@@ -196,9 +196,9 @@ const getAnalytics = () => {
return merge({}, _default, config?.analytics ?? {}) as AnalyticsConfig;
};
export const SITE_CONFIG = getSite();
export const I18N_CONFIG = getI18N();
export const METADATA_CONFIG = getMetadata();
export const APP_BLOG_CONFIG = getAppBlog();
export const UI_CONFIG = getUI();
export const ANALYTICS_CONFIG = getAnalytics();
export const SITE = getSite();
export const I18N = getI18N();
export const METADATA = getMetadata();
export const APP_BLOG = getAppBlog();
export const UI = getUI();
export const ANALYTICS = getAnalytics();

View File

@@ -1,6 +1,6 @@
import slugify from 'limax';
import { SITE_CONFIG, APP_BLOG_CONFIG } from '~/utils/config';
import { SITE, APP_BLOG } from '~/utils/config';
import { trim } from '~/utils/utils';
@@ -10,10 +10,10 @@ const createPath = (...params: string[]) => {
.map((el) => trimSlash(el))
.filter((el) => !!el)
.join('/');
return '/' + paths + (SITE_CONFIG.trailingSlash && paths ? '/' : '');
return '/' + paths + (SITE.trailingSlash && paths ? '/' : '');
};
const BASE_PATHNAME = SITE_CONFIG.base || '/';
const BASE_PATHNAME = SITE.base || '/';
export const cleanSlug = (text = '') =>
trimSlash(text)
@@ -21,18 +21,18 @@ export const cleanSlug = (text = '') =>
.map((slug) => slugify(slug))
.join('/');
export const BLOG_BASE = cleanSlug(APP_BLOG_CONFIG?.list?.pathname);
export const CATEGORY_BASE = cleanSlug(APP_BLOG_CONFIG?.category?.pathname);
export const TAG_BASE = cleanSlug(APP_BLOG_CONFIG?.tag?.pathname) || 'tag';
export const BLOG_BASE = cleanSlug(APP_BLOG?.list?.pathname);
export const CATEGORY_BASE = cleanSlug(APP_BLOG?.category?.pathname);
export const TAG_BASE = cleanSlug(APP_BLOG?.tag?.pathname) || 'tag';
export const POST_PERMALINK_PATTERN = trimSlash(APP_BLOG_CONFIG?.post?.permalink || `${BLOG_BASE}/%slug%`);
export const POST_PERMALINK_PATTERN = trimSlash(APP_BLOG?.post?.permalink || `${BLOG_BASE}/%slug%`);
/** */
export const getCanonical = (path = ''): string | URL => {
const url = String(new URL(path, SITE_CONFIG.site));
if (SITE_CONFIG.trailingSlash == false && path && url.endsWith('/')) {
const url = String(new URL(path, SITE.site));
if (SITE.trailingSlash == false && path && url.endsWith('/')) {
return url.slice(0, -1);
} else if (SITE_CONFIG.trailingSlash == true && path && !url.endsWith('/')) {
} else if (SITE.trailingSlash == true && path && !url.endsWith('/')) {
return url + '/';
}
return url;

View File

@@ -1,7 +1,7 @@
import { I18N_CONFIG } from '~/utils/config';
import { I18N } from '~/utils/config';
const formatter =
I18N_CONFIG?.dateFormatter ||
I18N?.dateFormatter ||
new Intl.DateTimeFormat('en', {
year: 'numeric',
month: 'short',