Merge pull request 'head 优化' (#613) from Eeeros/forgeplus-react:gitlink_ssr_test into gitlink_ssr
1
This commit is contained in:
commit
f16dabe7d6
|
|
@ -2,6 +2,8 @@ import React from "react";
|
|||
import md5 from 'md5';
|
||||
import {Input} from "antd";
|
||||
const { Search } = Input;
|
||||
import { url as ssrOrigin, host as ssrHost } from '../ssrUrl'
|
||||
|
||||
|
||||
// const $ = window.$;
|
||||
const isDev = __SERVER__ ? false : window.location.port == 3007;
|
||||
|
|
@ -351,13 +353,17 @@ export function setSeoMeta(keyWords, title, description, url, owner, projectId)
|
|||
if (domObj) {
|
||||
document = domObj.window.document
|
||||
}
|
||||
// 服务端没有location
|
||||
const host = window.location.host === 'null' || !window.location.host ? ssrHost : window.location.host
|
||||
const origin = window.location.origin === 'null' || !window.location.origin ? ssrOrigin : window.location.origin
|
||||
|
||||
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:url']`).content = origin + url;
|
||||
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 } ${ keyWords ? '' : 'gitLink,GitLink,gitlink,trustie,trustieforge,forge,开源,确实开源,代码托管,Git,开源,内源,项目管理,版本控制,开源代码,代码分享,项目协作,开源项目托管,免费代码托管,Git代码托管,Git托管服务,确实让创建更美好,协同开发平台' }` ;
|
||||
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='go-import']`).content = host + url + ' git ' + 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;
|
||||
|
|
@ -365,11 +371,7 @@ export function setSeoMeta(keyWords, title, description, url, owner, projectId)
|
|||
}
|
||||
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;
|
||||
if (domObj) {
|
||||
domObj.window.document.querySelector('meta[name="Keywords"]')
|
||||
}
|
||||
document.querySelector(`link[rel='canonical']`).href = origin + url;
|
||||
}
|
||||
|
||||
export function setDefaultMeta() {
|
||||
|
|
|
|||
|
|
@ -430,7 +430,7 @@ class Detail extends Component {
|
|||
// seo优化设置
|
||||
let keyWords=`${owner},${projectsId},${data.author.name},`;
|
||||
let title= `${owner}/${projectsId}${data.description?':'+data.description:''}`;
|
||||
setSeoMeta(keyWords,title,data.description,`/${owner}/${projectsId}`,owner,projectsId);
|
||||
setSeoMeta(keyWords,title,data.description || '',`/${owner}/${projectsId}`,owner,projectsId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1 +1,2 @@
|
|||
export const url = process.env.NODE_ENV === 'production' ? 'https://www.gitlink.org.cn' : 'http://172.20.32.202:4000'
|
||||
export const url = process.env.NODE_ENV === 'production' ? 'https://www.gitlink.org.cn' : 'http://172.20.32.202:4000'
|
||||
export const host = process.env.NODE_ENV === 'production' ? 'www.gitlink.org.cn' : '172.20.32.202:4000'
|
||||
Loading…
Reference in New Issue