Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
blog:2025:0917astro_attempt [2025/09/18 01:00] – [NEXT!! MAKING THE SITE] scumsuck | blog:2025:0917astro_attempt [2025/09/21 00:22] (current) – [Color toggle] scumsuck | ||
---|---|---|---|
Line 5: | Line 5: | ||
- Opened up VS Codium | - Opened up VS Codium | ||
- Opened up terminal | - Opened up terminal | ||
- | - ran ``npm create astro@latest`` as per tutorial | + | - ran '' |
- gave it a folder to build in ``Z: | - gave it a folder to build in ``Z: | ||
- said yes to everything like installing dependencies and initializing git | - said yes to everything like installing dependencies and initializing git | ||
Line 13: | Line 13: | ||
=====NEXT!! MAKING THE SITE===== | =====NEXT!! MAKING THE SITE===== | ||
- | - run ``npm run dev`` in the terminal to preview your gay site | + | - run '' |
- | - your site preview should be on ``http:// | + | - your site preview should be on '' |
- | - find ``src/ | + | - find '' |
- edit it | - edit it | ||
- save | - save | ||
Line 24: | Line 24: | ||
- wait for it to generate SSL certificate | - wait for it to generate SSL certificate | ||
- ok it's live: https:// | - ok it's live: https:// | ||
- | - make a new page in ``pages`` called | + | - make a new page in '' |
- | - type some shit in there, copy/paste what was in index.astro | + | - type some shit in there, copy/paste what was in '' |
- Did the markdown tutorial i already know that | - Did the markdown tutorial i already know that | ||
- on the [[https:// | - on the [[https:// | ||
Line 39: | Line 39: | ||
Stylize it tomorrow | Stylize it tomorrow | ||
+ | ===== Color toggle ===== | ||
+ | |||
+ | I'm copying this guide: [[https:// | ||
+ | |||
+ | I am specifically using this guide because it uses the default light/dark css themes that don't require any CSS, and allows the user to override it if they want to choose another theme. | ||
+ | |||
+ | I specifically want the ability to change background images, not just background color. | ||
+ | |||
+ | < | ||
+ | :root { | ||
+ | /* dark style, dark = default */ | ||
+ | color-scheme: | ||
+ | --bg: url('/ | ||
+ | transition-duration: | ||
+ | transition-property: | ||
+ | |||
+ | /* page preference is " | ||
+ | &: | ||
+ | --color-scheme: | ||
+ | /* any additional dark styles */ | ||
+ | --bg: url('/ | ||
+ | } | ||
+ | | ||
+ | /* page preference is " | ||
+ | @media (prefers-color-scheme: | ||
+ | &: | ||
+ | --color-scheme: | ||
+ | /* any additional dark styles, again */ | ||
+ | } | ||
+ | } | ||
+ | |||
+ | | ||
+ | transition-duration: | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | And this is in my '' | ||
+ | |||
+ | < | ||
+ | |||
+ | |||
+ | /* | ||
+ | * If a color scheme preference was previously stored, | ||
+ | * select the corresponding option in the color scheme preference UI | ||
+ | * unless it is already selected. | ||
+ | */ | ||
+ | function restoreColorSchemePreference() { | ||
+ | const colorScheme = localStorage.getItem(colorSchemeStorageItemName); | ||
+ | |||
+ | if (!colorScheme) { | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | const option = colorSchemeSelectorEl.querySelector(`[value=${colorScheme}]`); | ||
+ | |||
+ | if (!option) { | ||
+ | localStorage.removeItem(colorSchemeStorageItemName); | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | if (option.selected) { | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | option.selected = true; | ||
+ | } | ||
+ | |||
+ | /* | ||
+ | * Store an event target' | ||
+ | */ | ||
+ | function storeColorSchemePreference({ target }) { | ||
+ | const colorScheme = target.querySelector(": | ||
+ | localStorage.setItem(colorSchemeStorageItemName, | ||
+ | } | ||
+ | |||
+ | const colorSchemeStorageItemName = " | ||
+ | |||
+ | const colorSchemeSelectorEl = document.querySelector("# | ||
+ | |||
+ | if (colorSchemeSelectorEl) { | ||
+ | restoreColorSchemePreference(); | ||
+ | |||
+ | colorSchemeSelectorEl.addEventListener(" | ||
+ | } | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | Don't ask me what any of this means LOL I just copy/pasted someone else's code in the places that make it work on my site... | ||