Commit 160293f

HPCesia <me@hpcesia.com>
2026-01-31 06:09:07
Extract website title to config
1 parent ce783c2
Changed files (4)
src/layouts/GlobalLayout.astro
@@ -1,11 +1,12 @@
 ---
 import "@/styles/global.css";
+import { SITE_CONFIG } from "@/config";
 
 interface Props {
-  title: string;
+  title?: string;
 }
 
-const { title } = Astro.props;
+const { title = SITE_CONFIG.title } = Astro.props;
 ---
 
 <html lang="en">
src/pages/index.astro
@@ -1,7 +1,8 @@
 ---
+import { SITE_CONFIG } from "@/config";
 import GlobalLayout from "@/layouts/GlobalLayout.astro";
 ---
 
-<GlobalLayout title="Astro">
-  <h1>Astro</h1>
+<GlobalLayout>
+  <h1>{SITE_CONFIG.title}</h1>
 </GlobalLayout>
src/types/config.d.ts
@@ -0,0 +1,6 @@
+export type SiteConfig = {
+  /**
+   * Title of your website.
+   */
+  title: string;
+};
src/config.ts
@@ -0,0 +1,5 @@
+import type { SiteConfig } from "@/types/config.d.ts";
+
+export const SITE_CONFIG: SiteConfig = {
+  title: "Tybios",
+};