feat(i18n): 添加应用名称和描述的国际化支持
添加中英文的应用名称和描述配置 优化全局和首页的SEO meta设置 配置响应式的标题模板和国际化meta信息
This commit is contained in:
+31
@@ -1,3 +1,34 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { useHead, useSeoMeta } from '#imports'
|
||||||
|
import { useI18n } from 'vue-i18n'
|
||||||
|
import { computed } from 'vue'
|
||||||
|
|
||||||
|
const { t } = useI18n()
|
||||||
|
|
||||||
|
// 站点通用基础信息
|
||||||
|
const siteImage = '/og-image.png'
|
||||||
|
|
||||||
|
// 配置全局 Title 模板
|
||||||
|
useHead({
|
||||||
|
titleTemplate: computed(() => (titleChunk?: string) => {
|
||||||
|
const siteName = t('app.name')
|
||||||
|
return titleChunk ? `${titleChunk} - ${siteName}` : siteName
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
// 配置全局基础 SEO 和 Meta (响应式支持国际化)
|
||||||
|
useSeoMeta({
|
||||||
|
description: () => t('app.description'),
|
||||||
|
ogTitle: () => t('app.name'),
|
||||||
|
ogDescription: () => t('app.description'),
|
||||||
|
ogImage: siteImage,
|
||||||
|
twitterCard: 'summary_large_image',
|
||||||
|
twitterTitle: () => t('app.name'),
|
||||||
|
twitterDescription: () => t('app.description'),
|
||||||
|
twitterImage: siteImage,
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NuxtLayout>
|
<NuxtLayout>
|
||||||
<NuxtPage />
|
<NuxtPage />
|
||||||
|
|||||||
@@ -28,6 +28,16 @@ useHead({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 首页的 SEO 和 Meta 优化,支持国际化响应式
|
||||||
|
useSeoMeta({
|
||||||
|
title: () => t('home.title'),
|
||||||
|
description: () => t('home.welcome'),
|
||||||
|
ogTitle: () => `${t('home.title')} - ${t('app.name')}`,
|
||||||
|
ogDescription: () => t('home.welcome'),
|
||||||
|
twitterTitle: () => `${t('home.title')} - ${t('app.name')}`,
|
||||||
|
twitterDescription: () => t('home.welcome'),
|
||||||
|
})
|
||||||
|
|
||||||
// 背景图是装饰层,左右两列共用同一套模板,只通过 side 区分位置和速度。
|
// 背景图是装饰层,左右两列共用同一套模板,只通过 side 区分位置和速度。
|
||||||
const heroGalleryColumns = [
|
const heroGalleryColumns = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
{
|
{
|
||||||
|
"app": {
|
||||||
|
"name": "ArcticNewOne",
|
||||||
|
"description": "Explore infinite possibilities and modern experiences. Welcome to ArcticNewOne."
|
||||||
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"title": "Home",
|
"title": "Home",
|
||||||
"welcome": "Welcome to Arctic New One"
|
"welcome": "Welcome to Arctic New One"
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
{
|
{
|
||||||
|
"app": {
|
||||||
|
"name": "ArcticNewOne",
|
||||||
|
"description": "探索无限可能的现代化体验,欢迎来到 ArcticNewOne。"
|
||||||
|
},
|
||||||
"home": {
|
"home": {
|
||||||
"title": "首页",
|
"title": "首页",
|
||||||
"welcome": "欢迎来到 Arctic New One"
|
"welcome": "欢迎来到 Arctic New One"
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
// https://nuxt.com/docs/api/configuration/nuxt-config
|
// https://nuxt.com/docs/api/configuration/nuxt-config
|
||||||
export default defineNuxtConfig({
|
export default defineNuxtConfig({
|
||||||
|
app: {
|
||||||
|
head: {
|
||||||
|
charset: 'utf-8',
|
||||||
|
viewport: 'width=device-width, initial-scale=1, maximum-scale=1',
|
||||||
|
},
|
||||||
|
},
|
||||||
compatibilityDate: '2025-07-15',
|
compatibilityDate: '2025-07-15',
|
||||||
devtools: { enabled: true },
|
devtools: { enabled: true },
|
||||||
css: ['~/assets/css/tailwind.css'],
|
css: ['~/assets/css/tailwind.css'],
|
||||||
|
|||||||
Reference in New Issue
Block a user