internal-layout-components

布局样式插件

布局如何为默认的,这个在这里有解答,注意是从主题包中获取的,如果没有就取默认的 404layout

module.exports = (options, ctx) => {
  return {
    name: "@vuepress/internal-layout-components",

    async clientDynamicModules() {
      const componentNames = Object.keys(ctx.themeAPI.layoutComponentMap);
      const code = `export default {\n${componentNames
        .map(
          name =>
            `  ${JSON.stringify(name)}: () => import(${JSON.stringify(
              ctx.themeAPI.layoutComponentMap[name].path
            )})`
        )
        .join(",\n")} \n}`;
      return {
        name: "layout-components.js",
        content: code,
        dirname: "internal"
      };
    }
  };
};

temp 生成的对应 layout-components 文件

/**
 * Generated by "@vuepress/internal-layout-components"
 */
export default {
  NotFound: () =>
    import(
      "/Users/xiangxiao/Documents/work/workspace/vuepress-analysis/node_modules/@vuepress/theme-default/layouts/404.vue"
    ),
  Layout: () =>
    import(
      "/Users/xiangxiao/Documents/work/workspace/vuepress-analysis/node_modules/@vuepress/theme-default/layouts/Layout.vue"
    )
};