forked from Gitlink/forgeplus-react
帖子详情页动态修改title与head
This commit is contained in:
parent
baed9df260
commit
0580fcb2c0
|
|
@ -3,10 +3,10 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="google" content="notranslate" />
|
||||
<meta name=”Keywords” Content="trustie,trustieforge,forge,确实让创建更美好,协同开发平台">
|
||||
<meta name=”Keywords” Content="TrustieOpenSourceProject">
|
||||
<meta name=”Keywords” Content="issue,bug,tracker,软件工程,课程实践">
|
||||
<meta name=”Description” Content="持续构建协同、共享、可信的软件创建生态开源创作与软件生产相结合,支持大规模群体开展软件协同创新活动">
|
||||
<meta name="Keywords" Content="trustie,trustieforge,forge,确实让创建更美好,协同开发平台">
|
||||
<meta name="Keywords" Content="TrustieOpenSourceProject">
|
||||
<meta name="Keywords" Content="issue,bug,tracker,软件工程,课程实践">
|
||||
<meta name="Description" Content="持续构建协同、共享、可信的软件创建生态开源创作与软件生产相结合,支持大规模群体开展软件协同创新活动">
|
||||
<meta name="theme-color" content="#000000">
|
||||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
||||
<link rel=" stylesheet" type="text/css" href="%PUBLIC_URL%css/iconfont.css">
|
||||
|
|
|
|||
|
|
@ -219,3 +219,15 @@ export function publicSearchs(Placeholder,onSearch,onInputs,onChanges,loadings)
|
|||
allowClear={true}
|
||||
></Search>)
|
||||
}
|
||||
|
||||
// 手动添加/修改mate标签
|
||||
export function addMeta(name, content){
|
||||
if(document.querySelector(`meta[name='${name}']`)){
|
||||
document.querySelector(`meta[name='${name}']`).content=content;
|
||||
}else{
|
||||
const meta = document.createElement('meta');
|
||||
meta.content = content;
|
||||
meta.name = name;
|
||||
document.getElementsByTagName('head')[0].appendChild(meta);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export {
|
|||
getUploadLogoActionUrl as getUploadLogoActionUrl,
|
||||
getImageUrl as getImageUrl, getmyUrl as getmyUrl, getRandomNumber as getRandomNumber, getUrl as getUrl, publicSearchs as publicSearchs, getRandomcode as getRandomcode, getUrlmys as getUrlmys, getUrl2 as getUrl2, setImagesUrl as setImagesUrl
|
||||
, getUploadActionUrl as getUploadActionUrl, getUploadActionUrltwo as getUploadActionUrltwo, getUploadActionUrlthree as getUploadActionUrlthree, getUploadActionUrlOfAuth as getUploadActionUrlOfAuth
|
||||
, getTaskUrlById as getTaskUrlById, TEST_HOST, htmlEncode as htmlEncode, getupload_git_file as getupload_git_file, getcdnImageUrl as getcdnImageUrl
|
||||
, getTaskUrlById as getTaskUrlById, TEST_HOST, htmlEncode as htmlEncode, getupload_git_file as getupload_git_file, getcdnImageUrl as getcdnImageUrl, addMeta as addMeta
|
||||
} from './UrlTool';
|
||||
|
||||
export { setmiyah as setmiyah } from './Component';
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import axios from "axios";
|
||||
import { getImageUrl } from "educoder";
|
||||
import { getImageUrl, addMeta } from "educoder";
|
||||
import { Breadcrumb, Spin, Empty } from "antd";
|
||||
import { Link } from "react-router-dom";
|
||||
import {
|
||||
|
|
@ -47,7 +47,9 @@ function memo_show(props) {
|
|||
}, [memo_id]);
|
||||
|
||||
function componentWillUnmount() {
|
||||
// 离开页面恢复原来title与head
|
||||
document.title = '论坛交流'
|
||||
addMeta('Keywords', "trustie,trustieforge,forge,确实让创建更美好,协同开发平台")
|
||||
}
|
||||
|
||||
async function init() {
|
||||
|
|
@ -74,7 +76,9 @@ function memo_show(props) {
|
|||
setRecentmemos(result.data.recent_memos);
|
||||
setIsBanned(result.data.is_banned);
|
||||
getMemoUser(result.data.author_info);
|
||||
// 帖子详情页动态修改title与head
|
||||
document.title = `${result.data.memo.subject}/${result.data.memo.forum_tag && result.data.memo.forum_tag.title}`
|
||||
addMeta('Keywords', `${result.data.memo.subject}/${result.data.memo.forum_tag && result.data.memo.forum_tag.title}`)
|
||||
}
|
||||
setSpinType(false);
|
||||
})
|
||||
|
|
|
|||
Loading…
Reference in New Issue