mirror of
https://gitee.com/ineo6/homebrew-install.git
synced 2025-09-26 22:09:57 +08:00
feat: 添加评论功能
This commit is contained in:
parent
d1fc19cf23
commit
69316d469d
42
.dumi/theme/comment.ts
Normal file
42
.dumi/theme/comment.ts
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
import { IApi } from 'dumi';
|
||||||
|
|
||||||
|
export default (api: IApi) => {
|
||||||
|
api.describe({
|
||||||
|
key: 'valine',
|
||||||
|
config: {
|
||||||
|
schema(joi) {
|
||||||
|
return joi.object();
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const { valine = {} } = api.userConfig;
|
||||||
|
const { appId, appKey, el = '#vcomments' } = valine || {};
|
||||||
|
api.logger.log('insert Valine');
|
||||||
|
|
||||||
|
const valineScript = () => {
|
||||||
|
return `
|
||||||
|
(function(){
|
||||||
|
var script = document.createElement('script');
|
||||||
|
var m = document.getElementsByTagName('script')[0];
|
||||||
|
script.src = '//unpkg.com/valine/dist/Valine.min.js';
|
||||||
|
script.async = 'async';
|
||||||
|
|
||||||
|
script.addEventListener('load', function () {
|
||||||
|
new Valine({
|
||||||
|
el: '${el}',
|
||||||
|
appId: '${appId}',
|
||||||
|
appKey: '${appKey}'
|
||||||
|
})
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
m.parentNode.insertBefore(script, m)
|
||||||
|
})();
|
||||||
|
`;
|
||||||
|
};
|
||||||
|
|
||||||
|
api.addHTMLScripts(() => [
|
||||||
|
{
|
||||||
|
content: valineScript(),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
};
|
@ -102,6 +102,7 @@ const Layout: React.FC<IRouteComponentProps> = ({ children, location }) => {
|
|||||||
<div className="__dumi-default-layout-content">
|
<div className="__dumi-default-layout-content">
|
||||||
{children}
|
{children}
|
||||||
{!showHero && !showFeatures && meta.filePath && !meta.gapless && (
|
{!showHero && !showFeatures && meta.filePath && !meta.gapless && (
|
||||||
|
<>
|
||||||
<div className="__dumi-default-layout-footer-meta">
|
<div className="__dumi-default-layout-footer-meta">
|
||||||
{repoPlatform && (
|
{repoPlatform && (
|
||||||
<Link to={`${repoUrl}/edit/${branch}/${meta.filePath}`}>
|
<Link to={`${repoUrl}/edit/${branch}/${meta.filePath}`}>
|
||||||
@ -110,10 +111,14 @@ const Layout: React.FC<IRouteComponentProps> = ({ children, location }) => {
|
|||||||
: `Edit this doc on ${repoPlatform}`}
|
: `Edit this doc on ${repoPlatform}`}
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
<span data-updated-text={isCN ? '最后更新时间:' : 'Last update: '}>
|
<span
|
||||||
|
data-updated-text={isCN ? '最后更新时间:' : 'Last update: '}
|
||||||
|
>
|
||||||
{updatedTime}
|
{updatedTime}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="vcomments"></div>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{(showHero || showFeatures) && meta.footer && (
|
{(showHero || showFeatures) && meta.footer && (
|
||||||
<div
|
<div
|
||||||
|
@ -316,3 +316,7 @@ body {
|
|||||||
color: #b0b1ba;
|
color: #b0b1ba;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#vcomments {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
@ -87,6 +87,11 @@ export default defineConfig({
|
|||||||
// mode: 'string',
|
// mode: 'string',
|
||||||
// staticMarkup: false,
|
// staticMarkup: false,
|
||||||
},
|
},
|
||||||
|
valine: {
|
||||||
|
appId: 'Ke6Uq74Gi6sdTxcDu4nJ6sdw-MdYXbMMI',
|
||||||
|
appKey: 'VtFD26towQ1JQxB9tLHd8odg',
|
||||||
|
},
|
||||||
|
plugins: ['./.dumi/theme/comment.ts'],
|
||||||
exportStatic: {},
|
exportStatic: {},
|
||||||
// more config: https://d.umijs.org/config
|
// more config: https://d.umijs.org/config
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user