-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from AVGVSTVS96/darkMode
Add dark mode, update toc script, add sample blog posts, update styling, update Tailwind config
- Loading branch information
Showing
21 changed files
with
351 additions
and
97 deletions.
There are no files selected for viewing
This file contains 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,15 +1,22 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import tailwind from '@astrojs/tailwind'; | ||
|
||
import remarkSectionize from 'remark-sectionize'; | ||
import expressiveCode from 'astro-expressive-code'; | ||
|
||
/** @type {import('astro-expressive-code').AstroExpressiveCodeOptions} */ | ||
const astroExpressiveCodeOptions = { | ||
themes: ['material-theme-ocean'], | ||
themes: ['material-theme-ocean', 'material-theme-palenight'], | ||
}; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
integrations: [tailwind(), expressiveCode(astroExpressiveCodeOptions)], | ||
markdown: { | ||
remarkPlugins: [remarkSectionize], | ||
}, | ||
integrations: [ | ||
tailwind({ | ||
applyBaseStyles: false, | ||
}), | ||
expressiveCode(astroExpressiveCodeOptions), | ||
], | ||
}); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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,24 +1,25 @@ | ||
--- | ||
const allPosts = await Astro.glob('../pages/posts/*.md'); | ||
const { styles = '' } = Astro.props; | ||
const { class: className } = Astro.props; | ||
let displayPosts = Astro.props.postCount | ||
? allPosts.slice(-Astro.props.postCount) | ||
: allPosts; | ||
--- | ||
|
||
<ul class={`list-none pl-0 ${styles}`}> | ||
<ul class={`list-none pl-0 ${className}`}> | ||
{ | ||
displayPosts.map((post) => ( | ||
<li class="flex flex-row-reverse justify-between border-b-[0.5px] border-slate-300/25 p-2.5"> | ||
<li class="flex flex-row-reverse justify-between border-b-[0.5px] dark:border-slate-400/20 p-2.5"> | ||
<div> | ||
<a | ||
href={post.url} | ||
class="text-xl font-[600] text-sky-300/80 decoration-1 decoration-sky-300/55 underline-offset-[5px] hover:underline"> | ||
class="text-xl font-[600] text-slate-700 dark:text-sky-300/80 decoration-1 dark:decoration-sky-300/55 underline-offset-[5px] hover:underline"> | ||
{post.frontmatter.title} | ||
</a> | ||
</div> | ||
<div class="text-slate-200/60">{post.frontmatter.pubDate}</div> | ||
<div class="text-slate-600/75 dark:text-slate-200/60">{post.frontmatter.pubDate}</div> | ||
</li> | ||
)) | ||
} | ||
</ul> | ||
|
This file contains 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 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 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 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 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 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 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 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,57 @@ | ||
--- | ||
--- | ||
|
||
<button id="themeToggle" class="mr-4"> | ||
<svg width="26px" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"> | ||
<path | ||
class="sun" | ||
fill-rule="evenodd" | ||
d="M12 17.5a5.5 5.5 0 1 0 0-11 5.5 5.5 0 0 0 0 11zm0 1.5a7 7 0 1 0 0-14 7 7 0 0 0 0 14zm12-7a.8.8 0 0 1-.8.8h-2.4a.8.8 0 0 1 0-1.6h2.4a.8.8 0 0 1 .8.8zM4 12a.8.8 0 0 1-.8.8H.8a.8.8 0 0 1 0-1.6h2.5a.8.8 0 0 1 .8.8zm16.5-8.5a.8.8 0 0 1 0 1l-1.8 1.8a.8.8 0 0 1-1-1l1.7-1.8a.8.8 0 0 1 1 0zM6.3 17.7a.8.8 0 0 1 0 1l-1.7 1.8a.8.8 0 1 1-1-1l1.7-1.8a.8.8 0 0 1 1 0zM12 0a.8.8 0 0 1 .8.8v2.5a.8.8 0 0 1-1.6 0V.8A.8.8 0 0 1 12 0zm0 20a.8.8 0 0 1 .8.8v2.4a.8.8 0 0 1-1.6 0v-2.4a.8.8 0 0 1 .8-.8zM3.5 3.5a.8.8 0 0 1 1 0l1.8 1.8a.8.8 0 1 1-1 1L3.5 4.6a.8.8 0 0 1 0-1zm14.2 14.2a.8.8 0 0 1 1 0l1.8 1.7a.8.8 0 0 1-1 1l-1.8-1.7a.8.8 0 0 1 0-1z" | ||
></path> | ||
<path | ||
class="moon" | ||
fill-rule="evenodd" | ||
d="M16.5 6A10.5 10.5 0 0 1 4.7 16.4 8.5 8.5 0 1 0 16.4 4.7l.1 1.3zm-1.7-2a9 9 0 0 1 .2 2 9 9 0 0 1-11 8.8 9.4 9.4 0 0 1-.8-.3c-.4 0-.8.3-.7.7a10 10 0 0 0 .3.8 10 10 0 0 0 9.2 6 10 10 0 0 0 4-19.2 9.7 9.7 0 0 0-.9-.3c-.3-.1-.7.3-.6.7a9 9 0 0 1 .3.8z" | ||
></path> | ||
</svg> | ||
</button> | ||
|
||
<style> | ||
#themeToggle { | ||
border: 0; | ||
background: none; | ||
} | ||
.sun { | ||
fill: rgb(250, 250, 250, 0.7); | ||
} | ||
.moon { | ||
fill: transparent; | ||
} | ||
|
||
:global(.dark) .sun { | ||
fill: transparent; | ||
} | ||
:global(.dark) .moon { | ||
fill: rgb(250, 250, 250, 0.7); | ||
} | ||
</style> | ||
|
||
<script is:inline> | ||
const theme = localStorage.getItem('theme') || 'dark'; | ||
const element = document.documentElement; | ||
|
||
element.className = theme; | ||
element.setAttribute('data-theme', theme === 'dark' ? 'material-theme-ocean' : 'material-theme-palenight'); | ||
|
||
const handleToggleClick = () => { | ||
const newTheme = element.className === 'dark' ? 'light' : 'dark'; | ||
|
||
element.className = newTheme; | ||
element.setAttribute('data-theme', newTheme === 'dark' ? 'material-theme-ocean' : 'material-theme-palenight'); | ||
|
||
localStorage.setItem('theme', newTheme); | ||
}; | ||
|
||
document.getElementById('themeToggle').addEventListener('click', handleToggleClick); | ||
</script> |
Oops, something went wrong.