saicaca / fuwari

✨A static blog template built with Astro.
https://fuwari.vercel.app
MIT License
1.26k stars 276 forks source link

Search issues caused by language settings #167

Closed Yuuzi261 closed 1 month ago

Yuuzi261 commented 1 month ago

Description

When I was searching, I found that I could not find the posts I had written, so I did some tests. Is this a bug?

SiteConfig.lang = 'en' & language of posts = 'zh_TW'

I can only search About in English, and cannot search in Chinese.

圖片 圖片

SiteConfig.lang = 'zh_TW' & language of posts = 'zh_TW'

Everything works fine.

圖片 圖片

SiteConfig.lang = 'en' & language of posts = 'en'

After knowing that the problem was caused by language, I also set the language of the Chinese posts to English. I can search in English, but the preview of Chinese posts becomes strange, and I can't search in Chinese either.

圖片 圖片

Conclusion

Because the SiteConfig.lang will affect the language of the UI setting, if I want the UI to be in English, but it will result in Chinese posts not being searched, it is not very convenient.

saicaca commented 1 month ago

Will look into it

saicaca commented 1 month ago

Pagefind needs to know the webpage's language to index the content correctly. By default, it is the site language in the config.ts. That is why posts in Chinese cannot be indexed when the site's language is set to en.

To fix it, you can specify the lang attribute in the front-matter of the post, which overrides the site language setting.

lang: zh_TW