@starzkg/vuepress-plugin-page-info
Version:
A comment plugin for vuepress
49 lines (48 loc) • 2.38 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.pageInfoPlugin = void 0;
const vuepress_plugin_reading_time_1 = require("@starzkg/vuepress-plugin-reading-time");
const vuepress_shared_1 = require("@starzkg/vuepress-shared");
const utils_1 = require("@vuepress/utils");
const vuepress_plugin_sass_palette_1 = require("vuepress-plugin-sass-palette");
const i18n_1 = require("./i18n");
__exportStar(require("../shared"), exports);
const pageInfoPlugin = (options, app) => {
const { themeConfig } = app.options;
const commentOptions = Object.keys(options).length > 0
? options
: themeConfig.comment || { type: 'disable' };
(0, vuepress_shared_1.addViteOptimizeDeps)(app, '@waline/client');
(0, vuepress_plugin_reading_time_1.useReadingTimePlugin)(app, { wordPerminute: options.wordPerminute });
(0, vuepress_plugin_sass_palette_1.usePalettePlugin)(app, { id: 'hope' });
return {
name: '@starzkg/vuepress-plugin-page-info',
alias: {
'@Waline': commentOptions.type === 'waline'
? utils_1.path.resolve(__dirname, '../client/components/Waline.js')
: '@starzkg/vuepress-shared/lib/esm/client/NoopModule.js',
},
define: () => ({
COMMENT_OPTIONS: {
hint: !themeConfig.pure,
...commentOptions,
},
PAGE_INFO_I18N: (0, vuepress_shared_1.getLocales)(app, i18n_1.pageInfoI18n, options.pageInfoLocale),
}),
clientAppEnhanceFiles: utils_1.path.resolve(__dirname, '../client/clientAppEnhance.js'),
};
// if (commentOptions.type === "vssue")
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
// config.plugins!.push(["@vssue/vuepress-plugin-vssue", commentOptions]);
};
exports.pageInfoPlugin = pageInfoPlugin;