Skip to content

Commit

Permalink
fix: SEO
Browse files Browse the repository at this point in the history
  • Loading branch information
Chilfish committed Mar 2, 2024
1 parent ef8c91e commit b59ef39
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 7 deletions.
2 changes: 1 addition & 1 deletion apps/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" href="/icon.png" type="image/svg+xml">
<title>Weibo</title>
<title>Weibo Archiver</title>
<meta name="naive-ui-style" />
</head>
<body class="font-sans dark:text-white dark:bg-hex-121212">
Expand Down
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"typecheck": "vue-tsc --noEmit"
},
"dependencies": {
"@unhead/vue": "^1.8.10",
"@weibo-archiver/ui": "workspace:^"
}
}
30 changes: 30 additions & 0 deletions apps/web/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
<script setup lang="ts">
const user = useStorage('meta', { name: '' })
const appName = 'Weibo-Archiver'
const title = computed(() => {
const { name } = user.value
return name ? `@${name} - ${appName}` : `${appName} - 备份你的微博`
})
const description = `${appName} 一个微博备份工具,在账号被完全夹没前未雨绸缪 😭。`
const ogImage = 'https://p.chilfish.top/weibo/cover.webp'
useHead({
title,
})
useSeoMeta({
title,
description,
ogDescription: description,
ogImage,
ogImageAlt: appName,
ogSiteName: appName,
ogType: 'website',
ogUrl: 'https://weibo.chilfish.top',
ogLocale: 'zh_CN',
ogTitle: title,
twitterCard: 'summary_large_image',
twitterTitle: title,
twitterDescription: description,
twitterCreator: 'chilllish',
})
</script>

<template>
Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { createApp } from 'vue'
import { createPinia } from 'pinia'
import { createHead } from '@unhead/vue'
import { type RouteRecordRaw, createRouter, createWebHistory } from 'vue-router'
import App from './App.vue'

Expand All @@ -8,6 +9,7 @@ import 'uno.css'
import '@ui/shared.css'

const app = createApp(App)
const head = createHead()

const routes: RouteRecordRaw[] = [
{
Expand All @@ -32,4 +34,5 @@ const router = createRouter({
app
.use(router)
.use(createPinia())
.use(head)
.mount('#app')
2 changes: 2 additions & 0 deletions apps/web/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from 'node:path'
import { defineConfig } from 'vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
import { unheadVueComposablesImports } from '@unhead/vue'

import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
Expand All @@ -18,6 +19,7 @@ export default defineConfig({
...autoImportConfig,
imports: [
...autoImportConfig.imports as any[],
unheadVueComposablesImports,
{
'naive-ui': [
'useDialog',
Expand Down
2 changes: 2 additions & 0 deletions packages/ui/src/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const isMe = computed(() => {
const avatar = computed(() => {
const url = props.user.profile_image_url
if (!url)
return '/placeholder.webp'
if (isMe.value)
return replaceImg(url)
Expand Down
59 changes: 53 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b59ef39

Please sign in to comment.