chore: update comments for consistency, improve code readability and structure

This commit is contained in:
radishzzz 2025-03-22 22:54:23 +00:00
parent ca45fed0aa
commit fedf4cee1e
38 changed files with 46 additions and 60 deletions

View file

@ -1,4 +1,4 @@
<img alt="Cover Image" src="https://placehold.co/1920x1080?text=Comming+Soon"/> <img alt="Cover Image" src="https://placehold.co/1920x1080?text=Work+In+Progress"/>
<div align="center"> <div align="center">
<picture> <picture>

View file

@ -1,4 +1,4 @@
<img alt="Cover Image" src="https://placehold.co/1920x1080?text=Comming+Soon"/> <img alt="Cover Image" src="https://placehold.co/1920x1080?text=Work+In+Progress"/>
<div align="center"> <div align="center">
<a title="en" href="README.md"> <a title="en" href="README.md">

View file

@ -16,10 +16,8 @@ const isTag = isTagPage(currentPath)
// Check if there are other languages to switch // Check if there are other languages to switch
const showLanguageSwitcher = moreLocales.length > 0 const showLanguageSwitcher = moreLocales.length > 0
// Check if only the supported language switch list is used // Check if only the supported language switch list is used
const useSupportedLangs = isPost || (isTag && supportedLangs.length > 0) const useSupportedLangs = isPost || (isTag && supportedLangs.length > 0)
// Choose a language switch list according to the page type // Choose a language switch list according to the page type
const nextUrl = useSupportedLangs const nextUrl = useSupportedLangs
? getNextSupportedLangPath(currentPath, supportedLangs) // Switch between supported languages ? getNextSupportedLangPath(currentPath, supportedLangs) // Switch between supported languages
@ -33,7 +31,7 @@ const nextUrl = useSupportedLangs
'lg:(fixed w-14rem top-auto bottom-47 right-[max(5.625rem,calc(50vw-34.375rem))])', 'lg:(fixed w-14rem top-auto bottom-47 right-[max(5.625rem,calc(50vw-34.375rem))])',
]} ]}
> >
<!-- Language switcher --> <!-- Language Switcher -->
{showLanguageSwitcher && ( {showLanguageSwitcher && (
<a <a
href={nextUrl} href={nextUrl}
@ -52,7 +50,7 @@ const nextUrl = useSupportedLangs
</a> </a>
)} )}
<!-- Theme toggle --> <!-- Theme Toggle -->
<button <button
aria-label="Switch light/dark theme" aria-label="Switch light/dark theme"
class="button-theme-toggle aspect-square w-4.2 c-secondary active:scale-90 hover:c-primary" class="button-theme-toggle aspect-square w-4.2 c-secondary active:scale-90 hover:c-primary"
@ -68,7 +66,7 @@ const nextUrl = useSupportedLangs
</button> </button>
</div> </div>
<!-- Theme toggle >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> --> <!-- Theme Toggle Script >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<script is:inline define:vars={{ lightMode, darkMode }}> <script is:inline define:vars={{ lightMode, darkMode }}>
// Update theme // Update theme
function updateTheme() { function updateTheme() {

View file

@ -2,13 +2,11 @@
import { defaultLocale, themeConfig } from '@/config' import { defaultLocale, themeConfig } from '@/config'
import { walineLocaleMap } from '@/i18n/config' import { walineLocaleMap } from '@/i18n/config'
// Theme color configuration
const { const {
light: { primary: lightPrimary, secondary: lightSecondary, background: lightBackground }, light: { primary: lightPrimary, secondary: lightSecondary, background: lightBackground },
dark: { primary: darkPrimary, secondary: darkSecondary, background: darkBackground }, dark: { primary: darkPrimary, secondary: darkSecondary, background: darkBackground },
} = themeConfig.color } = themeConfig.color
// Waline configuration
const { const {
serverURL = '', serverURL = '',
emoji = [], emoji = [],
@ -27,7 +25,7 @@ function getWalineLang(currentPath: string, defaultLocale: string): string {
return walineLocaleMap[lang as keyof typeof walineLocaleMap] return walineLocaleMap[lang as keyof typeof walineLocaleMap]
} }
// Get Waline language and generate configuration // Get Waline language and generate configuration json
const walineLang = getWalineLang(Astro.url.pathname, defaultLocale) const walineLang = getWalineLang(Astro.url.pathname, defaultLocale)
const walineConfigJson = JSON.stringify({ const walineConfigJson = JSON.stringify({
serverURL, serverURL,
@ -71,7 +69,7 @@ initWaline()
document.addEventListener('astro:after-swap', initWaline) document.addEventListener('astro:after-swap', initWaline)
</script> </script>
<!-- Custom css styles >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> --> <!-- Custom CSS Styles >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<style is:global> <style is:global>
#waline .wl-login-info { #waline .wl-login-info {
--at-apply: 'mt-0 mr-3' --at-apply: 'mt-0 mr-3'
@ -177,8 +175,8 @@ document.addEventListener('astro:after-swap', initWaline)
} }
</style> </style>
<!-- Official css variables >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> --> <!-- Official CSS Variables >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<!-- Docs: https://waline.js.org/reference/client/style.html --> <!-- https://waline.js.org/reference/client/style.html -->
<style <style
define:vars={{ define:vars={{
lightPrimary, lightPrimary,

View file

@ -23,6 +23,7 @@ const enableComments = themeConfig.comment?.enabled ?? false
const walineURL = themeConfig.comment?.waline?.serverURL || '' const walineURL = themeConfig.comment?.waline?.serverURL || ''
const showWaline = enableComments && walineURL.trim() !== '' const showWaline = enableComments && walineURL.trim() !== ''
--- ---
<!-- {showDisqus && <Disqus />} --> <!-- {showDisqus && <Disqus />} -->
<!-- {showGiscus && <Giscus />} --> <!-- {showGiscus && <Giscus />} -->
<!-- {showTwikoo && <Twikoo />} --> <!-- {showTwikoo && <Twikoo />} -->

View file

@ -10,7 +10,7 @@ const year = Number(startYear) === currentYear
? startYear ? startYear
: `${startYear}-${currentYear}` : `${startYear}-${currentYear}`
// i18n rss path // i18n RSS Path
const currentLang = getLangFromPath(Astro.url.pathname) const currentLang = getLangFromPath(Astro.url.pathname)
const links = socialLinks.map((link) => { const links = socialLinks.map((link) => {
if (link.name === 'RSS') { if (link.name === 'RSS') {

View file

@ -41,7 +41,7 @@ const SubtitleTag = isPost ? 'div' : 'h2'
'font-bold font-title', 'font-bold font-title',
]} ]}
> >
<!-- Fix text cropping issues during view transition on ios by adding a div tag --> <!-- Fix text cropping issues during view transition on iOS by adding a div tag -->
<div <div
class="box-content inline-block pr-1" class="box-content inline-block pr-1"
transition:name={`site-title-${currentLang}`} transition:name={`site-title-${currentLang}`}

View file

@ -26,6 +26,7 @@ function getPostPath(post: Post) {
return lang && lang !== defaultLocale ? `/${lang}/posts/${postPath}/` : `/posts/${postPath}/` return lang && lang !== defaultLocale ? `/${lang}/posts/${postPath}/` : `/posts/${postPath}/`
} }
--- ---
<ul> <ul>
{posts.map(post => ( {posts.map(post => (
<li <li

View file

@ -14,6 +14,7 @@
</svg> </svg>
</button> </button>
<!-- Go Back Script >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -->
<script> <script>
function setupBackButton() { function setupBackButton() {
document.getElementById('back-button')?.addEventListener('click', () => { document.getElementById('back-button')?.addEventListener('click', () => {
@ -21,6 +22,7 @@ function setupBackButton() {
window.history.back() window.history.back()
} }
else { else {
// Click site title link to trigger view transition when no history
const titleLink = document.getElementById('site-title-link') as HTMLAnchorElement const titleLink = document.getElementById('site-title-link') as HTMLAnchorElement
if (titleLink) { if (titleLink) {
titleLink.click() titleLink.click()

View file

@ -16,7 +16,7 @@ export const themeConfig: ThemeConfig = {
// site url // site url
url: 'https://retypeset.radishzz.cc', url: 'https://retypeset.radishzz.cc',
// favicon url // favicon url
// recommended formats: SVG, PNG and ICO // recommended formats: svg, png or ico
favicon: '/icon/favicon.svg', // or https://example.com/favicon.svg favicon: '/icon/favicon.svg', // or https://example.com/favicon.svg
}, },
// SITE INFORMATION >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END // SITE INFORMATION >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END

View file

@ -1,7 +1,7 @@
import { allLocales } from '@/config' import { allLocales } from '@/config'
import { defineCollection, z } from 'astro:content' import { defineCollection, z } from 'astro:content'
// Posts collection // Posts Collection
const postsCollection = defineCollection({ const postsCollection = defineCollection({
schema: z.object({ schema: z.object({
// required // required
@ -23,7 +23,7 @@ const postsCollection = defineCollection({
}), }),
}) })
// About page // About Page
const aboutCollection = defineCollection({ const aboutCollection = defineCollection({
schema: z.object({ schema: z.object({
lang: z.enum(['', ...allLocales]).optional().default(''), lang: z.enum(['', ...allLocales]).optional().default(''),

View file

@ -118,32 +118,16 @@ we can use 3 backticks ``` in new line and write snippet and close with 3 backti
### Output ### Output
```html ```html
--- <!doctype html>
// Your component script here! <html lang="en">
import Banner from '../components/Banner.astro'; <head>
import ReactPokemonComponent from '../components/ReactPokemonComponent.jsx'; <meta charset="utf-8" />
const myFavoritePokemon = [/* ... */]; <title>Example HTML5 Document</title>
const { title } = Astro.props; </head>
--- <body>
<!-- HTML comments supported! --> <p>Test</p>
{/* JS comment syntax is also valid! */} </body>
</html>
<Banner />
<h1>Hello, world!</h1>
<!-- Use props and other variables from the component script: -->
<p>{title}</p>
<!-- Include other UI framework components with a `client:` directive to hydrate: -->
<ReactPokemonComponent client:visible />
<!-- Mix HTML with JavaScript expressions, similar to JSX: -->
<ul>
{myFavoritePokemon.map((data) => <li>{data.name}</li>)}
</ul>
<!-- Use a template directive to build class names from multiple strings or even objects! -->
<p class:list={["add", "dynamic", {classNames: true}]} />
``` ```
## List Types ## List Types

View file

@ -9,7 +9,7 @@ export const langMap: Record<string, string[]> = {
} }
// Waline Language Map // Waline Language Map
// docs: https://waline.js.org/guide/i18n.html // https://waline.js.org/guide/i18n.html
export const walineLocaleMap: Record<string, string> = { export const walineLocaleMap: Record<string, string> = {
'zh': 'zh-CN', 'zh': 'zh-CN',
'zh-tw': 'zh-TW', 'zh-tw': 'zh-TW',

View file

@ -3,7 +3,7 @@ import Layout from '@/layouts/Layout.astro'
--- ---
<Layout> <Layout>
<!-- Decorative line --> <!-- Decorative Line -->
<div class="uno-decorative-line"></div> <div class="uno-decorative-line"></div>
<!-- 404 --> <!-- 404 -->
<h1 class="mt-10 text-8 font-title">404</h1> <h1 class="mt-10 text-8 font-title">404</h1>

View file

@ -38,9 +38,9 @@ const { Content } = aboutEntry ? await aboutEntry.render() : { Content: null }
--- ---
<Layout> <Layout>
<!-- Decorative line --> <!-- Decorative Line -->
<div class="uno-decorative-line"></div> <div class="uno-decorative-line"></div>
<!-- About page content --> <!-- About Page Content -->
<div class="heti"> <div class="heti">
{Content && <Content />} {Content && <Content />}
</div> </div>

View file

@ -42,6 +42,7 @@ const postsByYear = await getPostsByYear(lang)
<PostList posts={pinnedPosts} lang={lang} /> <PostList posts={pinnedPosts} lang={lang} />
</section> </section>
)} )}
<!-- Regular Posts --> <!-- Regular Posts -->
{[...postsByYear.entries()].map(([_year, posts]) => ( {[...postsByYear.entries()].map(([_year, posts]) => (
<section class="mb-7.5"> <section class="mb-7.5">

View file

@ -2,7 +2,7 @@
import type { CollectionEntry } from 'astro:content' import type { CollectionEntry } from 'astro:content'
import Comments from '@/components/Comments/index.astro' import Comments from '@/components/Comments/index.astro'
import PostDate from '@/components/PostDate.astro' import PostDate from '@/components/PostDate.astro'
import BackHome from '@/components/Widgets/BackHome.astro' import GoBack from '@/components/Widgets/GoBack.astro'
import { allLocales, defaultLocale, moreLocales } from '@/config' import { allLocales, defaultLocale, moreLocales } from '@/config'
import { getTagPath } from '@/i18n/path' import { getTagPath } from '@/i18n/path'
import Layout from '@/layouts/Layout.astro' import Layout from '@/layouts/Layout.astro'
@ -107,8 +107,8 @@ const { Content, remarkPluginFrontmatter } = await post.render()
> >
<article class="heti mb-12.6"> <article class="heti mb-12.6">
<div class="relative"> <div class="relative">
<!-- Desktop back home button --> <!-- Go Back Button On Desktop -->
<BackHome /> <GoBack />
<!-- Title --> <!-- Title -->
<h1 class="post-title"> <h1 class="post-title">
<span <span

View file

@ -34,9 +34,9 @@ const allTags = await getAllTags(lang)
--- ---
<Layout> <Layout>
<!-- Decorative line --> <!-- Decorative Line -->
<div class="uno-decorative-line"></div> <div class="uno-decorative-line"></div>
<!-- Tags list --> <!-- Tags List -->
<div class="uno-tags-wrapper"> <div class="uno-tags-wrapper">
{allTags.map(tag => ( {allTags.map(tag => (
<a <a

View file

@ -53,9 +53,9 @@ const supportedLangs = tagSupportedLangs.filter(Boolean) as string[]
--- ---
<Layout supportedLangs={supportedLangs}> <Layout supportedLangs={supportedLangs}>
<!-- Decorative line --> <!-- Decorative Line -->
<div class="uno-decorative-line"></div> <div class="uno-decorative-line"></div>
<!-- Tags list --> <!-- Tags List -->
<div class="uno-tags-wrapper"> <div class="uno-tags-wrapper">
{allTags.map(tagName => ( {allTags.map(tagName => (
<a <a
@ -71,7 +71,7 @@ const supportedLangs = tagSupportedLangs.filter(Boolean) as string[]
))} ))}
</div> </div>
<!-- Posts list --> <!-- Posts List -->
<div class="mt-10.5"> <div class="mt-10.5">
<PostList posts={posts} lang={lang} /> <PostList posts={posts} lang={lang} />
</div> </div>

View file

@ -26,7 +26,7 @@ html.dark .astro-code span {
background-color: var(--shiki-dark-bg) !important; background-color: var(--shiki-dark-bg) !important;
} }
/* Horizontal reveal animation during theme switching */ /* View Transition with Theme Toggle >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
::view-transition-new(theme-transition) { ::view-transition-new(theme-transition) {
animation: reveal 1s cubic-bezier(0.4, 0, 0.2, 1); animation: reveal 1s cubic-bezier(0.4, 0, 0.2, 1);
clip-path: inset(0 0 0 0); clip-path: inset(0 0 0 0);
@ -64,7 +64,8 @@ html[data-theme-transition] [data-disable-transition-on-theme] {
} }
} }
/* Snell Roundhand static font */ /* Import Custom Fonts >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> */
/* Snell Roundhand Static Font */
@font-face { @font-face {
font-family: "Snell-Bold"; font-family: "Snell-Bold";
src: url("/font/Snell-Bold.woff2") format("woff2"); src: url("/font/Snell-Bold.woff2") format("woff2");
@ -79,7 +80,7 @@ html[data-theme-transition] [data-disable-transition-on-theme] {
unicode-range: U+0030-0039,U+0041-005A,U+0061-007A,U+00C1,U+00C9,U+00CD,U+00D3,U+00DA,U+00DC,U+00D1,U+00E1,U+00E9,U+00ED,U+00F3,U+00FA,U+00FC,U+00F1,U+0410-044F,U+0401,U+0451,U+0021-002F,U+003A-0040,U+00A9; unicode-range: U+0030-0039,U+0041-005A,U+0061-007A,U+00C1,U+00C9,U+00CD,U+00D3,U+00DA,U+00DC,U+00D1,U+00E1,U+00E9,U+00ED,U+00F3,U+00FA,U+00FC,U+00F1,U+0410-044F,U+0401,U+0451,U+0021-002F,U+003A-0040,U+00A9;
} }
/* STIXTwoText variable font */ /* STIXTwoText Variable Font */
@font-face { @font-face {
font-family: "STIX"; font-family: "STIX";
src: url("/font/STIX.woff2") format("woff2-variations"); src: url("/font/STIX.woff2") format("woff2-variations");
@ -96,7 +97,7 @@ html[data-theme-transition] [data-disable-transition-on-theme] {
unicode-range: U+0030-0039,U+0041-005A,U+0061-007A,U+00C1,U+00C9,U+00CD,U+00D3,U+00DA,U+00DC,U+00D1,U+00E1,U+00E9,U+00ED,U+00F3,U+00FA,U+00FC,U+00F1,U+0410-044F,U+0401,U+0451,U+0021-002F,U+003A-0040,U+00A9; unicode-range: U+0030-0039,U+0041-005A,U+0061-007A,U+00C1,U+00C9,U+00CD,U+00D3,U+00DA,U+00DC,U+00D1,U+00E1,U+00E9,U+00ED,U+00F3,U+00FA,U+00FC,U+00F1,U+0410-044F,U+0401,U+0451,U+0021-002F,U+003A-0040,U+00A9;
} }
/* Minimal subset of EarlySummerSerif variable font for ui */ /* Minimal Subset of EarlySummerSerif Variable Font */
@font-face { @font-face {
font-family: "EarlySummer-Subset"; font-family: "EarlySummer-Subset";
src: url("/font/EarlySummer-Subset.woff2") format("woff2-variations"); src: url("/font/EarlySummer-Subset.woff2") format("woff2-variations");