Replace SITE_CONFIG, UI_CONFIG, METADATA_CONFIG... to SITE, UI, METADATA...
This commit is contained in:
@ -13,21 +13,21 @@ import tasks from "./src/utils/tasks";
|
|||||||
|
|
||||||
import { readingTimeRemarkPlugin } from './src/utils/frontmatter.mjs';
|
import { readingTimeRemarkPlugin } from './src/utils/frontmatter.mjs';
|
||||||
|
|
||||||
import { ANALYTICS_CONFIG, SITE_CONFIG } from './src/utils/config.ts';
|
import { ANALYTICS, SITE } from './src/utils/config.ts';
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
const whenExternalScripts = (items = []) =>
|
const whenExternalScripts = (items = []) =>
|
||||||
ANALYTICS_CONFIG.vendors.googleAnalytics.id && ANALYTICS_CONFIG.vendors.googleAnalytics.partytown
|
ANALYTICS.vendors.googleAnalytics.id && ANALYTICS.vendors.googleAnalytics.partytown
|
||||||
? Array.isArray(items)
|
? Array.isArray(items)
|
||||||
? items.map((item) => item())
|
? items.map((item) => item())
|
||||||
: [items()]
|
: [items()]
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
site: SITE_CONFIG.site,
|
site: SITE.site,
|
||||||
base: SITE_CONFIG.base,
|
base: SITE.base,
|
||||||
trailingSlash: SITE_CONFIG.trailingSlash ? 'always' : 'never',
|
trailingSlash: SITE.trailingSlash ? 'always' : 'never',
|
||||||
|
|
||||||
output: 'static',
|
output: 'static',
|
||||||
|
|
||||||
|
@ -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">
|
<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>
|
</span>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
---
|
---
|
||||||
import { APP_BLOG_CONFIG } from '~/utils/config';
|
import { APP_BLOG } from '~/utils/config';
|
||||||
import type { Post } from '~/types';
|
import type { Post } from '~/types';
|
||||||
|
|
||||||
import Image from '~/components/common/Image.astro';
|
import Image from '~/components/common/Image.astro';
|
||||||
@ -39,7 +39,7 @@ const image = (await findImage(post.image));
|
|||||||
</div>
|
</div>
|
||||||
<h3 class="mb-2 text-xl font-bold leading-tight sm:text-2xl font-heading">
|
<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
|
post.title
|
||||||
) : (
|
) : (
|
||||||
<a
|
<a
|
||||||
|
@ -4,7 +4,7 @@ import { Icon } from 'astro-icon/components';
|
|||||||
import Image from '~/components/common/Image.astro';
|
import Image from '~/components/common/Image.astro';
|
||||||
import PostTags from '~/components/blog/Tags.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 type { Post } from '~/types';
|
||||||
|
|
||||||
import { getPermalink } from '~/utils/permalinks';
|
import { getPermalink } from '~/utils/permalinks';
|
||||||
@ -18,7 +18,7 @@ export interface Props {
|
|||||||
const { post } = Astro.props;
|
const { post } = Astro.props;
|
||||||
const image = (await findImage(post.image)) as ImageMetadata | undefined;
|
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' : ''}`}>
|
<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 { getPermalink } from '~/utils/permalinks';
|
||||||
|
|
||||||
import { APP_BLOG_CONFIG } from '~/utils/config';
|
import { APP_BLOG } from '~/utils/config';
|
||||||
import type { Post } from '~/types';
|
import type { Post } from '~/types';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
@ -23,7 +23,7 @@ const { tags, class: className = 'text-sm', title = undefined, isCategory = fals
|
|||||||
<ul class={className}>
|
<ul class={className}>
|
||||||
{tags.map((tag) => (
|
{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">
|
<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
|
tag
|
||||||
) : (
|
) : (
|
||||||
<a
|
<a
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from 'astro-icon/components';
|
import { Icon } from 'astro-icon/components';
|
||||||
import { getBlogPermalink } from '~/utils/permalinks';
|
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">
|
<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 { GoogleAnalytics } from '@astrolib/analytics';
|
||||||
import { ANALYTICS_CONFIG } from '~/utils/config';
|
import { ANALYTICS } from '~/utils/config';
|
||||||
---
|
---
|
||||||
|
|
||||||
{
|
{
|
||||||
ANALYTICS_CONFIG?.vendors?.googleAnalytics?.id ? (
|
ANALYTICS?.vendors?.googleAnalytics?.id ? (
|
||||||
<GoogleAnalytics id={String(ANALYTICS_CONFIG.vendors.googleAnalytics.id)} partytown={ANALYTICS_CONFIG?.vendors?.googleAnalytics?.partytown} />
|
<GoogleAnalytics id={String(ANALYTICS.vendors.googleAnalytics.id)} partytown={ANALYTICS?.vendors?.googleAnalytics?.partytown} />
|
||||||
) : null
|
) : null
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
---
|
---
|
||||||
import { UI_CONFIG } from "~/utils/config";
|
import { UI } from "~/utils/config";
|
||||||
|
|
||||||
// TODO: This code is temporary
|
// 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) {
|
function applyTheme(theme) {
|
||||||
if (theme === "dark") {
|
if (theme === "dark") {
|
||||||
document.documentElement.classList.add("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) {
|
function applyTheme(theme) {
|
||||||
if (theme === 'dark') {
|
if (theme === 'dark') {
|
||||||
document.documentElement.classList.add('dark');
|
document.documentElement.classList.add('dark');
|
||||||
|
@ -4,8 +4,8 @@ import { AstroSeo } from '@astrolib/seo';
|
|||||||
|
|
||||||
import type { AstroSeoProps } from '@astrolib/seo/src/types';
|
import type { AstroSeoProps } from '@astrolib/seo/src/types';
|
||||||
|
|
||||||
import { SITE_CONFIG, METADATA_CONFIG, I18N_CONFIG } from '~/utils/config';
|
import { SITE, METADATA, I18N } from '~/utils/config';
|
||||||
import { MetaData } from '~/types';
|
import type { MetaData } from '~/types';
|
||||||
import { getCanonical } from '~/utils/permalinks';
|
import { getCanonical } from '~/utils/permalinks';
|
||||||
|
|
||||||
import { adaptOpenGraphImages } from '~/utils/images';
|
import { adaptOpenGraphImages } from '~/utils/images';
|
||||||
@ -34,9 +34,9 @@ const seoProps: AstroSeoProps = merge(
|
|||||||
description: undefined,
|
description: undefined,
|
||||||
openGraph: {
|
openGraph: {
|
||||||
url: canonical,
|
url: canonical,
|
||||||
site_name: SITE_CONFIG?.name,
|
site_name: SITE?.name,
|
||||||
images: [],
|
images: [],
|
||||||
locale: I18N_CONFIG?.language || 'en',
|
locale: I18N?.language || 'en',
|
||||||
type: 'website',
|
type: 'website',
|
||||||
},
|
},
|
||||||
twitter: {
|
twitter: {
|
||||||
@ -44,13 +44,13 @@ const seoProps: AstroSeoProps = merge(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: METADATA_CONFIG?.title?.default,
|
title: METADATA?.title?.default,
|
||||||
titleTemplate: METADATA_CONFIG?.title?.template,
|
titleTemplate: METADATA?.title?.template,
|
||||||
noindex: typeof METADATA_CONFIG?.robots?.index !== 'undefined' ? !METADATA_CONFIG.robots.index : undefined,
|
noindex: typeof METADATA?.robots?.index !== 'undefined' ? !METADATA.robots.index : undefined,
|
||||||
nofollow: typeof METADATA_CONFIG?.robots?.follow !== 'undefined' ? !METADATA_CONFIG.robots.follow : undefined,
|
nofollow: typeof METADATA?.robots?.follow !== 'undefined' ? !METADATA.robots.follow : undefined,
|
||||||
description: METADATA_CONFIG?.description,
|
description: METADATA?.description,
|
||||||
openGraph: METADATA_CONFIG?.openGraph,
|
openGraph: METADATA?.openGraph,
|
||||||
twitter: METADATA_CONFIG?.twitter,
|
twitter: METADATA?.twitter,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: title,
|
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 { Icon } from 'astro-icon/components';
|
||||||
|
|
||||||
import { UI_CONFIG } from '~/utils/config';
|
import { UI } from '~/utils/config';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
label?: string;
|
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>
|
<button type="button" class={className} aria-label={label} data-aw-toggle-color-scheme>
|
||||||
<Icon name={iconName} class={iconClass} />
|
<Icon name={iconName} class={iconClass} />
|
||||||
</button>
|
</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";
|
import Grid from "~/components/blog/Grid.astro";
|
||||||
|
|
||||||
@ -29,11 +29,11 @@ const {
|
|||||||
bg = await Astro.slots.render("bg"),
|
bg = await Astro.slots.render("bg"),
|
||||||
} = Astro.props;
|
} = 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}>
|
<WidgetWrapper id={id} isDark={isDark} containerClass={classes?.container} bg={bg}>
|
||||||
<div class="flex flex-col lg:justify-between lg:flex-row mb-8">
|
<div class="flex flex-col lg:justify-between lg:flex-row mb-8">
|
||||||
{title && (
|
{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"
|
class="text-3xl font-bold tracking-tight sm:text-4xl sm:leading-none group font-heading mb-2"
|
||||||
set:html={title}
|
set:html={title}
|
||||||
/>
|
/>
|
||||||
{APP_BLOG_CONFIG.list.isEnabled && linkText && linkUrl && (
|
{APP_BLOG.list.isEnabled && linkText && linkUrl && (
|
||||||
<a
|
<a
|
||||||
class="text-muted dark:text-slate-400 hover:text-primary transition ease-in duration-200 block mb-6 lg:mb-0"
|
class="text-muted dark:text-slate-400 hover:text-primary transition ease-in duration-200 block mb-6 lg:mb-0"
|
||||||
href={linkUrl}
|
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";
|
import Grid from "~/components/blog/Grid.astro";
|
||||||
|
|
||||||
@ -29,11 +29,11 @@ const {
|
|||||||
bg = await Astro.slots.render("bg"),
|
bg = await Astro.slots.render("bg"),
|
||||||
} = Astro.props;
|
} = 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}>
|
<WidgetWrapper id={id} isDark={isDark} containerClass={classes?.container} bg={bg}>
|
||||||
<div class="flex flex-col lg:justify-between lg:flex-row mb-8">
|
<div class="flex flex-col lg:justify-between lg:flex-row mb-8">
|
||||||
{title && (
|
{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"
|
class="text-3xl font-bold tracking-tight sm:text-4xl sm:leading-none group font-heading mb-2"
|
||||||
set:html={title}
|
set:html={title}
|
||||||
/>
|
/>
|
||||||
{APP_BLOG_CONFIG.list.isEnabled && linkText && linkUrl && (
|
{APP_BLOG.list.isEnabled && linkText && linkUrl && (
|
||||||
<a
|
<a
|
||||||
class="text-muted dark:text-slate-400 hover:text-primary transition ease-in duration-200 block mb-6 lg:mb-0"
|
class="text-muted dark:text-slate-400 hover:text-primary transition ease-in duration-200 block mb-6 lg:mb-0"
|
||||||
href={linkUrl}
|
href={linkUrl}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
import { Icon } from 'astro-icon/components';
|
import { Icon } from 'astro-icon/components';
|
||||||
import { SITE_CONFIG } from '~/utils/config';
|
import { SITE } from '~/utils/config';
|
||||||
import { getHomePermalink } from '~/utils/permalinks';
|
import { getHomePermalink } from '~/utils/permalinks';
|
||||||
|
|
||||||
interface Link {
|
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="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="col-span-12 lg:col-span-4">
|
||||||
<div class="mb-2">
|
<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>
|
||||||
<div class="text-sm text-muted">
|
<div class="text-sm text-muted">
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
---
|
---
|
||||||
import '~/assets/styles/tailwind.css';
|
import '~/assets/styles/tailwind.css';
|
||||||
|
|
||||||
import { I18N_CONFIG } from "~/utils/config";
|
import { I18N } from "~/utils/config";
|
||||||
|
|
||||||
import CommonMeta from '~/components/common/CommonMeta.astro';
|
import CommonMeta from '~/components/common/CommonMeta.astro';
|
||||||
import Favicons from '~/components/Favicons.astro';
|
import Favicons from '~/components/Favicons.astro';
|
||||||
@ -19,7 +19,7 @@ export interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { metadata = {} } = Astro.props;
|
const { metadata = {} } = Astro.props;
|
||||||
const { language, textDirection } = I18N_CONFIG;
|
const { language, textDirection } = I18N;
|
||||||
---
|
---
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import rss from '@astrojs/rss';
|
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 { fetchPosts } from '~/utils/blog';
|
||||||
import { getPermalink } from '~/utils/permalinks';
|
import { getPermalink } from '~/utils/permalinks';
|
||||||
|
|
||||||
export const GET = async () => {
|
export const GET = async () => {
|
||||||
if (!APP_BLOG_CONFIG.isEnabled) {
|
if (!APP_BLOG.isEnabled) {
|
||||||
return new Response(null, {
|
return new Response(null, {
|
||||||
status: 404,
|
status: 404,
|
||||||
statusText: 'Not found',
|
statusText: 'Not found',
|
||||||
@ -15,8 +15,8 @@ export const GET = async () => {
|
|||||||
const posts = await fetchPosts();
|
const posts = await fetchPosts();
|
||||||
|
|
||||||
const { body = "" } = await rss({
|
const { body = "" } = await rss({
|
||||||
title: `${SITE_CONFIG.name}’s Blog`,
|
title: `${SITE.name}’s Blog`,
|
||||||
description: METADATA_CONFIG?.description || "",
|
description: METADATA?.description || "",
|
||||||
site: import.meta.env.SITE,
|
site: import.meta.env.SITE,
|
||||||
|
|
||||||
items: posts.map((post) => ({
|
items: posts.map((post) => ({
|
||||||
@ -26,7 +26,7 @@ export const GET = async () => {
|
|||||||
pubDate: post.publishDate,
|
pubDate: post.publishDate,
|
||||||
})),
|
})),
|
||||||
|
|
||||||
trailingSlash: SITE_CONFIG.trailingSlash,
|
trailingSlash: SITE.trailingSlash,
|
||||||
})
|
})
|
||||||
|
|
||||||
return new Response(body, {
|
return new Response(body, {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { getCollection } from 'astro:content';
|
import { getCollection } from 'astro:content';
|
||||||
import type { CollectionEntry } from 'astro:content';
|
import type { CollectionEntry } from 'astro:content';
|
||||||
import type { Post } from '~/types';
|
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';
|
import { cleanSlug, trimSlash, BLOG_BASE, POST_PERMALINK_PATTERN, CATEGORY_BASE, TAG_BASE } from './permalinks';
|
||||||
|
|
||||||
const generatePermalink = async ({
|
const generatePermalink = async ({
|
||||||
@ -103,18 +103,18 @@ const load = async function (): Promise<Array<Post>> {
|
|||||||
let _posts: Array<Post>;
|
let _posts: Array<Post>;
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
export const isBlogEnabled = APP_BLOG_CONFIG.isEnabled;
|
export const isBlogEnabled = APP_BLOG.isEnabled;
|
||||||
export const isBlogListRouteEnabled = APP_BLOG_CONFIG.list.isEnabled;
|
export const isBlogListRouteEnabled = APP_BLOG.list.isEnabled;
|
||||||
export const isBlogPostRouteEnabled = APP_BLOG_CONFIG.post.isEnabled;
|
export const isBlogPostRouteEnabled = APP_BLOG.post.isEnabled;
|
||||||
export const isBlogCategoryRouteEnabled = APP_BLOG_CONFIG.category.isEnabled;
|
export const isBlogCategoryRouteEnabled = APP_BLOG.category.isEnabled;
|
||||||
export const isBlogTagRouteEnabled = APP_BLOG_CONFIG.tag.isEnabled;
|
export const isBlogTagRouteEnabled = APP_BLOG.tag.isEnabled;
|
||||||
|
|
||||||
export const blogListRobots = APP_BLOG_CONFIG.list.robots;
|
export const blogListRobots = APP_BLOG.list.robots;
|
||||||
export const blogPostRobots = APP_BLOG_CONFIG.post.robots;
|
export const blogPostRobots = APP_BLOG.post.robots;
|
||||||
export const blogCategoryRobots = APP_BLOG_CONFIG.category.robots;
|
export const blogCategoryRobots = APP_BLOG.category.robots;
|
||||||
export const blogTagRobots = APP_BLOG_CONFIG.tag.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>> => {
|
export const fetchPosts = async (): Promise<Array<Post>> => {
|
||||||
|
@ -196,9 +196,9 @@ const getAnalytics = () => {
|
|||||||
return merge({}, _default, config?.analytics ?? {}) as AnalyticsConfig;
|
return merge({}, _default, config?.analytics ?? {}) as AnalyticsConfig;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const SITE_CONFIG = getSite();
|
export const SITE = getSite();
|
||||||
export const I18N_CONFIG = getI18N();
|
export const I18N = getI18N();
|
||||||
export const METADATA_CONFIG = getMetadata();
|
export const METADATA = getMetadata();
|
||||||
export const APP_BLOG_CONFIG = getAppBlog();
|
export const APP_BLOG = getAppBlog();
|
||||||
export const UI_CONFIG = getUI();
|
export const UI = getUI();
|
||||||
export const ANALYTICS_CONFIG = getAnalytics();
|
export const ANALYTICS = getAnalytics();
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import slugify from 'limax';
|
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';
|
import { trim } from '~/utils/utils';
|
||||||
|
|
||||||
@ -10,10 +10,10 @@ const createPath = (...params: string[]) => {
|
|||||||
.map((el) => trimSlash(el))
|
.map((el) => trimSlash(el))
|
||||||
.filter((el) => !!el)
|
.filter((el) => !!el)
|
||||||
.join('/');
|
.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 = '') =>
|
export const cleanSlug = (text = '') =>
|
||||||
trimSlash(text)
|
trimSlash(text)
|
||||||
@ -21,18 +21,18 @@ export const cleanSlug = (text = '') =>
|
|||||||
.map((slug) => slugify(slug))
|
.map((slug) => slugify(slug))
|
||||||
.join('/');
|
.join('/');
|
||||||
|
|
||||||
export const BLOG_BASE = cleanSlug(APP_BLOG_CONFIG?.list?.pathname);
|
export const BLOG_BASE = cleanSlug(APP_BLOG?.list?.pathname);
|
||||||
export const CATEGORY_BASE = cleanSlug(APP_BLOG_CONFIG?.category?.pathname);
|
export const CATEGORY_BASE = cleanSlug(APP_BLOG?.category?.pathname);
|
||||||
export const TAG_BASE = cleanSlug(APP_BLOG_CONFIG?.tag?.pathname) || 'tag';
|
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 => {
|
export const getCanonical = (path = ''): string | URL => {
|
||||||
const url = String(new URL(path, SITE_CONFIG.site));
|
const url = String(new URL(path, SITE.site));
|
||||||
if (SITE_CONFIG.trailingSlash == false && path && url.endsWith('/')) {
|
if (SITE.trailingSlash == false && path && url.endsWith('/')) {
|
||||||
return url.slice(0, -1);
|
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 + '/';
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { I18N_CONFIG } from '~/utils/config';
|
import { I18N } from '~/utils/config';
|
||||||
|
|
||||||
const formatter =
|
const formatter =
|
||||||
I18N_CONFIG?.dateFormatter ||
|
I18N?.dateFormatter ||
|
||||||
new Intl.DateTimeFormat('en', {
|
new Intl.DateTimeFormat('en', {
|
||||||
year: 'numeric',
|
year: 'numeric',
|
||||||
month: 'short',
|
month: 'short',
|
||||||
|
Reference in New Issue
Block a user