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

26 lines
909 B
JavaScript

import { colors } from 'vuepress/utils';
import { appendSEO } from './appendSEO.js';
import { generateDescription } from './generateDescription.js';
import { generateRobotsTxt } from './generateRobotsTxt.js';
import { logger, PLUGIN_NAME } from './utils/index.js';
export const seoPlugin = (options) => (app) => {
if (app.env.isDebug)
logger.info('Options:', options);
const plugin = { name: PLUGIN_NAME };
if (!options.hostname) {
logger.error(`Option ${colors.magenta('hostname')} is required!`);
return plugin;
}
return {
...plugin,
extendsPage: (page) => {
if (page.frontmatter.seo !== false)
generateDescription(app, page, options.autoDescription !== false);
},
onInitialized: (app) => {
appendSEO(app, options);
},
onGenerated: (app) => generateRobotsTxt(app),
};
};