diff --git a/astro.config.mjs b/astro.config.mjs index 80ffb1f..09e42b5 100644 --- a/astro.config.mjs +++ b/astro.config.mjs @@ -1,6 +1,6 @@ import { defineConfig } from "astro/config"; import { rehypeAccessibleEmojis } from "rehype-accessible-emojis"; -import { SITE } from "./src/content/custom"; +import { SITE } from "./src/content/site.config"; import mdx from "@astrojs/mdx"; import sitemap from "@astrojs/sitemap"; diff --git a/src/example_content/config.ts b/src/example_content/config.ts index afc955a..9a943a2 100644 --- a/src/example_content/config.ts +++ b/src/example_content/config.ts @@ -1,7 +1,7 @@ import { defineCollection, z } from "astro:content"; -import { CONFIG } from "@/content/custom"; +import { CONFIG } from "@/content/site.config"; -const DEFAULT_AUTHOR = CONFIG.AUTHOR !== undefined && CONFIG.AUTHOR; +const DEFAULT_AUTHOR = CONFIG.DEFAULT_AUTHOR !== undefined && CONFIG.DEFAULT_AUTHOR; const blogCollection = defineCollection({ type: "content", diff --git a/src/example_content/custom.ts b/src/example_content/custom.ts deleted file mode 100644 index a9dd426..0000000 --- a/src/example_content/custom.ts +++ /dev/null @@ -1,89 +0,0 @@ -// 引入类型声明 -// Introduce type declaration -import type { Config, MarqueeTOP, Metadata } from "@/content/types"; - -// 在这里设置你的网站地址,请以 "http://" 或者 "https://" 开头 -// Set your website address here, please start with "http://" or "https://" -// 如果暂时不想设置,请保持默认值:"http://example.com" -// If you do not want to set it yet, please keep the default value: "http://example.com" -export const SITE: string = "http://example.com"; - -// 网站相关信息 -// Website related information -export const CONFIG: Config = { - // 设置网站的默认图标 - // Set the default icon for the website - FAVICON: "favicon.ico", - - // 设置网站的默认语言 - // Set the default language for your website, for example "en" - DEFAULT_LOCALE: "zh-cn", - - // 全站文本内容书写方向: - // ltr = 从左到右,默认值,用于从左向右书写的语言(比如英语、中文等) - // rtl = 从右到左,用于从右向左书写的语言(比如阿拉伯语) - // The writing direction of the text content of the whole site: - // ltr = left to right, default value, used for languages ​​written from left to right (such as English, Chinese, etc.) - // rtl = right-to-left, for languages ​​written from right to left (such as Arabic) - DIR: "ltr", - - // 网站标题 - // Website title - TITLE: "Volantis GO", - - // 网站描述 - // Website description - DESCRIPTION: "A content site built with Astro", - - // 默认作者 - // Default author - AUTHOR: "Admin", - - // 是否启用在页面标题后面加上网站标题,仅字数不多时增加 - // Whether to enable adding the website title after the page title, and only increase it when the number of words is small - ADD_TITLE: true, - - // 分隔符选择: true = "|" , false = "-" , 只有 ADD_TITLE = true 时生效. - // Delimiter selection: true = "|" , false = "-" , only takes effect when ADD_TITLE = true. - DELIMITER: false, - - // 是否启用视图过渡动画: true = 启用, false = 禁用. - // Use view transitions: true = enable, false = Disable - VIEW_TRANSITIONS: true, - - // 是否启用较小字体大小 (true = 14px, false = 16px). - // Whether to use smaller font size (true = 14px, false = 16px). - USE_SMALLER_FONT: false, -}; - -// 顶部横条配置,启用时,所有页面将显示 -// Marquee top config, enabled on all pages when true -export const MARQUEE_TOP: MarqueeTOP = { - // 顶部横条使用开关,只有设置为 true 才启用。不使用,请设置为 false - // Enable / disable marquee top - ENABLE: true, - - // 横条内容的移动方向, left = 向左移动, right = 向右移动 - // Direction of movement of the marquee top content, left = leftward, right = rightward - DIRECTION: "left", - - // 横条的首要内容 - // The primary content of the marquee top - PRIMARY_CONTENT: "Welcome to Volantis GO", - - // 横条的次要内容 - // Secondary content in the mobile marquee top - SECONDARY_CONTENT: "A content site built with Astro", -}; - -// 网站首页的页面信息 -// Page information on the homepage of the website -export const HOME: Metadata = { - // 网站首页的标题 - // The title of the homepage of the website - TITLE: "Home", - - // 网站首页的描述 - // Description of website homepage - DESCRIPTION: "Welcome to Volantis GO", -}; diff --git a/src/example_content/site.config.ts b/src/example_content/site.config.ts new file mode 100644 index 0000000..709c6cd --- /dev/null +++ b/src/example_content/site.config.ts @@ -0,0 +1,69 @@ +// 引入类型声明 +// Introduce type declaration +import type { Config, Metadata } from "@/content/types"; + +// 在这里设置你的网站地址,请以 "http://" 或者 "https://" 开头 +// Set your website address here, please start with "http://" or "https://" +// 如果暂时不想设置,请保持默认值:"http://example.com" +// If you do not want to set it yet, please keep the default value: "http://example.com" +export const SITE: string = "http://example.com"; + +// 网站相关信息 +// Website related information +export const CONFIG: Config = { + // 全站文本内容书写方向: + // ltr = 从左到右,默认值,用于从左向右书写的语言(比如英语、中文等) + // rtl = 从右到左,用于从右向左书写的语言(比如阿拉伯语) + // The writing direction of the text content of the whole site: + // ltr = left to right, default value, used for languages ​​written from left to right (such as English, Chinese, etc.) + // rtl = right-to-left, for languages ​​written from right to left (such as Arabic) + DIR: "ltr", + + // 设置网站的默认图标 + // Set the default icon for the website + FAVICON: "favicon.ico", + + // 设置网站的默认语言 + // Set the default language for your website, for example "en" + DEFAULT_LOCALE: "zh-cn", + + // 网站标题。显示在浏览器标签页和社交媒体分享中。 + // Website title. Displayed in browser tab and social media shares. + DEFAULT_TITLE: "Volantis GO", + + // 网站简短描述。用于搜索引擎优化和社交媒体分享。 + // Short website description. Used for SEO and social media shares. + DEFAULT_DESCRIPTION: "A content site built with Astro", + + // 默认作者名称。用于文章元数据和作者页面。 + // Default author name. Used for article metadata and author pages. + DEFAULT_AUTHOR: "Admin", + + // 是否在页面标题后添加网站标题。仅当标题字数较少时添加,例如 "页面标题 | 网站标题"。 + // Append website title to page titles. Only applied when the title is short, e.g., "Page Title | Website Title". + ADD_TITLE: true, + + // 标题分隔符。仅当 ADD_TITLE 为 true 时生效。 true 使用 "|",false 使用 "-"。 + // Title delimiter. Only takes effect when ADD_TITLE is true. True for "|", false for "-". + DELIMITER: false, + + // 是否启用页面切换动画。 + // Enable page transition animations. + VIEW_TRANSITIONS: true, + + // 是否启用较小字体大小 (true = 14px, false = 16px). + // Whether to use smaller font size (true = 14px, false = 16px). + USE_SMALLER_FONT: false, +}; + +// 网站首页的页面信息 +// Page information on the homepage of the website +export const HOME: Metadata = { + // 网站首页标题,用于浏览器标签页和社交媒体分享。 + // Homepage title, displayed in browser tab and social media shares. + DEFAULT_TITLE: "Home", + + // 网站首页简短描述,用于搜索引擎优化和社交媒体分享。 + // Short homepage description, used for SEO and social media shares. + DEFAULT_DESCRIPTION: "Welcome to Volantis GO", +}; diff --git a/src/example_content/custom.css b/src/example_content/style.css similarity index 100% rename from src/example_content/custom.css rename to src/example_content/style.css diff --git a/src/layouts/BaseHead.astro b/src/layouts/BaseHead.astro index fb90f1b..07d7718 100644 --- a/src/layouts/BaseHead.astro +++ b/src/layouts/BaseHead.astro @@ -2,7 +2,7 @@ import "@/styles/base.css"; import "@/styles/global.css"; import "@/content/custom.css"; -import { CONFIG } from "@/content/custom"; +import { CONFIG } from "@/content/site.config"; import { ViewTransitions } from "astro:transitions"; type Props = { @@ -20,16 +20,16 @@ type Props = { const { description, pageType } = Astro.props; const favicon = CONFIG.FAVICON ? CONFIG.FAVICON : "favicon.ico"; -const author = Astro.props.author || CONFIG.AUTHOR || ""; +const author = Astro.props.author || CONFIG.DEFAULT_AUTHOR || ""; const joinDelimiter = CONFIG.DELIMITER ? ` | ` : ` - `; // 如果标题过长,就仅使用页面标题,否则,标题会包含站点名称(仅在 custom 里开启添加标题) // If the title is too long, just use the page title, otherwise the title will include the site name (Only enable adding title in custom) const title = Astro.props.title - ? Astro.props.title.length + CONFIG.TITLE.length + 3 <= 55 && CONFIG.ADD_TITLE - ? [Astro.props.title, CONFIG.TITLE].join(joinDelimiter) + ? Astro.props.title.length + CONFIG.DEFAULT_TITLE.length + 3 <= 55 && CONFIG.ADD_TITLE + ? [Astro.props.title, CONFIG.DEFAULT_TITLE].join(joinDelimiter) : Astro.props.title - : CONFIG.TITLE; + : CONFIG.DEFAULT_TITLE; // 如果没有图片则使用网站图标 // If there is no image, use a favicon diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 64d37f5..cec4464 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -1,5 +1,5 @@ --- -import { CONFIG } from "@/content/custom"; +import { CONFIG } from "@/content/site.config"; import BaseHead from "@/layouts/BaseHead.astro"; import Header from "@/layouts/components/Header.astro"; @@ -17,10 +17,10 @@ type Props = { }; const { - title = CONFIG.TITLE, - description = CONFIG.DESCRIPTION, + title = CONFIG.DEFAULT_TITLE, + description = CONFIG.DEFAULT_DESCRIPTION, date, - author = CONFIG.AUTHOR, + author = CONFIG.DEFAULT_AUTHOR, categories, tags, image, diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 8d68277..20caf9f 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -13,7 +13,7 @@ export async function getStaticPaths() { type Props = CollectionEntry<"blog">; const post = Astro.props; -const { Content, headings } = await post.render(); +const { Content } = await post.render(); ---