mirror of
https://gitee.com/ineo6/homebrew-install.git
synced 2025-04-05 19:41:45 +08:00
feat: 调整valine方案
This commit is contained in:
parent
9aa504c325
commit
3d8bbf5a75
18
.dumi/theme/ValineComment.tsx
Normal file
18
.dumi/theme/ValineComment.tsx
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
|
export default function ValineComment({ location }) {
|
||||||
|
const { pathname } = location;
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
import('valine').then(Valine => {
|
||||||
|
new Valine.default({
|
||||||
|
el: '#vcomments',
|
||||||
|
appId: 'Ke6Uq74Gi6sdTxcDu4nJ6sdw-MdYXbMMI',
|
||||||
|
appKey: 'VtFD26towQ1JQxB9tLHd8odg',
|
||||||
|
path: pathname,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, [pathname]);
|
||||||
|
|
||||||
|
return <div id="vcomments" />;
|
||||||
|
}
|
@ -5,8 +5,8 @@ import Navbar from 'dumi-theme-default/src/components/Navbar';
|
|||||||
import SideMenu from 'dumi-theme-default/src/components/SideMenu';
|
import SideMenu from 'dumi-theme-default/src/components/SideMenu';
|
||||||
import SlugList from 'dumi-theme-default/src/components/SlugList';
|
import SlugList from 'dumi-theme-default/src/components/SlugList';
|
||||||
import SearchBar from 'dumi-theme-default/src/components/SearchBar';
|
import SearchBar from 'dumi-theme-default/src/components/SearchBar';
|
||||||
import { ValineComment } from 'dumi';
|
|
||||||
import Notice from './Notice';
|
import Notice from './Notice';
|
||||||
|
import ValineComment from './ValineComment';
|
||||||
import './style/layout.less';
|
import './style/layout.less';
|
||||||
|
|
||||||
const Hero = hero => (
|
const Hero = hero => (
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
import { useEffect } from 'react';
|
|
||||||
import Valine from 'valine';
|
|
||||||
|
|
||||||
export function ValineComment({ location }) {
|
|
||||||
const { pathname } = location;
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
import('valine').then(Valine => {
|
|
||||||
console.log(Valine)
|
|
||||||
new Valine.default({
|
|
||||||
el: '{{{ el }}}',
|
|
||||||
appId: '{{{ appId }}}',
|
|
||||||
appKey: '{{{ appKey }}}'
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}, [pathname])
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div id="vcomments"/>
|
|
||||||
)
|
|
||||||
}
|
|
@ -1,52 +0,0 @@
|
|||||||
import { IApi } from 'dumi';
|
|
||||||
import { join } from 'path';
|
|
||||||
import { readFileSync } from 'fs';
|
|
||||||
|
|
||||||
export default (api: IApi) => {
|
|
||||||
const {
|
|
||||||
paths,
|
|
||||||
utils: { Mustache, winPath, lodash },
|
|
||||||
} = api;
|
|
||||||
|
|
||||||
api.describe({
|
|
||||||
key: 'valine',
|
|
||||||
config: {
|
|
||||||
default: {
|
|
||||||
el: '#vcomments',
|
|
||||||
appId: '',
|
|
||||||
appKey: '',
|
|
||||||
},
|
|
||||||
schema(joi) {
|
|
||||||
return joi.object({
|
|
||||||
el: joi.string(),
|
|
||||||
appId: joi.string(),
|
|
||||||
appKey: joi.string(),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// 生成临时文件
|
|
||||||
api.onGenerateFiles(async () => {
|
|
||||||
// Comment.tsx
|
|
||||||
const selectLang = readFileSync(join(__dirname, 'Comment.tpl'), 'utf-8');
|
|
||||||
|
|
||||||
const { appId, appKey, el = '#vcomments' } = api.userConfig.valine;
|
|
||||||
|
|
||||||
api.writeTmpFile({
|
|
||||||
path: 'plugin-valine/Comment.tsx',
|
|
||||||
content: Mustache.render(selectLang, {
|
|
||||||
el: el,
|
|
||||||
appId: appId,
|
|
||||||
appKey: appKey,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
api.addUmiExports(() => {
|
|
||||||
return {
|
|
||||||
exportAll: true,
|
|
||||||
source: `../plugin-valine/Comment`,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
};
|
|
@ -87,11 +87,6 @@ export default defineConfig({
|
|||||||
// mode: 'string',
|
// mode: 'string',
|
||||||
// staticMarkup: false,
|
// staticMarkup: false,
|
||||||
},
|
},
|
||||||
valine: {
|
|
||||||
appId: 'Ke6Uq74Gi6sdTxcDu4nJ6sdw-MdYXbMMI',
|
|
||||||
appKey: 'VtFD26towQ1JQxB9tLHd8odg',
|
|
||||||
},
|
|
||||||
plugins: ['./.dumi/theme/plugin-valine/index.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