From 74b65c5fb02c0273e65e47f329fd3c5324e9af01 Mon Sep 17 00:00:00 2001 From: Sanjeev Kumar Date: Sun, 5 Oct 2025 07:42:54 +0530 Subject: [PATCH 1/2] Add config-based toggling for layout and sections Introduces cvfolio.config.json for toggling layout elements and page sections without modifying templates. Updates BaseLayout and page components to conditionally render header, footer, theme switcher, and homepage/writing sections based on config. Adds site-config utility for config loading and validation. Updates documentation to explain new configuration options. --- .gitignore | 3 + cvfolio.config.json | 20 +++++ docs/customization.md | 30 ++++++- src/layouts/BaseLayout.astro | 8 +- src/lib/site-config.ts | 153 ++++++++++++++++++++++++++++++++++ src/pages/index.astro | 43 ++++++---- src/pages/writing/index.astro | 33 +++++--- 7 files changed, 259 insertions(+), 31 deletions(-) create mode 100644 cvfolio.config.json create mode 100644 src/lib/site-config.ts diff --git a/.gitignore b/.gitignore index 16d54bb..777844f 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ pnpm-debug.log* # jetbrains setting folder .idea/ + +# Local configuration overrides +cvfolio.config.local.json diff --git a/cvfolio.config.json b/cvfolio.config.json new file mode 100644 index 0000000..2c6774f --- /dev/null +++ b/cvfolio.config.json @@ -0,0 +1,20 @@ +{ + "layout": { + "header": true, + "footer": true, + "themeSwitcher": true + }, + "sections": { + "homepage": { + "author": true, + "about": true, + "contact": true, + "workExperience": true, + "speaking": true + }, + "writing": { + "author": true, + "latestPosts": true + } + } +} diff --git a/docs/customization.md b/docs/customization.md index 16b2434..4093c54 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -16,4 +16,32 @@ Here’s an overview of folders relevant to customization: | `src/styles/global.css` | Global CSS and utility styles | | `src/lib/` | Utility functions and constants | -> You are free to preserve the labels of `Made by CVFolio` from the footer and the floating badge. \ No newline at end of file +> You are free to preserve the labels of `Made by CVFolio` from the footer and the floating badge. +## Toggle sections and elements + +You can hide built-in sections and UI elements without touching the templates by editing `cvfolio.config.json` at the project root. The defaults look like this: + +```json +{ + "layout": { + "header": true, + "footer": true, + "themeSwitcher": true + }, + "sections": { + "homepage": { + "author": true, + "about": true, + "contact": true, + "workExperience": true, + "speaking": true + }, + "writing": { + "author": true, + "latestPosts": true + } + } +} +``` + +Set any flag to `false` to remove that section from the rendered page while keeping the source code intact. diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index b9ba860..86bbc3e 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -6,22 +6,24 @@ import Header from '@/components/partials/Header.astro'; import Footer from '@/components/partials/Footer.astro'; import Head from '@/components/partials/Head.astro'; import SwitchTheme from '@/components/SwitchTheme.tsx'; +import { loadSiteConfig } from '@/lib/site-config'; interface Props { seo?: Seo } const { seo } = Astro.props; +const { layout } = await loadSiteConfig(); --- -
+ {layout.header &&
}
-