feat: i18n rss url and different excerpt length for different languages

This commit is contained in:
radishzzz 2025-03-17 02:49:02 +00:00
parent e4c61bf21b
commit f34b0cb46b
6 changed files with 62 additions and 13 deletions

View file

@ -1,7 +1,8 @@
---
import LanguageSwitcher from '@/components/Widgets/LanguageSwitcher.astro'
import ThemeToggle from '@/components/Widgets/ThemeToggle.astro'
import themeConfig from '@/config'
import { defaultLocale, themeConfig } from '@/config'
import { getLangFromPath } from '@/i18n/lang'
interface Props {
class?: string
@ -10,7 +11,19 @@ interface Props {
const { class: className, supportedLangs = [] } = Astro.props
const { author } = themeConfig.site
const { links, startYear } = themeConfig.footer
const { links: configLinks, startYear } = themeConfig.footer
// i18n rss path
const currentLang = getLangFromPath(Astro.url.pathname)
const links = configLinks.map((link) => {
if (link.name === 'RSS') {
return {
...link,
url: currentLang === defaultLocale ? link.url : `/${currentLang}${link.url}/`,
}
}
return link
})
const currentYear = new Date().getFullYear()
const year = Number(startYear) === currentYear

View file

@ -68,7 +68,7 @@ function getPostPath(post: Post) {
class="heti hidden"
lg="mt-2 block"
>
<p>{generateDescription(post)}</p>
<p>{generateDescription(post, 'list')}</p>
</div>
</li>