From 3fbb453214118e01b75343303549dc9a49ff12ad Mon Sep 17 00:00:00 2001 From: goodspeed Date: Mon, 7 Oct 2024 16:53:48 +0800 Subject: [PATCH] add clarity analytics --- layouts/default.vue | 15 ++++++--------- nuxt.config.ts | 39 +++++++++++++++++++++++++++------------ package-lock.json | 9 +++++++++ package.json | 1 + 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/layouts/default.vue b/layouts/default.vue index 91195ed..4b35f00 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -109,6 +109,7 @@ const nightModeIcon = ref('🌙') const mobileMenuOpen = ref(false) const mobileFriendLinksOpen = ref(false) const floatingTimeLabel = ref(null) +const config = useRuntimeConfig() const toggleNightMode = () => { document.documentElement.classList.toggle('dark') @@ -192,23 +193,19 @@ onMounted(() => { // SEO优化 useHead({ titleTemplate: (titleChunk) => { - return titleChunk ? `${titleChunk} - 古思乱讲` : '古思乱讲' + return titleChunk ? `${titleChunk} - ${config.public.siteTitle}` : config.public.siteTitle }, meta: [ - { charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }, - { name: 'description', content: '古思乱讲 - 一个关于技术、生活和思考的博客' }, + { name: 'description', content: config.public.siteDescription }, { name: 'format-detection', content: 'telephone=no' }, - // Open Graph - { property: 'og:site_name', content: '古思乱讲' }, + { property: 'og:site_name', content: config.public.siteTitle }, { property: 'og:type', content: 'website' }, - // Twitter Card - { name: 'twitter:card', content: 'summary_large_image' }, - { name: 'twitter:site', content: '@yourtwitterhandle' }, + { name: 'twitter:site', content: config.public.twitterHandle }, ], link: [ { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }, - { rel: 'canonical', href: 'https://momo.gusibi.mobi' } + { rel: 'canonical', href: config.public.siteUrl } ], }) \ No newline at end of file diff --git a/nuxt.config.ts b/nuxt.config.ts index 49e1333..f965b7c 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -1,20 +1,32 @@ // https://nuxt.com/docs/api/configuration/nuxt-config export default defineNuxtConfig({ - site: { - url: 'https://momo.gusibi.mobi', - name: '古思乱讲' + // site: { + // url: 'https://momo.gusibi.mobi', + // name: '古思乱讲' + // }, + app: { + head: { + charset: 'utf-8', + viewport: 'width=device-width, initial-scale=1', + titleTemplate: '%s - 古思乱讲', + meta: [ + { charset: 'utf-8' }, + { name: 'viewport', content: 'width=device-width, initial-scale=1' }, + { name: 'format-detection', content: 'telephone=no' }, + // Open Graph + { property: 'og:type', content: 'website' }, + // Twitter Card + { name: 'twitter:card', content: 'summary_large_image' }, + ], + link: [ + { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }, + ] + } }, ssr: false, compatibilityDate: '2024-04-03', devtools: { enabled: true }, - modules: [ - '@nuxtjs/tailwindcss', - '@pinia/nuxt', - '@stefanobartoletti/nuxt-social-share', - '@nuxtjs/sitemap', - '@nuxtjs/supabase', - 'nuxt-gtag', - ], + modules: ['@nuxtjs/tailwindcss', '@pinia/nuxt', '@stefanobartoletti/nuxt-social-share', '@nuxtjs/sitemap', '@nuxtjs/supabase', 'nuxt-gtag', 'nuxt-clarity-analytics'], // configuration options socialShare: { @@ -54,10 +66,13 @@ export default defineNuxtConfig({ runtimeConfig: { public: { apiBaseUrl: process.env.API_BASE_URL || 'https://path-memo-api.gusibi.mobi', - siteUrl: process.env.SITE_URL || 'https://momo.gusibi.mobi', repoOwner: process.env.REPO_OWNER || 'gusibi', repoName: process.env.REPO_NAME || 'path-meme-db', perPageSize: process.env.PER_PAGE_SIZE || '10', + siteTitle: '古思乱讲', + siteDescription: '古思乱讲 - 一个关于技术、生活和思考的博客', + siteUrl: process.env.SITE_URL || 'https://momo.gusibi.mobi', + twitterHandle: '@yourtwitterhandle' }, private: { githubToken: process.env.GITHUB_TOKEN diff --git a/package-lock.json b/package-lock.json index 530c6fa..5652ffd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,7 @@ "html-to-image": "^1.11.11", "marked": "^14.1.2", "nuxt": "^3.13.2", + "nuxt-clarity-analytics": "^0.0.9", "nuxt-gtag": "^3.0.1", "octokit": "^4.0.2", "qrcode.vue": "^3.5.0", @@ -7321,6 +7322,14 @@ } } }, + "node_modules/nuxt-clarity-analytics": { + "version": "0.0.9", + "resolved": "https://registry.npmmirror.com/nuxt-clarity-analytics/-/nuxt-clarity-analytics-0.0.9.tgz", + "integrity": "sha512-H5w+B5XOm9hdoVn3CnDCKIcnZli48UwuD8fP1bOogse0NVxNDUKhW0pdqOMRkniL/oORiqIwMrEZh12YE+23KQ==", + "dependencies": { + "@nuxt/kit": "^3.13.1" + } + }, "node_modules/nuxt-gtag": { "version": "3.0.1", "resolved": "https://registry.npmmirror.com/nuxt-gtag/-/nuxt-gtag-3.0.1.tgz", diff --git a/package.json b/package.json index 0bc5f3a..4f6c1bc 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "html-to-image": "^1.11.11", "marked": "^14.1.2", "nuxt": "^3.13.2", + "nuxt-clarity-analytics": "^0.0.9", "nuxt-gtag": "^3.0.1", "octokit": "^4.0.2", "qrcode.vue": "^3.5.0",