mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-14 07:26:52 +00:00
[feat] 支持matomo网站统计
This commit is contained in:
@@ -37,14 +37,11 @@ const BLOG = {
|
||||
|
||||
BLOG_FAVICON: process.env.NEXT_PUBLIC_FAVICON || '/favicon.ico', // blog favicon 配置, 默认使用 /public/favicon.ico,支持在线图片,如 https://img.imesong.com/favicon.png
|
||||
|
||||
|
||||
RANDOM_IMAGE_URL: process.env.NEXT_PUBLIC_RANDOM_IMAGE_URL || '', // 随机图片API,如果未配置下面的关键字,主页封面,头像,文章封面图都会被替换为随机图片
|
||||
RANDOM_IMAGE_REPLACE_TEXT: process.env.NEXT_PUBLIC_RANDOM_IMAGE_NOT_REPLACE_TEXT || 'images.unsplash.com', // 触发替换图片的 url 关键字(多个支持用英文逗号分开),只有图片地址中包含此关键字才会替换为上方随机图片url
|
||||
// eg: images.unsplash.com(notion图床的所有图片都会替换),如果你在 notion 里已经添加了一个随机图片 url,恰巧那个服务跑路或者挂掉,想一键切换所有配图可以将该 url 配置在这里
|
||||
// 默认下会将你上传到 notion的主页封面图和头像也给替换,建议将主页封面图和头像放在其他图床,在 notion 里配置 link 即可。
|
||||
|
||||
|
||||
|
||||
// START ************网站字体*****************
|
||||
|
||||
FONT_STYLE: process.env.NEXT_PUBLIC_FONT_STYLE || 'font-sans', // ['font-serif','font-sans'] 两种可选,分别是衬线和无衬线: 参考 https://www.jianshu.com/p/55e410bd2115
|
||||
@@ -329,6 +326,9 @@ const BLOG = {
|
||||
ANALYTICS_CNZZ_ID: process.env.NEXT_PUBLIC_ANALYTICS_CNZZ_ID || '', // 只需要填写站长统计的id, [cnzz_id] -> https://s9.cnzz.com/z_stat.php?id=[cnzz_id]&web_id=[cnzz_id]
|
||||
ANALYTICS_GOOGLE_ID: process.env.NEXT_PUBLIC_ANALYTICS_GOOGLE_ID || '', // 谷歌Analytics的id e.g: G-XXXXXXXXXX
|
||||
|
||||
// Matomo 网站统计
|
||||
MATOMO_HOST_URL: process.env.NEXT_PUBLIC_MATOMO_HOST_URL || '', // Matomo服务器地址,不带斜杠
|
||||
MATOMO_SITE_ID: process.env.NEXT_PUBLIC_MATOMO_SITE_ID || '', // Matomo网站ID
|
||||
// ACKEE网站访客统计工具
|
||||
ANALYTICS_ACKEE_TRACKER: process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_TRACKER || '', // e.g 'https://ackee.tangly1024.com/tracker.js'
|
||||
ANALYTICS_ACKEE_DATA_SERVER: process.env.NEXT_PUBLIC_ANALYTICS_ACKEE_DATA_SERVER || '', // e.g https://ackee.tangly1024.com , don't end with a slash
|
||||
|
||||
@@ -97,6 +97,24 @@ const CommonScript = () => {
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Matomo 统计 */}
|
||||
{BLOG.MATOMO_HOST_URL && BLOG.MATOMO_SITE_ID && (
|
||||
<script async dangerouslySetInnerHTML={{
|
||||
__html: `
|
||||
var _paq = window._paq = window._paq || [];
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u="//${BLOG.MATOMO_HOST_URL}/";
|
||||
_paq.push(['setTrackerUrl', u+'matomo.php']);
|
||||
_paq.push(['setSiteId', '${BLOG.MATOMO_SITE_ID}']);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
|
||||
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
`
|
||||
}}/>
|
||||
)}
|
||||
|
||||
{/* 谷歌统计 */}
|
||||
{BLOG.ANALYTICS_GOOGLE_ID && (<>
|
||||
<script async
|
||||
|
||||
@@ -70,24 +70,23 @@ const mapImgUrl = (img, block, type = 'block', from) => {
|
||||
if (!isEmoji(ret) && ret.indexOf('notion.so/images/page-cover') < 0) {
|
||||
if (BLOG.RANDOM_IMAGE_URL) {
|
||||
// 只有配置了随机图片接口,才会替换图片
|
||||
const texts = BLOG.RANDOM_IMAGE_REPLACE_TEXT
|
||||
let isReplace = false;
|
||||
if (texts) {
|
||||
const textArr = texts.split(',')
|
||||
// 判断是否包含替换的文本
|
||||
textArr.forEach(text => {
|
||||
if (ret.indexOf(text) > -1) {
|
||||
isReplace = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
isReplace = true
|
||||
}
|
||||
|
||||
if (isReplace) {
|
||||
ret = BLOG.RANDOM_IMAGE_URL
|
||||
}
|
||||
const texts = BLOG.RANDOM_IMAGE_REPLACE_TEXT
|
||||
let isReplace = false;
|
||||
if (texts) {
|
||||
const textArr = texts.split(',')
|
||||
// 判断是否包含替换的文本
|
||||
textArr.forEach(text => {
|
||||
if (ret.indexOf(text) > -1) {
|
||||
isReplace = true
|
||||
}
|
||||
})
|
||||
} else {
|
||||
isReplace = true
|
||||
}
|
||||
if (isReplace) {
|
||||
ret = BLOG.RANDOM_IMAGE_URL
|
||||
}
|
||||
}
|
||||
// 随机图片接口优化 防止因url一致而随机结果相同
|
||||
const separator = ret.includes('?') ? '&' : '?'
|
||||
// 拼接唯一识别参数,防止请求的图片被缓存
|
||||
|
||||
Reference in New Issue
Block a user