vuepress-plugin-blog2
Advanced tools
Comparing version 2.0.0-alpha.29 to 2.0.0-alpha.30
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@vuepress/core");const t=new(require("@mr-hope/vuepress-shared").Logger)("vuepress-plugin-blog2"),a=(e,t)=>{const{filter:a=(e=>Boolean(e.filePathRelative)&&!e.frontmatter.home)}=e,o={};return t.pages.filter(a).forEach((e=>{o[e.pathLocale]||(o[e.pathLocale]=[]),o[e.pathLocale].push(e)})),o},o=e=>e.replace(/^\//,""),n=(a,n,r)=>{const{category:p=[],slugify:s=(e=>e.replace(/[ _]/g,"-").toLowerCase())}=n;return Promise.all(p.map((async({key:n,getter:p,sorter:i=(()=>-1),path:g="",layout:l="Layout",itemPath:u="",itemLayout:c="Layout"},y)=>{if("string"!=typeof n||!n)return t.error(`Invalid 'key' option ${n} in 'category[${y}]'`),null;if("function"!=typeof p)return t.error(`Invalid 'getter' option in 'category[${y}]', it should be a function!`),null;a.env.isDebug&&t.info(`Generating ${n} category.\n`);const h={},f=[],m="function"==typeof u?u:e=>u.replace(/:key/g,s(n)).replace(/:name/g,s(e));for(const u in r){if(g){const t=await e.createPage(a,{path:`${u}${o(g.replace(/:key/g,s(n)))}`,frontmatter:{blog:{type:"category",key:n},layout:l}});a.pages.push(t),f.push(t.path),h[u]={path:t.path,map:{}}}else h[u]={path:"",map:{}};const{map:y}=h[u],_={};for(const t of r[u]){const r=p(t);for(const p of r){if(!y[p]){const t=m(p);if(t){const r=await e.createPage(a,{path:`${u}${o(t)}`,frontmatter:{blog:{type:"category",name:p,key:n},layout:c}});a.pages.push(r),f.push(r.path),y[p]={path:r.path,keys:[]}}else y[p]={path:"",keys:[]};_[p]=[]}_[p].push(t)}}for(const e in _)y[e].keys=_[e].sort(i).map((({key:e})=>e));if(a.env.isDebug){let e=`Route ${u} in ${n} cateogry:\n`;for(const t in y){const{path:a,keys:o}=y[t];e+=`name: ${t}; ${a?`path: ${a}; `:""}items: ${o.length}`}t.info(e)}}return{key:n,map:h,pagePaths:f}}))).then((async e=>{const o={},n=[];return e.filter((e=>null!==e)).forEach((({key:e,map:t,pagePaths:a})=>{o[e]=t,n.push(...a)})),await a.writeTemp("blog/category.js",`export const categoryMap = ${JSON.stringify(o)}\n\nif (import.meta.webpackHot) {\n import.meta.webpackHot.accept()\n if (__VUE_HMR_RUNTIME__.updateBlogCategory) {\n __VUE_HMR_RUNTIME__.updateBlogCategory(categoryMap)\n }\n}\n\nif (import.meta.hot) {\n import.meta.hot.accept(({ categoryMap }) => {\n __VUE_HMR_RUNTIME__.updateBlogCategory(categoryMap)\n })\n}\n`),a.env.isDebug&&t.info("All types generated."),n}))},r=(a,n,r)=>{const{type:p=[],slugify:s=(e=>e.replace(/[ _]/g,"-").toLowerCase())}=n;return Promise.all(p.map((async({key:n,sorter:p=(()=>-1),filter:i=(()=>!0),path:g="",layout:l="Layout"},u)=>{if("string"!=typeof n||!n)return t.error(`Invalid 'key' option ${n} in 'category[${u}]'`),null;const c={},y=[];a.env.isDebug&&t.info(`Generating ${n} type.\n`);for(const u in r){const h=r[u].filter(i).sort(p).map((({key:e})=>e));if(g){const r=await e.createPage(a,{path:`${u}${o(s(g.replace(/:key/g,n)))}`,frontmatter:{blog:{type:"type",key:n},layout:l}});a.pages.push(r),y.push(r.path),c[u]={path:r.path,keys:h},a.env.isDebug&&t.info(`Route ${u} in ${n} type: path: ${r.path}; items: ${h.length}`)}else c[u]={path:"",keys:h},a.env.isDebug&&t.info(`Route ${u} in ${n} type: items: ${h.length}`)}return{key:n,map:c,pagePaths:y}}))).then((async e=>{const o={},n=[];return e.filter((e=>null!==e)).forEach((({key:e,map:t,pagePaths:a})=>{o[e]=t,n.push(...a)})),await a.writeTemp("blog/type.js",`export const typeMap = ${JSON.stringify(o)}\n\nif (import.meta.webpackHot) {\n import.meta.webpackHot.accept()\n if (__VUE_HMR_RUNTIME__.updateBlogType) {\n __VUE_HMR_RUNTIME__.updateBlogType(typeMap)\n }\n}\n\nif (import.meta.hot) {\n import.meta.hot.accept(({ typeMap }) => {\n __VUE_HMR_RUNTIME__.updateBlogType(typeMap)\n })\n}\n`),a.env.isDebug&&t.info("All types generated."),n}))},p=o=>{const{getInfo:p=(()=>({})),metaScope:s="_blog"}=o;let i=[];return{name:"vuepress-plugin-blog2",define:()=>({BLOG_META_SCOPE:s}),extendsPage(e){e.routeMeta={...""===s?p(e):{[s]:p(e)},...e.routeMeta}},onInitialized(e){const p=a(o,e);return Promise.all([n(e,o,p).then((e=>{i.push(...e)})),r(e,o,p).then((e=>{i.push(...e)}))]).then((()=>{e.env.isDebug&&t.info("temp file generated")}))},onWatched(p){const s=[],g=a(o,p);return Promise.all([n(p,o,g).then((e=>{s.push(...e)})),r(p,o,g).then((e=>{s.push(...e)}))]).then((async()=>{if(s.length!==i.length)await e.preparePagesComponents(p),await e.preparePagesData(p),await e.preparePagesRoutes(p);else for(const t of s)i.includes(t)||(await e.preparePagesComponents(p),await e.preparePagesData(p),await e.preparePagesRoutes(p));i=s,p.env.isDebug&&t.info("temp file updated")}))}}};exports.blog=e=>["blog2",e],exports.blogPlugin=p,exports.default=p; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@mr-hope/vuepress-shared"),t=require("@vuepress/core");const a=new e.Logger("vuepress-plugin-blog2"),n=(e,t)=>{const{filter:a=(e=>Boolean(e.filePathRelative)&&!e.frontmatter.home)}=e,n={};return t.pages.filter(a).forEach((e=>{n[e.pathLocale]||(n[e.pathLocale]=[]),n[e.pathLocale].push(e)})),n},o=e=>e.replace(/^\//,""),r=(e,n,r)=>{const{category:p=[],slugify:s=(e=>e.replace(/[ _]/g,"-").toLowerCase())}=n;return Promise.all(p.map((async({key:n,getter:p,sorter:i=(()=>-1),path:l="",layout:g="Layout",itemPath:u="",itemLayout:c="Layout"},y)=>{if("string"!=typeof n||!n)return a.error(`Invalid 'key' option ${n} in 'category[${y}]'`),null;if("function"!=typeof p)return a.error(`Invalid 'getter' option in 'category[${y}]', it should be a function!`),null;e.env.isDebug&&a.info(`Generating ${n} category.\n`);const h={},f=[],m="function"==typeof u?u:e=>u.replace(/:key/g,s(n)).replace(/:name/g,s(e));for(const u in r){if(l){const a=await t.createPage(e,{path:`${u}${o(l.replace(/:key/g,s(n)))}`,frontmatter:{blog:{type:"category",key:n},layout:g}});e.pages.push(a),f.push(a.path),h[u]={path:a.path,map:{}}}else h[u]={path:"",map:{}};const{map:y}=h[u],_={};for(const a of r[u]){const r=p(a);for(const p of r){if(!y[p]){const a=m(p);if(a){const r=await t.createPage(e,{path:`${u}${o(a)}`,frontmatter:{blog:{type:"category",name:p,key:n},layout:c}});e.pages.push(r),f.push(r.path),y[p]={path:r.path,keys:[]}}else y[p]={path:"",keys:[]};_[p]=[]}_[p].push(a)}}for(const e in _)y[e].keys=_[e].sort(i).map((({key:e})=>e));if(e.env.isDebug){let e=`Route ${u} in ${n} cateogry:\n`;for(const t in y){const{path:a,keys:n}=y[t];e+=`name: ${t}; ${a?`path: ${a}; `:""}items: ${n.length}`}a.info(e)}}return{key:n,map:h,pagePaths:f}}))).then((async t=>{const n={},o=[];return t.filter((e=>null!==e)).forEach((({key:e,map:t,pagePaths:a})=>{n[e]=t,o.push(...a)})),await e.writeTemp("blog/category.js",`export const categoryMap = ${JSON.stringify(n)}\n\nif (import.meta.webpackHot) {\n import.meta.webpackHot.accept()\n if (__VUE_HMR_RUNTIME__.updateBlogCategory) {\n __VUE_HMR_RUNTIME__.updateBlogCategory(categoryMap)\n }\n}\n\nif (import.meta.hot) {\n import.meta.hot.accept(({ categoryMap }) => {\n __VUE_HMR_RUNTIME__.updateBlogCategory(categoryMap)\n })\n}\n`),e.env.isDebug&&a.info("All types generated."),o}))},p=(e,n,r)=>{const{type:p=[],slugify:s=(e=>e.replace(/[ _]/g,"-").toLowerCase())}=n;return Promise.all(p.map((async({key:n,sorter:p=(()=>-1),filter:i=(()=>!0),path:l="",layout:g="Layout"},u)=>{if("string"!=typeof n||!n)return a.error(`Invalid 'key' option ${n} in 'category[${u}]'`),null;const c={},y=[];e.env.isDebug&&a.info(`Generating ${n} type.\n`);for(const u in r){const h=r[u].filter(i).sort(p).map((({key:e})=>e));if(l){const r=await t.createPage(e,{path:`${u}${o(s(l.replace(/:key/g,n)))}`,frontmatter:{blog:{type:"type",key:n},layout:g}});e.pages.push(r),y.push(r.path),c[u]={path:r.path,keys:h},e.env.isDebug&&a.info(`Route ${u} in ${n} type: path: ${r.path}; items: ${h.length}`)}else c[u]={path:"",keys:h},e.env.isDebug&&a.info(`Route ${u} in ${n} type: items: ${h.length}`)}return{key:n,map:c,pagePaths:y}}))).then((async t=>{const n={},o=[];return t.filter((e=>null!==e)).forEach((({key:e,map:t,pagePaths:a})=>{n[e]=t,o.push(...a)})),await e.writeTemp("blog/type.js",`export const typeMap = ${JSON.stringify(n)}\n\nif (import.meta.webpackHot) {\n import.meta.webpackHot.accept()\n if (__VUE_HMR_RUNTIME__.updateBlogType) {\n __VUE_HMR_RUNTIME__.updateBlogType(typeMap)\n }\n}\n\nif (import.meta.hot) {\n import.meta.hot.accept(({ typeMap }) => {\n __VUE_HMR_RUNTIME__.updateBlogType(typeMap)\n })\n}\n`),e.env.isDebug&&a.info("All types generated."),o}))},s=(o,s)=>{s.env.isDev&&e.addViteOptimizeDeps(s,"@mr-hope/vuepress-shared/lib/client"),s.env.isBuild&&e.addViteSsrNoExternal(s,"@mr-hope/vuepress-shared/lib/client");const{metaScope:i="_blog"}=o;let l=[];return{name:"vuepress-plugin-blog2",define:()=>({BLOG_META_SCOPE:i}),extendsPage(e){const{getInfo:t=(()=>({}))}=o;e.routeMeta={...""===i?t(e):{[i]:t(e)},...e.routeMeta}},onInitialized(e){const t=n(o,e);return Promise.all([r(e,o,t).then((e=>{l.push(...e)})),p(e,o,t).then((e=>{l.push(...e)}))]).then((()=>{e.env.isDebug&&a.info("temp file generated")}))},onWatched(e){const s=[],i=n(o,e);return Promise.all([r(e,o,i).then((e=>{s.push(...e)})),p(e,o,i).then((e=>{s.push(...e)}))]).then((async()=>{if(s.length!==l.length)await t.preparePagesComponents(e),await t.preparePagesData(e),await t.preparePagesRoutes(e);else for(const a of s)l.includes(a)||(await t.preparePagesComponents(e),await t.preparePagesData(e),await t.preparePagesRoutes(e));l=s,e.env.isDebug&&a.info("temp file updated")}))}}};exports.blog=e=>["blog2",e],exports.blogPlugin=s,exports.default=s; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "vuepress-plugin-blog2", | ||
"version": "2.0.0-alpha.29", | ||
"version": "2.0.0-alpha.30", | ||
"description": "Blog plugin for VuePress", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@mr-hope/vuepress-shared": "2.0.0-alpha.29", | ||
"@mr-hope/vuepress-shared": "2.0.0-alpha.30", | ||
"@vuepress/client": "2.0.0-beta.35", | ||
@@ -55,3 +55,3 @@ "@vuepress/core": "2.0.0-beta.35", | ||
}, | ||
"gitHead": "bf211ea2d600320632bef69091d4fc3672902c5b" | ||
"gitHead": "bdf89753c00522d9c05ddbb5ca081627912db2db" | ||
} |
import { | ||
addViteOptimizeDeps, | ||
addViteSsrNoExternal, | ||
} from "@mr-hope/vuepress-shared"; | ||
import { | ||
preparePagesComponents, | ||
@@ -13,6 +17,10 @@ preparePagesData, | ||
export const blogPlugin: Plugin<BlogOptions> = (options) => { | ||
const { getInfo = (): Record<string, never> => ({}), metaScope = "_blog" } = | ||
options; | ||
export const blogPlugin: Plugin<BlogOptions> = (options, app) => { | ||
if (app.env.isDev) | ||
addViteOptimizeDeps(app, "@mr-hope/vuepress-shared/lib/client"); | ||
if (app.env.isBuild) | ||
addViteSsrNoExternal(app, "@mr-hope/vuepress-shared/lib/client"); | ||
const { metaScope = "_blog" } = options; | ||
let generatePages: string[] = []; | ||
@@ -28,2 +36,4 @@ | ||
extendsPage(page): void { | ||
const { getInfo = (): Record<string, never> => ({}) } = options; | ||
page.routeMeta = { | ||
@@ -30,0 +40,0 @@ ...(metaScope === "" ? getInfo(page) : { [metaScope]: getInfo(page) }), |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47041
1021
+ Added@mr-hope/vuepress-shared@2.0.0-alpha.30(transitive)
- Removed@mr-hope/vuepress-shared@2.0.0-alpha.29(transitive)