From b814569bc638b02a70cf2ae21b60da6fde1c8e00 Mon Sep 17 00:00:00 2001 From: grassblock Date: Sat, 24 May 2025 22:09:25 +0800 Subject: [PATCH] feat: use src/content/index.md to render homepage --- src/content/index.md | 6 ++++++ src/pages/index.astro | 18 +++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 src/content/index.md diff --git a/src/content/index.md b/src/content/index.md new file mode 100644 index 0000000..32e0c36 --- /dev/null +++ b/src/content/index.md @@ -0,0 +1,6 @@ +# Welcome +Thank you for choosing this theme! + +If you want to see the posts, check out the [posts](/blog) page. + +If you are site owner, you can manually edit the content of this page by editing the `src/content/index.md` file. \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index 5fc47fd..c130d7a 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -1,15 +1,23 @@ --- import Layout from '../layouts/Layout.astro'; - +// Conditionally import content if file exists +let HomePageContent; +try { + const module = await import('../content/index.md'); + HomePageContent = module.Content; +} catch (e) { + // File doesn't exist or couldn't be imported + console.log('Homepage content not found, using default content'); +} ---

~/

+ {HomePageContent ? :

Welcome!

- - Not much here yet, but you can check out my blog posts here. -
- If you are site owner, please edit src/pages/index.astro to customize this page. +

Not much here yet, but you can check out my blog posts here.

+

If you are site owner, please create src/content/index.md to customize this page.

+ }
\ No newline at end of file