mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-16 19:51:07 +02:00
refactor: clean up configuration and components, optimize implementation details
- Remove unused navigation bar and social link configurations - Update Footer component, simplify code - Refactor PostList and PostTime components, improve code readability - Adjust Waline comment component styles - Streamline content config and reading time plugin - Update theme guide document titles and tags
This commit is contained in:
parent
8ac9b865f5
commit
c23a54ae83
10 changed files with 33 additions and 126 deletions
22
pnpm-lock.yaml
generated
22
pnpm-lock.yaml
generated
|
@ -268,13 +268,13 @@ packages:
|
|||
resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@babel/parser@7.26.9':
|
||||
resolution: {integrity: sha512-81NWa1njQblgZbQHxWHpxxCzNsa3ZwvFqpUg7P+NNUU6f3UU2jBEg4OlF/J6rl8+PQGh1q6/zWScd001YwcA5A==}
|
||||
'@babel/parser@7.26.10':
|
||||
resolution: {integrity: sha512-6aQR2zGE/QFi8JpDLjUZEPYOs7+mhKXm86VaKFiLP35JQwQb6bwUE+XbvkH0EptsYhbNBSUGaUBLKqxH1xSgsA==}
|
||||
engines: {node: '>=6.0.0'}
|
||||
hasBin: true
|
||||
|
||||
'@babel/types@7.26.9':
|
||||
resolution: {integrity: sha512-Y3IR1cRnOxOCDvMmNiym7XpXQ93iGDDPHx+Zj+NM+rg0fBaShfQLkg+hKPaZCEvg5N/LeCo4+Rj/i3FuJsIQaw==}
|
||||
'@babel/types@7.26.10':
|
||||
resolution: {integrity: sha512-emqcG3vHrpxUKTrxcblR36dcrcoRDvKmnL/dCL6ZsHaShW80qxCAcNhzQZrpeM765VzEos+xOi4s+r4IXzTwdQ==}
|
||||
engines: {node: '>=6.9.0'}
|
||||
|
||||
'@clack/core@0.4.1':
|
||||
|
@ -3941,11 +3941,11 @@ snapshots:
|
|||
|
||||
'@babel/helper-validator-identifier@7.25.9': {}
|
||||
|
||||
'@babel/parser@7.26.9':
|
||||
'@babel/parser@7.26.10':
|
||||
dependencies:
|
||||
'@babel/types': 7.26.9
|
||||
'@babel/types': 7.26.10
|
||||
|
||||
'@babel/types@7.26.9':
|
||||
'@babel/types@7.26.10':
|
||||
dependencies:
|
||||
'@babel/helper-string-parser': 7.25.9
|
||||
'@babel/helper-validator-identifier': 7.25.9
|
||||
|
@ -4841,7 +4841,7 @@ snapshots:
|
|||
|
||||
'@vue/compiler-core@3.5.13':
|
||||
dependencies:
|
||||
'@babel/parser': 7.26.9
|
||||
'@babel/parser': 7.26.10
|
||||
'@vue/shared': 3.5.13
|
||||
entities: 4.5.0
|
||||
estree-walker: 2.0.2
|
||||
|
@ -4854,7 +4854,7 @@ snapshots:
|
|||
|
||||
'@vue/compiler-sfc@3.5.13':
|
||||
dependencies:
|
||||
'@babel/parser': 7.26.9
|
||||
'@babel/parser': 7.26.10
|
||||
'@vue/compiler-core': 3.5.13
|
||||
'@vue/compiler-dom': 3.5.13
|
||||
'@vue/compiler-ssr': 3.5.13
|
||||
|
@ -6403,8 +6403,8 @@ snapshots:
|
|||
|
||||
magicast@0.3.5:
|
||||
dependencies:
|
||||
'@babel/parser': 7.26.9
|
||||
'@babel/types': 7.26.9
|
||||
'@babel/parser': 7.26.10
|
||||
'@babel/types': 7.26.10
|
||||
source-map-js: 1.2.1
|
||||
|
||||
markdown-extensions@2.0.0: {}
|
||||
|
|
|
@ -146,7 +146,7 @@ document.addEventListener('astro:after-swap', initWaline)
|
|||
}
|
||||
|
||||
#waline .wl-content p {
|
||||
--at-apply: 'leading-6';
|
||||
--at-apply: 'leading-6 text-3.5';
|
||||
}
|
||||
|
||||
#waline .wl-time {
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
---
|
||||
import { themeConfig } from '@/config'
|
||||
import { isPostPage } from '@/utils/path'
|
||||
|
||||
interface Props {
|
||||
date: Date
|
||||
updatedDate?: Date
|
||||
minutes?: number
|
||||
}
|
||||
|
||||
const { date, updatedDate, minutes } = Astro.props
|
||||
const format = themeConfig.global.dateFormat
|
||||
const currentPath = Astro.url.pathname
|
||||
const isPost = isPostPage(currentPath)
|
||||
const updatedTimeMarginClass = isPost ? 'ml-1.75' : 'ml-1.5'
|
||||
const readingTimeMarginClass = isPost ? 'ml-1.75' : 'ml-1.5'
|
||||
|
||||
function formatDate(date: Date, format: 'YYYY-MM-DD' | 'MM-DD-YYYY' | 'DD-MM-YYYY' | 'MONTH DAY YYYY' | 'DAY MONTH YYYY') {
|
||||
const options: Intl.DateTimeFormatOptions = {
|
||||
year: 'numeric',
|
||||
month: format === 'MONTH DAY YYYY' || format === 'DAY MONTH YYYY' ? 'short' : '2-digit',
|
||||
day: format === 'MONTH DAY YYYY' || format === 'DAY MONTH YYYY' ? 'numeric' : '2-digit',
|
||||
}
|
||||
|
||||
switch (format) {
|
||||
// ISO format: 2024-03-04
|
||||
case 'YYYY-MM-DD':
|
||||
return date.toISOString().split('T')[0]
|
||||
|
||||
// US date format: 03-04-2024
|
||||
case 'MM-DD-YYYY':
|
||||
return date.toLocaleDateString('en-US', options).replace(/\//g, '-')
|
||||
|
||||
// European date format: 04-03-2024
|
||||
case 'DD-MM-YYYY':
|
||||
return date.toLocaleDateString('en-GB', options).replace(/\//g, '-')
|
||||
|
||||
// US month text format: Mar 4 2024
|
||||
case 'MONTH DAY YYYY':
|
||||
return date.toLocaleDateString('en-US', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
}).replace(',', '')
|
||||
|
||||
// British month text format: 4 Mar 2024
|
||||
case 'DAY MONTH YYYY':
|
||||
return date.toLocaleDateString('en-GB', {
|
||||
year: 'numeric',
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
}).replace(',', '')
|
||||
|
||||
// Default to ISO format
|
||||
default:
|
||||
return date.toISOString().split('T')[0]
|
||||
}
|
||||
}
|
||||
---
|
||||
|
||||
<!-- published time -->
|
||||
<time datetime={date.toISOString().split('T')[0]}>
|
||||
{formatDate(date, format)}
|
||||
</time>
|
||||
|
||||
<!-- updated time -->
|
||||
{updatedDate && (
|
||||
<time datetime={updatedDate.toISOString().split('T')[0]} class={updatedTimeMarginClass}>
|
||||
updated {formatDate(updatedDate, format)}
|
||||
</time>
|
||||
)}
|
||||
|
||||
<!-- reading time -->
|
||||
{minutes !== undefined && (
|
||||
<span class={readingTimeMarginClass}>
|
||||
{minutes} min
|
||||
</span>
|
||||
)}
|
|
@ -6,7 +6,6 @@ interface Props {
|
|||
}
|
||||
|
||||
const { class: className } = Astro.props
|
||||
|
||||
const { author } = themeConfig.site
|
||||
const { links, startYear } = themeConfig.footer
|
||||
|
||||
|
|
|
@ -6,28 +6,29 @@ interface Post {
|
|||
title: string
|
||||
abbrlink?: string
|
||||
published: Date
|
||||
lang?: string
|
||||
}
|
||||
// URL path automatically generated by Astro based on the filename
|
||||
slug?: string
|
||||
// Optional for robustness in case render() fails or plugin isn't applied
|
||||
remarkPluginFrontmatter?: {
|
||||
minutes?: number
|
||||
}
|
||||
}
|
||||
|
||||
// Receive posts parameter passed from outside
|
||||
const { posts, lang: pageLang } = Astro.props
|
||||
// Get post list and page language parameter from props
|
||||
const { posts, lang } = Astro.props
|
||||
|
||||
// Declare the type of props
|
||||
export interface Props {
|
||||
posts: Post[]
|
||||
lang?: string
|
||||
}
|
||||
|
||||
// 构建正确的链接路径
|
||||
function getPostUrl(post: Post) {
|
||||
// Get multilingual post URL path
|
||||
function getPostPath(post: Post) {
|
||||
// If abbrlink is set, it will be used instead of slug
|
||||
const postPath = post.data.abbrlink || post.slug
|
||||
// 如果是在语言文件夹下的页面,添加语言前缀
|
||||
return pageLang ? `/${pageLang}/posts/${postPath}/` : `/posts/${postPath}/`
|
||||
// Add language prefix to URL if current page is in a language subdirectory
|
||||
return lang ? `/${lang}/posts/${postPath}/` : `/posts/${postPath}/`
|
||||
}
|
||||
---
|
||||
<ul>
|
||||
|
@ -37,7 +38,7 @@ function getPostUrl(post: Post) {
|
|||
{/* post title */}
|
||||
<a
|
||||
class="hover:c-primary"
|
||||
href={getPostUrl(post)}
|
||||
href={getPostPath(post)}
|
||||
transition:name={`post-${post.data.abbrlink || post.slug}`}
|
||||
data-disable-transition-on-theme
|
||||
>
|
||||
|
|
|
@ -12,8 +12,7 @@ const { date, updatedDate, minutes } = Astro.props
|
|||
const format = themeConfig.global.dateFormat
|
||||
const currentPath = Astro.url.pathname
|
||||
const isPost = isPostPage(currentPath)
|
||||
const updatedTimeMarginClass = isPost ? 'ml-1.75' : 'ml-1.5'
|
||||
const readingTimeMarginClass = isPost ? 'ml-1.75' : 'ml-1.5'
|
||||
const timeSpacingClass = isPost ? 'ml-1.75' : 'ml-1.5'
|
||||
|
||||
function formatDate(date: Date, format: 'YYYY-MM-DD' | 'MM-DD-YYYY' | 'DD-MM-YYYY' | 'MONTH DAY YYYY' | 'DAY MONTH YYYY') {
|
||||
const options: Intl.DateTimeFormatOptions = {
|
||||
|
@ -65,14 +64,14 @@ function formatDate(date: Date, format: 'YYYY-MM-DD' | 'MM-DD-YYYY' | 'DD-MM-YYY
|
|||
|
||||
<!-- updated time -->
|
||||
{updatedDate && (
|
||||
<time datetime={updatedDate.toISOString().split('T')[0]} class={updatedTimeMarginClass}>
|
||||
<time datetime={updatedDate.toISOString().split('T')[0]} class={timeSpacingClass}>
|
||||
updated {formatDate(updatedDate, format)}
|
||||
</time>
|
||||
)}
|
||||
|
||||
<!-- reading time -->
|
||||
{minutes !== undefined && (
|
||||
<span class={readingTimeMarginClass}>
|
||||
<span class={timeSpacingClass}>
|
||||
{minutes} min
|
||||
</span>
|
||||
)}
|
||||
|
|
|
@ -114,17 +114,6 @@ export const themeConfig: ThemeConfig = {
|
|||
},
|
||||
// SEO SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END
|
||||
|
||||
// NAVBAR SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START
|
||||
// navbar: {
|
||||
// linkA: {
|
||||
// // link name
|
||||
// name: 'RSS',
|
||||
// // link url
|
||||
// url: '/rss.xml', // rss.xml or atom.xml
|
||||
// },
|
||||
// },
|
||||
// NAVBAR SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END
|
||||
|
||||
// FOOTER SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> START
|
||||
footer: {
|
||||
// social links
|
||||
|
@ -138,11 +127,11 @@ export const themeConfig: ThemeConfig = {
|
|||
url: 'https://github.com/radishzzz/astro-theme-retypeset',
|
||||
},
|
||||
{
|
||||
name: 'Views',
|
||||
url: 'https://views.radishzz.cc/share/uoGMvehDKafqkMC3/retypeset.radishzz.cc',
|
||||
name: 'Twitter',
|
||||
url: 'https://x.com/astrodotbuild',
|
||||
},
|
||||
// {
|
||||
// name: 'Mail',
|
||||
// name: 'Email',
|
||||
// url: 'https://example@gmail.com',
|
||||
// }
|
||||
],
|
||||
|
@ -162,9 +151,9 @@ export const themeConfig: ThemeConfig = {
|
|||
imageHostURL: 'https://image.radishzz.cc',
|
||||
// If you proxy analytics js to the custom domain, you can fill in below.
|
||||
// See https://gist.github.com/xiaopc/0602f06ca465d76bd9efd3dda9393738
|
||||
customGoogleAnalyticsJS: '', // https://custom.example.com/whatever.js
|
||||
customGoogleAnalyticsJS: '',
|
||||
// see https://github.com/umami-software/umami/discussions/1026
|
||||
customUmamiAnalyticsJS: '', // https://custom.example.com/whatever.js
|
||||
customUmamiAnalyticsJS: '',
|
||||
},
|
||||
// PRELOAD SETTINGS >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> END
|
||||
}
|
||||
|
|
|
@ -17,9 +17,8 @@ const postsCollection = defineCollection({
|
|||
{ message: 'Abbrlink can only contain lowercase letters, numbers and hyphens' },
|
||||
),
|
||||
// Auto-generated
|
||||
minutes: z.number().optional(),
|
||||
image: z.string().optional().default(''),
|
||||
description: z.string().optional().default(''),
|
||||
image: z.string().optional().default(''),
|
||||
}),
|
||||
})
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---
|
||||
title: 主题使用指南
|
||||
title: 主题上手指南
|
||||
published: 2025-01-26
|
||||
updated: 2025-03-09
|
||||
tags: ["Astro 博客主题","指南"]
|
||||
tags: ["博客主题","指南"]
|
||||
pin: 99
|
||||
lang: zh
|
||||
---
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>
|
||||
import { toString } from 'mdast-util-to-string'
|
||||
import getReadingTime from 'reading-time'
|
||||
|
||||
|
@ -10,6 +9,5 @@ export function remarkReadingTime() {
|
|||
1,
|
||||
Math.round(readingTime.minutes),
|
||||
)
|
||||
data.astro.frontmatter.words = readingTime.words
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue