vuepress-plugin-blog2
Advanced tools
Comparing version 2.0.0-rc.15 to 2.0.0-rc.16
@@ -1,2 +0,2 @@ | ||
import{watch as B}from"chokidar";import{createPage as U,preparePageComponent as V,preparePageData as A,preparePagesComponents as G,preparePagesData as K,preparePagesRoutes as j}from"vuepress/core";import{Logger as F,keys as J,isString as C,isFunction as T,removeLeadingSlash as I,createConverter as z,checkVersion as W,getPageExcerpt as q,addViteSsrNoExternal as Q}from"vuepress-shared/node";import{colors as m}from"vuepress/utils";const L="vuepress-plugin-blog2",s=new F(L),N=({options:t,pages:_},d)=>{const k=J(t.locales),u={};return(k.length?k:["/"]).forEach(a=>{u[a]=[]}),_.filter(d).forEach(a=>{a.path!=="/404.html"&&u[a.pathLocale].push(a)}),u},X=` | ||
import{watch as B}from"chokidar";import{createPage as U,preparePageComponent as V,preparePageData as A,preparePagesComponents as G,preparePagesData as K,preparePagesRoutes as j}from"vuepress/core";import{Logger as F,keys as J,isString as C,isFunction as L,removeLeadingSlash as I,createConverter as z,getPageExcerpt as W,addViteSsrNoExternal as q}from"vuepress-shared/node";import{colors as f}from"vuepress/utils";const T="vuepress-plugin-blog2",s=new F(T),N=({options:t,pages:_},k)=>{const d=J(t.locales),u={};return(d.length?d:["/"]).forEach(a=>{u[a]=[]}),_.filter(k).forEach(a=>{a.path!=="/404.html"&&u[a.pathLocale].push(a)}),u},Q=` | ||
if (import.meta.webpackHot) { | ||
@@ -13,8 +13,8 @@ import.meta.webpackHot.accept(); | ||
`,O=(t,{category:_,slugify:d},k,u=!1)=>Promise.all(_.map(async({key:a,getter:h,sorter:$=()=>-1,path:l="/:key/",layout:v="Layout",frontmatter:w=()=>({}),itemPath:E="/:key/:name/",itemLayout:M="Layout",itemFrontmatter:b=()=>({})},g)=>{if(!C(a)||!a.length)return s.error(`Invalid ${m.magenta("key")} option ${m.cyan(a)} in ${m.cyan(`category[${g}]`)}`),null;if(!T(h))return s.error(`Invalid ${m.magenta("getter")} option in "${m.cyan(`category[${g}]`)}", it should be a function!`),null;t.env.isDebug&&s.info(`Generating ${m.cyan(a)} category. | ||
`);const e={},c=[],o=T(E)?E:C(E)?p=>E.replace(/:key/g,d(a)).replace(/:name/g,d(p)):()=>null;for(const p in k){if(l){const r=`${p}${I(l.replace(/:key/g,d(a)))}`,i=await U(t,{path:encodeURI(r),frontmatter:{...w(p),blog:{type:"category",key:a},layout:v}}),n=t.pages.findIndex(({path:f})=>f===r);n===-1?t.pages.push(i):t.pages[n].key!==i.key&&(t.pages.splice(n,1,i),u&&s.warn(`Overriding existed path ${m.cyan(r)}`)),c.push(i.key),e[p]={path:i.path,map:{}}}else e[p]={path:"",map:{}};const{map:y}=e[p],x={};for(const r of k[p]){const i=h(r);for(const n of i){if(!y[n]){const f=o(n);if(f){const D=`${p}${I(f)}`,R=await U(t,{path:`${p}${I(f)}`,frontmatter:{...b(n,p),blog:{type:"category",name:n,key:a},layout:M}}),P=t.pages.findIndex(({path:H})=>H===D);P===-1?t.pages.push(R):t.pages[P].key!==R.key&&(t.pages.splice(P,1,R),u&&s.warn(`Overriding existed path ${D}`)),c.push(R.key),y[n]={path:R.path,keys:[]}}else y[n]={path:"",keys:[]};x[n]=[]}x[n].push(r)}}for(const r in x)y[r].keys=x[r].sort($).map(({key:i})=>i);if(t.env.isDebug){let r=`Route ${p} in ${a} category: | ||
`;for(const i in y){const{path:n,keys:f}=y[i];r+=`name: ${i}; ${n?`path: ${n}; `:""}items: ${f.length} | ||
`,O=(t,{category:_,slugify:k},d,u=!1)=>Promise.all(_.map(async({key:a,getter:h,sorter:$=()=>-1,path:l="/:key/",layout:v="Layout",frontmatter:w=()=>({}),itemPath:E="/:key/:name/",itemLayout:M="Layout",itemFrontmatter:b=()=>({})},g)=>{if(!C(a)||!a.length)return s.error(`Invalid ${f.magenta("key")} option ${f.cyan(a)} in ${f.cyan(`category[${g}]`)}`),null;if(!L(h))return s.error(`Invalid ${f.magenta("getter")} option in "${f.cyan(`category[${g}]`)}", it should be a function!`),null;t.env.isDebug&&s.info(`Generating ${f.cyan(a)} category. | ||
`);const e={},c=[],o=L(E)?E:C(E)?p=>E.replace(/:key/g,k(a)).replace(/:name/g,k(p)):()=>null;for(const p in d){if(l){const r=`${p}${I(l.replace(/:key/g,k(a)))}`,i=await U(t,{path:encodeURI(r),frontmatter:{...w(p),blog:{type:"category",key:a},layout:v}}),n=t.pages.findIndex(({path:m})=>m===r);n===-1?t.pages.push(i):t.pages[n].key!==i.key&&(t.pages.splice(n,1,i),u&&s.warn(`Overriding existed path ${f.cyan(r)}`)),c.push(i.key),e[p]={path:i.path,map:{}}}else e[p]={path:"",map:{}};const{map:y}=e[p],x={};for(const r of d[p]){const i=h(r);for(const n of i){if(!y[n]){const m=o(n);if(m){const D=`${p}${I(m)}`,R=await U(t,{path:`${p}${I(m)}`,frontmatter:{...b(n,p),blog:{type:"category",name:n,key:a},layout:M}}),P=t.pages.findIndex(({path:H})=>H===D);P===-1?t.pages.push(R):t.pages[P].key!==R.key&&(t.pages.splice(P,1,R),u&&s.warn(`Overriding existed path ${D}`)),c.push(R.key),y[n]={path:R.path,keys:[]}}else y[n]={path:"",keys:[]};x[n]=[]}x[n].push(r)}}for(const r in x)y[r].keys=x[r].sort($).map(({key:i})=>i);if(t.env.isDebug){let r=`Route ${p} in ${a} category: | ||
`;for(const i in y){const{path:n,keys:m}=y[i];r+=`name: ${i}; ${n?`path: ${n}; `:""}items: ${m.length} | ||
`}s.info(r)}}return{key:a,map:e,pageKeys:c}})).then(async a=>{const h={},$=[];return a.filter(l=>l!==null).forEach(({key:l,map:v,pageKeys:w})=>{h[l]=v,$.push(...w)}),await t.writeTemp("blog/category.js",`export const categoryMap = ${JSON.stringify(h)}; | ||
${t.env.isDev?X:""} | ||
`),t.env.isDebug&&s.info("All categories generated."),$}),Y=t=>{const{deprecatedLogger:_}=z("blog2");_({options:t,old:"customElements",new:"isCustomElement"})},Z=` | ||
${t.env.isDev?Q:""} | ||
`),t.env.isDebug&&s.info("All categories generated."),$}),X=t=>{const{deprecatedLogger:_}=z("blog2");_({options:t,old:"customElements",new:"isCustomElement"})},Y=` | ||
if (import.meta.webpackHot) { | ||
@@ -30,8 +30,8 @@ import.meta.webpackHot.accept(); | ||
}); | ||
`,S=(t,{type:_,slugify:d},k,u=!1)=>Promise.all(_.map(async({key:a,sorter:h=()=>-1,filter:$=()=>!0,path:l="/:key/",layout:v="Layout",frontmatter:w=()=>({})},E)=>{if(!C(a)||!a.length)return s.error(`Invalid ${m.magenta("key")} option ${m.cyan(a)} in ${m.cyan(`type[${E}]`)}`),null;const M={},b=[];t.env.isDebug&&s.info(`Generating ${m.cyan(a)} type. | ||
`);for(const g in k){const e=k[g].filter($).sort(h).map(({key:c})=>c);if(l){const c=`${g}${I(d(l.replace(/:key/g,a)))}`,o=await U(t,{path:encodeURI(c),frontmatter:{...w(g),blog:{type:"type",key:a},layout:v}}),p=t.pages.findIndex(({path:y})=>y===c);p===-1?t.pages.push(o):t.pages[p].key!==o.key&&(t.pages.splice(p,1,o),u&&s.warn(`Overriding existed path ${m.cyan(c)}`)),b.push(o.key),M[g]={path:o.path,keys:e},t.env.isDebug&&s.info(`Route ${g} in ${a} type: path: ${o.path}; items: ${e.length} | ||
`,S=(t,{type:_,slugify:k},d,u=!1)=>Promise.all(_.map(async({key:a,sorter:h=()=>-1,filter:$=()=>!0,path:l="/:key/",layout:v="Layout",frontmatter:w=()=>({})},E)=>{if(!C(a)||!a.length)return s.error(`Invalid ${f.magenta("key")} option ${f.cyan(a)} in ${f.cyan(`type[${E}]`)}`),null;const M={},b=[];t.env.isDebug&&s.info(`Generating ${f.cyan(a)} type. | ||
`);for(const g in d){const e=d[g].filter($).sort(h).map(({key:c})=>c);if(l){const c=`${g}${I(k(l.replace(/:key/g,a)))}`,o=await U(t,{path:encodeURI(c),frontmatter:{...w(g),blog:{type:"type",key:a},layout:v}}),p=t.pages.findIndex(({path:y})=>y===c);p===-1?t.pages.push(o):t.pages[p].key!==o.key&&(t.pages.splice(p,1,o),u&&s.warn(`Overriding existed path ${f.cyan(c)}`)),b.push(o.key),M[g]={path:o.path,keys:e},t.env.isDebug&&s.info(`Route ${g} in ${a} type: path: ${o.path}; items: ${e.length} | ||
`)}else M[g]={path:"",keys:e},t.env.isDebug&&s.info(`Route ${g} in ${a} type: items: ${e.length} | ||
`)}return{key:a,map:M,pageKeys:b}})).then(async a=>{const h={},$=[];return a.filter(l=>l!==null).forEach(({key:l,map:v,pageKeys:w})=>{h[l]=v,$.push(...w)}),await t.writeTemp("blog/type.js",`export const typeMap = ${JSON.stringify(h)}; | ||
${t.env.isDev?Z:""} | ||
`),t.env.isDebug&&s.info("All types generated."),$}),ee=(t,_=!0)=>d=>{_&&Y(t),W(d,L,"2.0.0-rc.2");const{getInfo:k=()=>({}),filter:u=e=>!!e.filePathRelative&&!e.frontmatter.home,metaScope:a="_blog",excerpt:h=!0,excerptSeparator:$="<!-- more -->",excerptLength:l=300,excerptFilter:v=u,isCustomElement:w=()=>!1,category:E=[],type:M=[],slugify:b=e=>e.replace(/[ _]/g,"-").replace(/[:?*|\\/<>]/g,"").toLowerCase()}=t;let g=[];return d.env.isDebug&&s.info("Options:",t),{name:L,define:()=>({BLOG_META_SCOPE:a}),extendsPage:e=>{h&&v(e)&&(e.data.excerpt=q(d,e,{isCustomElement:w,excerptSeparator:$,excerptLength:l}))},extendsBundlerOptions:(e,c)=>{Q(e,c,"vuepress-shared")},onInitialized:e=>{const c=N(e,u);return e.pages.filter(u).forEach(o=>{o.routeMeta={...a===""?k(o):{[a]:k(o)},...o.routeMeta}}),Promise.all([O(e,{category:E,slugify:b},c,!0).then(o=>{g.push(...o)}),S(e,{type:M,slugify:b},c,!0).then(o=>{g.push(...o)})]).then(()=>{e.env.isDebug&&s.info("temp file generated")})},onWatched:(e,c)=>{if("hotReload"in t?t.hotReload:e.env.isDebug){const o=B("pages/**/*.js",{cwd:e.dir.temp(),ignoreInitial:!0}),p=()=>{const y=[],x=N(e,u);return Promise.all([O(e,{category:E,slugify:b},x).then(r=>{y.push(...r)}),S(e,{type:M,slugify:b},x).then(r=>{y.push(...r)})]).then(async()=>{const r=g.filter(n=>!y.includes(n)),i=y.filter(n=>!g.includes(n));i.length&&(e.env.isDebug&&s.info(`New pages detected: ${i.toString()}`),await Promise.all(i.map(async n=>{const f=e.pages.find(({key:D})=>D===n);await V(e,f),await A(e,f)}))),r.length&&(e.env.isDebug&&s.info(`Removing following pages: ${r.toString()}`),r.forEach(n=>{e.pages.splice(e.pages.findIndex(({key:f})=>f===n),1)})),(r.length||i.length)&&(await G(e),await K(e),await j(e)),g=y,e.env.isDebug&&s.info("temp file updated")})};o.on("add",()=>{p()}),o.on("change",()=>{p()}),o.on("unlink",()=>{p()}),c.push(o)}}}};export{ee as blogPlugin}; | ||
${t.env.isDev?Y:""} | ||
`),t.env.isDebug&&s.info("All types generated."),$}),Z=(t,_=!0)=>k=>{_&&X(t);const{getInfo:d=()=>({}),filter:u=e=>!!e.filePathRelative&&!e.frontmatter.home,metaScope:a="_blog",excerpt:h=!0,excerptSeparator:$="<!-- more -->",excerptLength:l=300,excerptFilter:v=u,isCustomElement:w=()=>!1,category:E=[],type:M=[],slugify:b=e=>e.replace(/[ _]/g,"-").replace(/[:?*|\\/<>]/g,"").toLowerCase()}=t;let g=[];return k.env.isDebug&&s.info("Options:",t),{name:T,define:()=>({BLOG_META_SCOPE:a}),extendsPage:e=>{h&&v(e)&&(e.data.excerpt=W(k,e,{isCustomElement:w,excerptSeparator:$,excerptLength:l}))},extendsBundlerOptions:(e,c)=>{q(e,c,"vuepress-shared")},onInitialized:e=>{const c=N(e,u);return e.pages.filter(u).forEach(o=>{o.routeMeta={...a===""?d(o):{[a]:d(o)},...o.routeMeta}}),Promise.all([O(e,{category:E,slugify:b},c,!0).then(o=>{g.push(...o)}),S(e,{type:M,slugify:b},c,!0).then(o=>{g.push(...o)})]).then(()=>{e.env.isDebug&&s.info("temp file generated")})},onWatched:(e,c)=>{if("hotReload"in t?t.hotReload:e.env.isDebug){const o=B("pages/**/*.js",{cwd:e.dir.temp(),ignoreInitial:!0}),p=()=>{const y=[],x=N(e,u);return Promise.all([O(e,{category:E,slugify:b},x).then(r=>{y.push(...r)}),S(e,{type:M,slugify:b},x).then(r=>{y.push(...r)})]).then(async()=>{const r=g.filter(n=>!y.includes(n)),i=y.filter(n=>!g.includes(n));i.length&&(e.env.isDebug&&s.info(`New pages detected: ${i.toString()}`),await Promise.all(i.map(async n=>{const m=e.pages.find(({key:D})=>D===n);await V(e,m),await A(e,m)}))),r.length&&(e.env.isDebug&&s.info(`Removing following pages: ${r.toString()}`),r.forEach(n=>{e.pages.splice(e.pages.findIndex(({key:m})=>m===n),1)})),(r.length||i.length)&&(await G(e),await K(e),await j(e)),g=y,e.env.isDebug&&s.info("temp file updated")})};o.on("add",()=>{p()}),o.on("change",()=>{p()}),o.on("unlink",()=>{p()}),c.push(o)}}}};export{Z as blogPlugin}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "vuepress-plugin-blog2", | ||
"version": "2.0.0-rc.15", | ||
"version": "2.0.0-rc.16", | ||
"description": "Blog plugin for VuePress", | ||
@@ -41,3 +41,3 @@ "keywords": [ | ||
"vue-router": "^4.2.5", | ||
"vuepress-shared": "2.0.0-rc.15" | ||
"vuepress-shared": "2.0.0-rc.16" | ||
}, | ||
@@ -44,0 +44,0 @@ "peerDependencies": { |
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
61022
+ Addedvuepress-shared@2.0.0-rc.16(transitive)
- Removedvuepress-shared@2.0.0-rc.15(transitive)
Updatedvuepress-shared@2.0.0-rc.16