mirror of
https://github.com/reonokiy/blog.nokiy.net.git
synced 2025-06-17 12:01:33 +02:00
feat: i18n rss url and different excerpt length for different languages
This commit is contained in:
parent
e4c61bf21b
commit
f34b0cb46b
6 changed files with 62 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue