-
-
Notifications
You must be signed in to change notification settings - Fork 21
Add configuration-based visibility control for sections and elements #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
shrvansudhakara
wants to merge
2
commits into
coderdiaz:main
Choose a base branch
from
shrvansudhakara:feature/config-flags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Site Configuration - Control visibility of sections | ||
| sections: | ||
| about: true | ||
| workExperience: true | ||
| talks: true | ||
| writing: true | ||
| socialLinks: true | ||
|
|
||
| # Individual elements | ||
| elements: | ||
| avatar: true | ||
| themeSwitch: true | ||
| header: true | ||
| footer: true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,14 @@ | ||
| --- | ||
| import Container from '@/components/Container.astro'; | ||
| import { getSiteConfig } from '@/lib/config'; | ||
|
|
||
| const config = getSiteConfig(); | ||
| --- | ||
|
|
||
| <Container as='footer' class='pt-24'> | ||
| <p class="text-center text-muted-foreground text-sm"> | ||
| © {new Date().getFullYear()}. Powered by <a href="https://astro.build" target="_blank" rel="noopener noreferrer">Astro</a> and CVfolio. | ||
| </p> | ||
| </Container> | ||
| {config.elements.footer && ( | ||
| <Container as='footer' class='pt-24'> | ||
| <p class="text-center text-muted-foreground text-sm"> | ||
| © {new Date().getFullYear()}. Powered by <a href="https://astro.build" target="_blank" rel="noopener noreferrer">Astro</a> and CVfolio. | ||
| </p> | ||
| </Container> | ||
| )} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,43 +1,49 @@ | ||
| --- | ||
| import Container from '@/components/Container.astro'; | ||
| import { getSiteConfig } from '@/lib/config'; | ||
|
|
||
| const pathname = Astro.url.pathname; | ||
|
|
||
| const isHomePage = pathname === '/'; | ||
| const isWritingPage = pathname.startsWith('/writing'); | ||
| --- | ||
|
|
||
| <Container | ||
| as="header" | ||
| class="w-full max-w-full flex justify-center items-center" | ||
| > | ||
| <div | ||
| class="w-max fixed top-0 mt-5 bg-muted-foreground/40 backdrop-blur-3xl border border-border rounded-full p-1" | ||
| const config = getSiteConfig(); | ||
| --- | ||
| {config.elements.header && ( | ||
| <Container | ||
| as="header" | ||
| class="w-full max-w-full flex justify-center items-center" | ||
| > | ||
| <nav class="flex items-center"> | ||
| <ul class="flex items-center gap-1"> | ||
| <li> | ||
| <a | ||
| href="/" | ||
| class:list={[ | ||
| 'font-medium transition-colors block px-5 py-2', | ||
| 'hover:text-headings', | ||
| isHomePage && 'text-headings bg-muted-foreground/40 rounded-full', | ||
| ]}>Home</a | ||
| > | ||
| </li> | ||
| <li> | ||
| <a | ||
| href="/writing" | ||
| class:list={[ | ||
| 'font-medium transition-colors block px-5 py-2', | ||
| 'hover:text-headings', | ||
| isWritingPage && | ||
| 'text-headings bg-muted-foreground/40 rounded-full', | ||
| ]}>Writing</a | ||
| > | ||
| </li> | ||
| </ul> | ||
| </nav> | ||
| </div> | ||
| </Container> | ||
| <div | ||
| class="w-max fixed top-0 mt-5 bg-muted-foreground/40 backdrop-blur-3xl border border-border rounded-full p-1" | ||
| > | ||
| <nav class="flex items-center"> | ||
| <ul class="flex items-center gap-1"> | ||
| <li> | ||
| <a | ||
| href="/" | ||
| class:list={[ | ||
| 'font-medium transition-colors block px-5 py-2', | ||
| 'hover:text-headings', | ||
| isHomePage && 'text-headings bg-muted-foreground/40 rounded-full', | ||
| ]}>Home</a | ||
| > | ||
| </li> | ||
| {config.sections.writing && ( | ||
| <li> | ||
| <a | ||
| href="/writing" | ||
| class:list={[ | ||
| 'font-medium transition-colors block px-5 py-2', | ||
| 'hover:text-headings', | ||
| isWritingPage && | ||
| 'text-headings bg-muted-foreground/40 rounded-full', | ||
| ]}>Writing</a | ||
| > | ||
| </li> | ||
| )} | ||
| </ul> | ||
| </nav> | ||
| </div> | ||
| </Container> | ||
| )} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
| import yaml from 'js-yaml'; | ||
|
|
||
| interface SiteConfig { | ||
| sections: { | ||
| about: boolean; | ||
| workExperience: boolean; | ||
| talks: boolean; | ||
| writing: boolean; | ||
| socialLinks: boolean; | ||
| }; | ||
| elements: { | ||
| avatar: boolean; | ||
| themeSwitch: boolean; | ||
| header: boolean; | ||
| footer: boolean; | ||
| }; | ||
| } | ||
|
|
||
| const defaultConfig: SiteConfig = { | ||
| sections: { | ||
| about: true, | ||
| workExperience: true, | ||
| talks: true, | ||
| writing: true, | ||
| socialLinks: true, | ||
| }, | ||
| elements: { | ||
| avatar: true, | ||
| themeSwitch: true, | ||
| footer: true, | ||
| header: true, | ||
| }, | ||
| }; | ||
|
|
||
| export function getSiteConfig(): SiteConfig { | ||
| try { | ||
| const configPath = path.join(process.cwd(), 'config.yml'); | ||
| const fileContents = fs.readFileSync(configPath, 'utf8'); | ||
| return yaml.load(fileContents) as SiteConfig; | ||
| } catch (error) { | ||
| console.warn('config.yml not found, using defaults'); | ||
| return defaultConfig; | ||
shrvansudhakara marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.