useSeo.ts 739 B

123456789101112131415161718192021222324252627
  1. // import { useSeoMeta } from '#imports'; // Nuxt 3 提供的 composables
  2. // const seoSetup = function(title: string, description: string, keywords: string){
  3. // // 使用 useSeoMeta 设置 SEO 相关的 meta 标签
  4. // useSeoMeta({
  5. // title,
  6. // description,
  7. // keywords,
  8. // });
  9. // };
  10. // export {seoSetup};
  11. import { useHead } from '#imports'; // Nuxt 3 提供的 composables
  12. const seoSetup = (title: string, description: string, keywords: string) => {
  13. useHead({
  14. title: title,
  15. meta: [
  16. { name: 'description', content: description },
  17. { name: 'keywords', content: keywords },
  18. { name: 'viewport', content: 'width=device-width,initial-scale=1,user-scalable=no' }
  19. ]
  20. });
  21. };
  22. export {seoSetup};