mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-15 11:12:54 +02:00
feat: adjust layout spacing and add comment toggle configuration
This commit is contained in:
parent
51ae238192
commit
783fb958d5
5 changed files with 16 additions and 12 deletions
|
@ -5,21 +5,23 @@
|
|||
import Waline from '@/components/Comments/Waline.astro'
|
||||
import { themeConfig } from '@/config'
|
||||
|
||||
const enableComments = themeConfig.comment?.enabled ?? false
|
||||
|
||||
// Disqus
|
||||
// const disqusShortname = themeConfig.comment?.disqus?.shortname || ''
|
||||
// const showDisqus = disqusShortname.trim() !== ''
|
||||
// const showDisqus = enableComments && disqusShortname.trim() !== ''
|
||||
|
||||
// Giscus
|
||||
// const giscusRepo = themeConfig.comment?.giscus?.repo || ''
|
||||
// const showGiscus = giscusRepo.trim() !== ''
|
||||
// const showGiscus = enableComments && giscusRepo.trim() !== ''
|
||||
|
||||
// Twikoo
|
||||
// const twikooEnvId = themeConfig.comment?.twikoo?.envId || ''
|
||||
// const showTwikoo = twikooEnvId.trim() !== ''
|
||||
// const showTwikoo = enableComments && twikooEnvId.trim() !== ''
|
||||
|
||||
// Waline
|
||||
const walineURL = themeConfig.comment?.waline?.serverURL || ''
|
||||
const showWaline = walineURL.trim() !== ''
|
||||
const showWaline = enableComments && walineURL.trim() !== ''
|
||||
---
|
||||
<!-- {showDisqus && <Disqus />} -->
|
||||
<!-- {showGiscus && <Giscus />} -->
|
||||
|
|
|
@ -68,6 +68,8 @@ export const themeConfig: ThemeConfig = {
|
|||
|
||||
// COMMENT SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START
|
||||
comment: {
|
||||
// enable comment system
|
||||
enabled: true, // true, false
|
||||
// waline comment system
|
||||
// https://waline.js.org/en/
|
||||
waline: {
|
||||
|
|
|
@ -22,6 +22,9 @@ const { getLocalizedPath, isPost } = getPageInfo(Astro.url.pathname)
|
|||
const localizedHome = getLocalizedPath('/')
|
||||
const { light: { background: lightMode }, dark: { background: darkMode } } = themeConfig.color
|
||||
const fontStyle = themeConfig.global.fontStyle === 'serif' ? 'font-serif' : 'font-sans'
|
||||
const MarginBottom = isPost && themeConfig.comment?.enabled
|
||||
? 'mb-10' // Post page with comment system
|
||||
: 'mb-12' // Other pages
|
||||
---
|
||||
|
||||
<html
|
||||
|
@ -39,7 +42,7 @@ const fontStyle = themeConfig.global.fontStyle === 'serif' ? 'font-serif' : 'fon
|
|||
>
|
||||
<Header />
|
||||
<Navbar />
|
||||
<main class="mb-10.5">
|
||||
<main class={MarginBottom}>
|
||||
<slot />
|
||||
</main>
|
||||
<Button supportedLangs={supportedLangs} />
|
||||
|
@ -55,7 +58,6 @@ const fontStyle = themeConfig.global.fontStyle === 'serif' ? 'font-serif' : 'fon
|
|||
|
||||
// Get current theme
|
||||
const isDark = document.documentElement.classList.contains('dark')
|
||||
|
||||
// Update meta theme color
|
||||
const metaThemeColor = document.querySelector('meta[name="theme-color"]')
|
||||
if (metaThemeColor) {
|
||||
|
@ -71,7 +73,6 @@ const fontStyle = themeConfig.global.fontStyle === 'serif' ? 'font-serif' : 'fon
|
|||
function setupThemeToggle() {
|
||||
// Locate theme toggle button
|
||||
const themeToggleButtons = document.querySelectorAll('.button-theme-toggle')
|
||||
|
||||
// Add click listener to each button
|
||||
themeToggleButtons.forEach((button) => {
|
||||
button.addEventListener('click', () => {
|
||||
|
@ -87,7 +88,6 @@ const fontStyle = themeConfig.global.fontStyle === 'serif' ? 'font-serif' : 'fon
|
|||
|
||||
// If browser supports View Transitions API, use it to update theme
|
||||
const themeTransition = document.startViewTransition(updateTheme)
|
||||
|
||||
// Remove markers after animation
|
||||
themeTransition.finished.then(() => {
|
||||
document.documentElement.style.removeProperty('view-transition-name')
|
||||
|
@ -121,6 +121,5 @@ const fontStyle = themeConfig.global.fontStyle === 'serif' ? 'font-serif' : 'fon
|
|||
setupBackButton()
|
||||
document.addEventListener('astro:after-swap', setupBackButton)
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -37,14 +37,14 @@ const postsByYear = await getPostsByYear(lang)
|
|||
<Layout>
|
||||
<!-- Pinned Posts -->
|
||||
{pinnedPosts.length > 0 && (
|
||||
<section class="mb-7.5 lg:mb-10">
|
||||
<section class="mb-7.5">
|
||||
<div class="uno-decorative-line"></div>
|
||||
<PostList posts={pinnedPosts} lang={lang} />
|
||||
</section>
|
||||
)}
|
||||
<!-- Regular Posts -->
|
||||
{[...postsByYear.entries()].map(([_year, posts]) => (
|
||||
<section class="mb-7.5 lg:mb-10">
|
||||
<section class="mb-7.5">
|
||||
<div class="uno-decorative-line"></div>
|
||||
<PostList posts={posts} lang={lang} />
|
||||
</section>
|
||||
|
|
3
src/types/index.d.ts
vendored
3
src/types/index.d.ts
vendored
|
@ -36,7 +36,8 @@ export interface ThemeConfig {
|
|||
titleGap: 1 | 2 | 3
|
||||
}
|
||||
|
||||
comment?: {
|
||||
comment: {
|
||||
enabled: boolean
|
||||
waline?: {
|
||||
serverURL?: string
|
||||
emoji?: string[]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue