From d532912f06157fd96861594836dd6782d63d1f55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=AB=A5=E5=B4=87?= <792998983@qq.com> Date: Tue, 7 Feb 2023 15:24:37 +0800 Subject: [PATCH] =?UTF-8?q?seo=E4=BC=98=E5=8C=96=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 4 +++- src/common/UrlTool.js | 17 ++++++++++------- src/forge/Main/CoderDepot.jsx | 4 ++-- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/public/index.html b/public/index.html index a9459cced..88863515a 100755 --- a/public/index.html +++ b/public/index.html @@ -3,7 +3,7 @@
- + @@ -17,6 +17,8 @@ + + diff --git a/src/common/UrlTool.js b/src/common/UrlTool.js index 98e381e2b..f1654f0d1 100644 --- a/src/common/UrlTool.js +++ b/src/common/UrlTool.js @@ -321,22 +321,25 @@ export function addMeta(name, content){ * projectId 项目唯一标识 */ export function setSeoMeta(keyWords, title, description, url, owner, projectId) { - console.log('keyWords:'+ keyWords); - document.querySelector(`meta[property='og:title']`).content = title; + let keyStatement = ' '; + if(owner)keyStatement += owner; + if(projectId)keyStatement += `/${projectId}`; + + document.querySelector(`meta[property='og:title']`).content = title + keyStatement + ' for gitlink' + keyStatement + ' for git'; document.querySelector(`meta[property='og:url']`).content = window.location.origin + url; - document.querySelector(`meta[property='og:description']`).content = description + ' - ' + title; - document.querySelector(`meta[property='og:image:alt']`).content = description + ' - ' + title; + document.querySelector(`meta[property='og:description']`).content = description + ' - ' + title + ' for gitlink' + keyStatement + ' for git'; + document.querySelector(`meta[property='og:image:alt']`).content = description + ' - ' + title + ' for gitlink' + keyStatement + ' for git'; document.querySelector('meta[name="Keywords"]').content=keyWords + 'gitLink,GitLink,gitlink,trustie,trustieforge,forge,开源,确实开源,代码托管,Git,开源,内源,项目管理,版本控制,开源代码,代码分享,项目协作,开源项目托管,免费代码托管,Git代码托管,Git托管服务,确实让创建更美好,协同开发平台'; - document.querySelector(`meta[name='description']`).content = description; + document.querySelector(`meta[name='description']`).content = description + keyStatement + ' for gitlink' + keyStatement + ' for git'; document.querySelector(`meta[name='go-import']`).content = window.location.host + url + ' git ' + window.location.origin + url; document.querySelector(`meta[name='octolytics-dimension-user_login']`).content = owner; if (projectId) { document.querySelector(`meta[name='octolytics-dimension-repository_nwo']`).content = owner + '/' + projectId; document.querySelector(`meta[name='octolytics-dimension-repository_network_root_nwo']`).content = owner + '/' + projectId; } - document.querySelector(`meta[name='twitter:title']`).content = title; - document.querySelector(`meta[name='twitter:description']`).content = description + ' - ' + title; + document.querySelector(`meta[name='twitter:title']`).content = title + keyStatement + ' for gitlink' + keyStatement + ' for git'; + document.querySelector(`meta[name='twitter:description']`).content = description + ' - ' + title + keyStatement + ' for gitlink' + keyStatement + ' for git'; document.querySelector(`link[rel='canonical']`).href = window.location.origin + url; diff --git a/src/forge/Main/CoderDepot.jsx b/src/forge/Main/CoderDepot.jsx index 51df3a40d..309535ae8 100644 --- a/src/forge/Main/CoderDepot.jsx +++ b/src/forge/Main/CoderDepot.jsx @@ -107,9 +107,9 @@ function CoderDepot(props){ const { author, name, description, default_branch} = details; if(branchName && branchName !== default_branch){ // 处于某分支/标签 - document.title = `${author.name}/${name}-${branchName}`; + document.title = `${author.name}/${name}-${branchName}-for gitlink;for git`; }else{ - document.title = `${author.name}/${name}${description?': '+description:''}`; + document.title = `${author.name}/${name}${description?': '+description:''}-for gitlink;for git` ; } } }, [treeValuePath, details, branchName])