test02/node_modules/@vuepress/plugin-back-to-top/lib/node/backToTopPlugin.js
罗佳鸿 6aa1ebe342
Some checks are pending
部署文档 / deploy-gh-pages (push) Waiting to run
first commit
2024-08-13 10:11:19 +08:00

24 lines
882 B
JavaScript

import { getLocaleConfig } from '@vuepress/helper';
import { getDirname, logger, path } from 'vuepress/utils';
import { backToTopLocales } from './locales.js';
import { PLUGIN_NAME } from './logger.js';
const __dirname = getDirname(import.meta.url);
export const backToTopPlugin = (options = {}) => (app) => {
if (app.env.isDebug)
logger.info('Options', options);
return {
name: PLUGIN_NAME,
define: (app) => ({
__BACK_TO_TOP_LOCALES__: getLocaleConfig({
app,
name: 'back-to-top',
default: backToTopLocales,
config: options.locales,
}),
__BACK_TO_TOP_PROGRESS__: options.progress ?? true,
__BACK_TO_TOP_THRESHOLD__: options.threshold ?? 100,
}),
clientConfigFile: path.resolve(__dirname, '../client/config.js'),
};
};