Replace SITE_CONFIG, UI_CONFIG, METADATA_CONFIG... to SITE, UI, METADATA...
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
---
|
||||
import { SITE_CONFIG } from '~/utils/config';
|
||||
import { SITE } from '~/utils/config';
|
||||
---
|
||||
|
||||
<span class="self-center ml-2 rtl:ml-0 rtl:mr-2 text-2xl md:text-xl font-bold text-gray-900 whitespace-nowrap dark:text-white">
|
||||
🚀 {SITE_CONFIG?.name}
|
||||
🚀 {SITE?.name}
|
||||
</span>
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
import { APP_BLOG_CONFIG } from '~/utils/config';
|
||||
import { APP_BLOG } from '~/utils/config';
|
||||
import type { Post } from '~/types';
|
||||
|
||||
import Image from '~/components/common/Image.astro';
|
||||
@ -39,7 +39,7 @@ const image = (await findImage(post.image));
|
||||
</div>
|
||||
<h3 class="mb-2 text-xl font-bold leading-tight sm:text-2xl font-heading">
|
||||
{
|
||||
!APP_BLOG_CONFIG?.post?.isEnabled ? (
|
||||
!APP_BLOG?.post?.isEnabled ? (
|
||||
post.title
|
||||
) : (
|
||||
<a
|
||||
|
@ -4,7 +4,7 @@ import { Icon } from 'astro-icon/components';
|
||||
import Image from '~/components/common/Image.astro';
|
||||
import PostTags from '~/components/blog/Tags.astro';
|
||||
|
||||
import { APP_BLOG_CONFIG } from '~/utils/config';
|
||||
import { APP_BLOG } from '~/utils/config';
|
||||
import type { Post } from '~/types';
|
||||
|
||||
import { getPermalink } from '~/utils/permalinks';
|
||||
@ -18,7 +18,7 @@ export interface Props {
|
||||
const { post } = Astro.props;
|
||||
const image = (await findImage(post.image)) as ImageMetadata | undefined;
|
||||
|
||||
const link = APP_BLOG_CONFIG?.post?.isEnabled ? getPermalink(post.permalink, 'post') : '';
|
||||
const link = APP_BLOG?.post?.isEnabled ? getPermalink(post.permalink, 'post') : '';
|
||||
---
|
||||
|
||||
<article class={`max-w-md mx-auto md:max-w-none grid gap-6 md:gap-8 ${image ? 'md:grid-cols-2' : ''}`}>
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
import { getPermalink } from '~/utils/permalinks';
|
||||
|
||||
import { APP_BLOG_CONFIG } from '~/utils/config';
|
||||
import { APP_BLOG } from '~/utils/config';
|
||||
import type { Post } from '~/types';
|
||||
|
||||
export interface Props {
|
||||
@ -23,7 +23,7 @@ const { tags, class: className = 'text-sm', title = undefined, isCategory = fals
|
||||
<ul class={className}>
|
||||
{tags.map((tag) => (
|
||||
<li class="bg-gray-100 dark:bg-slate-700 inline-block mr-2 rtl:mr-0 rtl:ml-2 mb-2 py-0.5 px-2 lowercase font-medium">
|
||||
{!APP_BLOG_CONFIG?.tag?.isEnabled ? (
|
||||
{!APP_BLOG?.tag?.isEnabled ? (
|
||||
tag
|
||||
) : (
|
||||
<a
|
||||
|
@ -1,9 +1,9 @@
|
||||
---
|
||||
import { Icon } from 'astro-icon/components';
|
||||
import { getBlogPermalink } from '~/utils/permalinks';
|
||||
import { I18N_CONFIG } from '~/utils/config';
|
||||
import { I18N } from '~/utils/config';
|
||||
|
||||
const { textDirection } = I18N_CONFIG;
|
||||
const { textDirection } = I18N;
|
||||
---
|
||||
|
||||
<div class="mx-auto px-6 sm:px-6 max-w-3xl pt-8 md:pt-4 pb-12 md:pb-20">
|
||||
|
@ -1,10 +1,10 @@
|
||||
---
|
||||
import { GoogleAnalytics } from '@astrolib/analytics';
|
||||
import { ANALYTICS_CONFIG } from '~/utils/config';
|
||||
import { ANALYTICS } from '~/utils/config';
|
||||
---
|
||||
|
||||
{
|
||||
ANALYTICS_CONFIG?.vendors?.googleAnalytics?.id ? (
|
||||
<GoogleAnalytics id={String(ANALYTICS_CONFIG.vendors.googleAnalytics.id)} partytown={ANALYTICS_CONFIG?.vendors?.googleAnalytics?.partytown} />
|
||||
ANALYTICS?.vendors?.googleAnalytics?.id ? (
|
||||
<GoogleAnalytics id={String(ANALYTICS.vendors.googleAnalytics.id)} partytown={ANALYTICS?.vendors?.googleAnalytics?.partytown} />
|
||||
) : null
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
---
|
||||
import { UI_CONFIG } from "~/utils/config";
|
||||
import { UI } from "~/utils/config";
|
||||
|
||||
// TODO: This code is temporary
|
||||
---
|
||||
|
||||
<script is:inline define:vars={{ defaultTheme: UI_CONFIG.theme || "system" }}>
|
||||
<script is:inline define:vars={{ defaultTheme: UI.theme || "system" }}>
|
||||
function applyTheme(theme) {
|
||||
if (theme === "dark") {
|
||||
document.documentElement.classList.add("dark");
|
||||
|
@ -1,8 +1,8 @@
|
||||
---
|
||||
import { UI_CONFIG } from '~/utils/config';
|
||||
import { UI } from '~/utils/config';
|
||||
---
|
||||
|
||||
<script is:inline define:vars={{ defaultTheme: UI_CONFIG.theme }}>
|
||||
<script is:inline define:vars={{ defaultTheme: UI.theme }}>
|
||||
function applyTheme(theme) {
|
||||
if (theme === 'dark') {
|
||||
document.documentElement.classList.add('dark');
|
||||
|
@ -4,8 +4,8 @@ import { AstroSeo } from '@astrolib/seo';
|
||||
|
||||
import type { AstroSeoProps } from '@astrolib/seo/src/types';
|
||||
|
||||
import { SITE_CONFIG, METADATA_CONFIG, I18N_CONFIG } from '~/utils/config';
|
||||
import { MetaData } from '~/types';
|
||||
import { SITE, METADATA, I18N } from '~/utils/config';
|
||||
import type { MetaData } from '~/types';
|
||||
import { getCanonical } from '~/utils/permalinks';
|
||||
|
||||
import { adaptOpenGraphImages } from '~/utils/images';
|
||||
@ -34,9 +34,9 @@ const seoProps: AstroSeoProps = merge(
|
||||
description: undefined,
|
||||
openGraph: {
|
||||
url: canonical,
|
||||
site_name: SITE_CONFIG?.name,
|
||||
site_name: SITE?.name,
|
||||
images: [],
|
||||
locale: I18N_CONFIG?.language || 'en',
|
||||
locale: I18N?.language || 'en',
|
||||
type: 'website',
|
||||
},
|
||||
twitter: {
|
||||
@ -44,13 +44,13 @@ const seoProps: AstroSeoProps = merge(
|
||||
},
|
||||
},
|
||||
{
|
||||
title: METADATA_CONFIG?.title?.default,
|
||||
titleTemplate: METADATA_CONFIG?.title?.template,
|
||||
noindex: typeof METADATA_CONFIG?.robots?.index !== 'undefined' ? !METADATA_CONFIG.robots.index : undefined,
|
||||
nofollow: typeof METADATA_CONFIG?.robots?.follow !== 'undefined' ? !METADATA_CONFIG.robots.follow : undefined,
|
||||
description: METADATA_CONFIG?.description,
|
||||
openGraph: METADATA_CONFIG?.openGraph,
|
||||
twitter: METADATA_CONFIG?.twitter,
|
||||
title: METADATA?.title?.default,
|
||||
titleTemplate: METADATA?.title?.template,
|
||||
noindex: typeof METADATA?.robots?.index !== 'undefined' ? !METADATA.robots.index : undefined,
|
||||
nofollow: typeof METADATA?.robots?.follow !== 'undefined' ? !METADATA.robots.follow : undefined,
|
||||
description: METADATA?.description,
|
||||
openGraph: METADATA?.openGraph,
|
||||
twitter: METADATA?.twitter,
|
||||
},
|
||||
{
|
||||
title: title,
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
import { SITE_CONFIG } from "~/utils/config";
|
||||
import { SITE } from "~/utils/config";
|
||||
---
|
||||
|
||||
{SITE_CONFIG.googleSiteVerificationId && <meta name="google-site-verification" content={SITE_CONFIG.googleSiteVerificationId} />}
|
||||
{SITE.googleSiteVerificationId && <meta name="google-site-verification" content={SITE.googleSiteVerificationId} />}
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
import { Icon } from 'astro-icon/components';
|
||||
|
||||
import { UI_CONFIG } from '~/utils/config';
|
||||
import { UI } from '~/utils/config';
|
||||
|
||||
export interface Props {
|
||||
label?: string;
|
||||
@ -20,7 +20,7 @@ const {
|
||||
---
|
||||
|
||||
{
|
||||
!(UI_CONFIG.theme && UI_CONFIG.theme.endsWith(':only')) && (
|
||||
!(UI.theme && UI.theme.endsWith(':only')) && (
|
||||
<button type="button" class={className} aria-label={label} data-aw-toggle-color-scheme>
|
||||
<Icon name={iconName} class={iconClass} />
|
||||
</button>
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
import { APP_BLOG_CONFIG } from "~/utils/config";
|
||||
import { APP_BLOG } from "~/utils/config";
|
||||
|
||||
import Grid from "~/components/blog/Grid.astro";
|
||||
|
||||
@ -29,11 +29,11 @@ const {
|
||||
bg = await Astro.slots.render("bg"),
|
||||
} = Astro.props;
|
||||
|
||||
const posts = APP_BLOG_CONFIG.isEnabled ? await findPostsByIds(postIds) : [];
|
||||
const posts = APP_BLOG.isEnabled ? await findPostsByIds(postIds) : [];
|
||||
---
|
||||
|
||||
{
|
||||
APP_BLOG_CONFIG.isEnabled ? (
|
||||
APP_BLOG.isEnabled ? (
|
||||
<WidgetWrapper id={id} isDark={isDark} containerClass={classes?.container} bg={bg}>
|
||||
<div class="flex flex-col lg:justify-between lg:flex-row mb-8">
|
||||
{title && (
|
||||
@ -42,7 +42,7 @@ const posts = APP_BLOG_CONFIG.isEnabled ? await findPostsByIds(postIds) : [];
|
||||
class="text-3xl font-bold tracking-tight sm:text-4xl sm:leading-none group font-heading mb-2"
|
||||
set:html={title}
|
||||
/>
|
||||
{APP_BLOG_CONFIG.list.isEnabled && linkText && linkUrl && (
|
||||
{APP_BLOG.list.isEnabled && linkText && linkUrl && (
|
||||
<a
|
||||
class="text-muted dark:text-slate-400 hover:text-primary transition ease-in duration-200 block mb-6 lg:mb-0"
|
||||
href={linkUrl}
|
||||
|
@ -1,5 +1,5 @@
|
||||
---
|
||||
import { APP_BLOG_CONFIG } from "~/utils/config";
|
||||
import { APP_BLOG } from "~/utils/config";
|
||||
|
||||
import Grid from "~/components/blog/Grid.astro";
|
||||
|
||||
@ -29,11 +29,11 @@ const {
|
||||
bg = await Astro.slots.render("bg"),
|
||||
} = Astro.props;
|
||||
|
||||
const posts = APP_BLOG_CONFIG.isEnabled ? await findLatestPosts({ count }) : [];
|
||||
const posts = APP_BLOG.isEnabled ? await findLatestPosts({ count }) : [];
|
||||
---
|
||||
|
||||
{
|
||||
APP_BLOG_CONFIG.isEnabled ? (
|
||||
APP_BLOG.isEnabled ? (
|
||||
<WidgetWrapper id={id} isDark={isDark} containerClass={classes?.container} bg={bg}>
|
||||
<div class="flex flex-col lg:justify-between lg:flex-row mb-8">
|
||||
{title && (
|
||||
@ -42,7 +42,7 @@ const posts = APP_BLOG_CONFIG.isEnabled ? await findLatestPosts({ count }) : [];
|
||||
class="text-3xl font-bold tracking-tight sm:text-4xl sm:leading-none group font-heading mb-2"
|
||||
set:html={title}
|
||||
/>
|
||||
{APP_BLOG_CONFIG.list.isEnabled && linkText && linkUrl && (
|
||||
{APP_BLOG.list.isEnabled && linkText && linkUrl && (
|
||||
<a
|
||||
class="text-muted dark:text-slate-400 hover:text-primary transition ease-in duration-200 block mb-6 lg:mb-0"
|
||||
href={linkUrl}
|
||||
|
@ -1,6 +1,6 @@
|
||||
---
|
||||
import { Icon } from 'astro-icon/components';
|
||||
import { SITE_CONFIG } from '~/utils/config';
|
||||
import { SITE } from '~/utils/config';
|
||||
import { getHomePermalink } from '~/utils/permalinks';
|
||||
|
||||
interface Link {
|
||||
@ -32,7 +32,7 @@ const { socialLinks = [], secondaryLinks = [], links = [], footNote = '', theme
|
||||
<div class="grid grid-cols-12 gap-4 gap-y-8 sm:gap-8 py-8 md:py-12">
|
||||
<div class="col-span-12 lg:col-span-4">
|
||||
<div class="mb-2">
|
||||
<a class="inline-block font-bold text-xl" href={getHomePermalink()}>{SITE_CONFIG?.name}</a>
|
||||
<a class="inline-block font-bold text-xl" href={getHomePermalink()}>{SITE?.name}</a>
|
||||
</div>
|
||||
<div class="text-sm text-muted">
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
import '~/assets/styles/tailwind.css';
|
||||
|
||||
import { I18N_CONFIG } from "~/utils/config";
|
||||
import { I18N } from "~/utils/config";
|
||||
|
||||
import CommonMeta from '~/components/common/CommonMeta.astro';
|
||||
import Favicons from '~/components/Favicons.astro';
|
||||
@ -19,7 +19,7 @@ export interface Props {
|
||||
}
|
||||
|
||||
const { metadata = {} } = Astro.props;
|
||||
const { language, textDirection } = I18N_CONFIG;
|
||||
const { language, textDirection } = I18N;
|
||||
---
|
||||
|
||||
<!DOCTYPE html>
|
||||
|
@ -1,11 +1,11 @@
|
||||
import rss from '@astrojs/rss';
|
||||
|
||||
import { SITE_CONFIG, METADATA_CONFIG, APP_BLOG_CONFIG } from '~/utils/config';
|
||||
import { SITE, METADATA, APP_BLOG } from '~/utils/config';
|
||||
import { fetchPosts } from '~/utils/blog';
|
||||
import { getPermalink } from '~/utils/permalinks';
|
||||
|
||||
export const GET = async () => {
|
||||
if (!APP_BLOG_CONFIG.isEnabled) {
|
||||
if (!APP_BLOG.isEnabled) {
|
||||
return new Response(null, {
|
||||
status: 404,
|
||||
statusText: 'Not found',
|
||||
@ -15,8 +15,8 @@ export const GET = async () => {
|
||||
const posts = await fetchPosts();
|
||||
|
||||
const { body = "" } = await rss({
|
||||
title: `${SITE_CONFIG.name}’s Blog`,
|
||||
description: METADATA_CONFIG?.description || "",
|
||||
title: `${SITE.name}’s Blog`,
|
||||
description: METADATA?.description || "",
|
||||
site: import.meta.env.SITE,
|
||||
|
||||
items: posts.map((post) => ({
|
||||
@ -26,7 +26,7 @@ export const GET = async () => {
|
||||
pubDate: post.publishDate,
|
||||
})),
|
||||
|
||||
trailingSlash: SITE_CONFIG.trailingSlash,
|
||||
trailingSlash: SITE.trailingSlash,
|
||||
})
|
||||
|
||||
return new Response(body, {
|
||||
|
@ -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>> => {
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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',
|
||||
|
Reference in New Issue
Block a user