vuepress-plugin-blog2
Advanced tools
Comparing version 2.0.0-alpha.38 to 2.0.0-alpha.39
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@mr-hope/vuepress-shared"),t=require("@vuepress/core");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=a(require("chokidar"));const o=new e.Logger("vuepress-plugin-blog2"),p=(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},r=e=>e.replace(/^\//,""),s=(e,a,n,p=!1)=>{const{category:s=[],slugify:i=(e=>e.replace(/[ _]/g,"-").toLowerCase())}=a;return Promise.all(s.map((async({key:a,getter:s,sorter:g=(()=>-1),path:l="",layout:u="Layout",itemPath:c="",itemLayout:y="Layout"},h)=>{if("string"!=typeof a||!a)return o.error(`Invalid 'key' option ${a} in 'category[${h}]'`),null;if("function"!=typeof s)return o.error(`Invalid 'getter' option in 'category[${h}]', it should be a function!`),null;e.env.isDebug&&o.info(`Generating ${a} category.\n`);const f={},d=[],m="function"==typeof c?c:e=>c.replace(/:key/g,i(a)).replace(/:name/g,i(e));for(const c in n){if(l){const n=`${c}${r(l.replace(/:key/g,i(a)))}`,s=await t.createPage(e,{path:n,frontmatter:{blog:{type:"category",key:a},layout:u}}),g=e.pages.findIndex((({path:e})=>e===n));-1===g?e.pages.push(s):e.pages[g].key!==s.key&&(e.pages.splice(g,1,s),p&&o.warn(`Overiding existed path ${n}`)),d.push(s.key),f[c]={path:s.path,map:{}}}else f[c]={path:"",map:{}};const{map:h}=f[c],_={};for(const i of n[c]){const n=s(i);for(const s of n){if(!h[s]){const n=m(s);if(n){const i=`${c}${r(n)}`,g=await t.createPage(e,{path:`${c}${r(n)}`,frontmatter:{blog:{type:"category",name:s,key:a},layout:y}}),l=e.pages.findIndex((({path:e})=>e===i));-1===l?e.pages.push(g):e.pages[l].key!==g.key&&(e.pages.splice(l,1,g),p&&o.warn(`Overiding existed path ${i}`)),d.push(g.key),h[s]={path:g.path,keys:[]}}else h[s]={path:"",keys:[]};_[s]=[]}_[s].push(i)}}for(const e in _)h[e].keys=_[e].sort(g).map((({key:e})=>e));if(e.env.isDebug){let e=`Route ${c} in ${a} cateogry:\n`;for(const t in h){const{path:a,keys:n}=h[t];e+=`name: ${t}; ${a?`path: ${a}; `:""}items: ${n.length}\n`}o.info(e)}}return{key:a,map:f,pageKeys:d}}))).then((async t=>{const a={},n=[];return t.filter((e=>null!==e)).forEach((({key:e,map:t,pageKeys:o})=>{a[e]=t,n.push(...o)})),await e.writeTemp("blog/category.js",`export const categoryMap = ${JSON.stringify(a)}\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&&o.info("All categories generated."),n}))},i=(e,a,n,p=!1)=>{const{type:s=[],slugify:i=(e=>e.replace(/[ _]/g,"-").toLowerCase())}=a;return Promise.all(s.map((async({key:a,sorter:s=(()=>-1),filter:g=(()=>!0),path:l="",layout:u="Layout"},c)=>{if("string"!=typeof a||!a)return o.error(`Invalid 'key' option ${a} in 'category[${c}]'`),null;const y={},h=[];e.env.isDebug&&o.info(`Generating ${a} type.\n`);for(const c in n){const f=n[c].filter(g).sort(s).map((({key:e})=>e));if(l){const n=`${c}${r(i(l.replace(/:key/g,a)))}`,s=await t.createPage(e,{path:n,frontmatter:{blog:{type:"type",key:a},layout:u}}),g=e.pages.findIndex((({path:e})=>e===n));-1===g?e.pages.push(s):e.pages[g].key!==s.key&&(e.pages.splice(g,1,s),p&&o.warn(`Overiding existed path ${n}`)),h.push(s.key),y[c]={path:s.path,keys:f},e.env.isDebug&&o.info(`Route ${c} in ${a} type: path: ${s.path}; items: ${f.length}\n`)}else y[c]={path:"",keys:f},e.env.isDebug&&o.info(`Route ${c} in ${a} type: items: ${f.length}\n`)}return{key:a,map:y,pageKeys:h}}))).then((async t=>{const a={},n=[];return t.filter((e=>null!==e)).forEach((({key:e,map:t,pageKeys:o})=>{a[e]=t,n.push(...o)})),await e.writeTemp("blog/type.js",`export const typeMap = ${JSON.stringify(a)}\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&&o.info("All types generated."),n}))},g=(a,r)=>{r.env.isDev&&e.addViteOptimizeDepsInclude(r,"@mr-hope/vuepress-shared/lib/client"),e.addViteSsrNoExternal(r,["@mr-hope/vuepress-shared","vuepress-plugin-blog2"]),e.addViteOptimizeDepsExclude(r,"vuepress-plugin-blog2");const{metaScope:g="_blog"}=a;let l=[];return{name:"vuepress-plugin-blog2",define:()=>({BLOG_META_SCOPE:g}),extendsPage(e){const{getInfo:t=(()=>({}))}=a;e.routeMeta={...""===g?t(e):{[g]:t(e)},...e.routeMeta}},onInitialized(e){const t=p(a,e);return Promise.all([s(e,a,t,!0).then((e=>{l.push(...e)})),i(e,a,t,!0).then((e=>{l.push(...e)}))]).then((()=>{e.env.isDebug&&o.info("temp file generated")}))},onWatched(e,r){if(a.hotReload){const g=n.default.watch("pages/**/*.js",{cwd:e.dir.temp(),ignoreInitial:!0}),u=()=>{const n=[],r=p(a,e);return Promise.all([s(e,a,r).then((e=>{n.push(...e)})),i(e,a,r).then((e=>{n.push(...e)}))]).then((async()=>{const a=l.filter((e=>!n.includes(e)));a.length?(e.env.isDebug&&o.info(`Removing following pages: ${a.toString()}`),a.forEach((t=>{e.pages.splice(e.pages.findIndex((({key:e})=>e===t)),1)})),await t.preparePagesComponents(e),await t.preparePagesData(e),await t.preparePagesRoutes(e)):n.length!==l.length&&(e.env.isDebug&&o.info("New pages detected"),await t.preparePagesComponents(e),await t.preparePagesData(e),await t.preparePagesRoutes(e)),l=n,e.env.isDebug&&o.info("temp file updated")}))};g.on("add",(()=>{u()})),g.on("change",(()=>{u()})),g.on("unlink",(()=>{u()})),r.push(g)}}}};exports.blog=e=>["blog2",e],exports.blogPlugin=g,exports.default=g; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@mr-hope/vuepress-shared"),t=require("@vuepress/core");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=a(require("chokidar"));const o=new e.Logger("vuepress-plugin-blog2"),p=(e,t)=>{const a={};Object.keys({"/":{},...t.options.locales}).forEach((e=>{a[e]=[]}));const{filter:n=(e=>Boolean(e.filePathRelative)&&!e.frontmatter.home)}=e;return t.pages.filter(n).forEach((e=>{a[e.pathLocale].push(e)})),a},r=e=>e.replace(/^\//,""),s=(e,a,n,p=!1)=>{const{category:s=[],slugify:i=(e=>e.replace(/[ _]/g,"-").toLowerCase())}=a;return Promise.all(s.map((async({key:a,getter:s,sorter:g=(()=>-1),path:l="",layout:c="Layout",itemPath:u="",itemLayout:y="Layout"},f)=>{if("string"!=typeof a||!a)return o.error(`Invalid 'key' option ${a} in 'category[${f}]'`),null;if("function"!=typeof s)return o.error(`Invalid 'getter' option in 'category[${f}]', it should be a function!`),null;e.env.isDebug&&o.info(`Generating ${a} category.\n`);const h={},d=[],m="function"==typeof u?u:e=>u.replace(/:key/g,i(a)).replace(/:name/g,i(e));for(const u in n){if(l){const n=`${u}${r(l.replace(/:key/g,i(a)))}`,s=await t.createPage(e,{path:n,frontmatter:{blog:{type:"category",key:a},layout:c}}),g=e.pages.findIndex((({path:e})=>e===n));-1===g?e.pages.push(s):e.pages[g].key!==s.key&&(e.pages.splice(g,1,s),p&&o.warn(`Overiding existed path ${n}`)),d.push(s.key),h[u]={path:s.path,map:{}}}else h[u]={path:"",map:{}};const{map:f}=h[u],_={};for(const i of n[u]){const n=s(i);for(const s of n){if(!f[s]){const n=m(s);if(n){const i=`${u}${r(n)}`,g=await t.createPage(e,{path:`${u}${r(n)}`,frontmatter:{blog:{type:"category",name:s,key:a},layout:y}}),l=e.pages.findIndex((({path:e})=>e===i));-1===l?e.pages.push(g):e.pages[l].key!==g.key&&(e.pages.splice(l,1,g),p&&o.warn(`Overiding existed path ${i}`)),d.push(g.key),f[s]={path:g.path,keys:[]}}else f[s]={path:"",keys:[]};_[s]=[]}_[s].push(i)}}for(const e in _)f[e].keys=_[e].sort(g).map((({key:e})=>e));if(e.env.isDebug){let e=`Route ${u} in ${a} cateogry:\n`;for(const t in f){const{path:a,keys:n}=f[t];e+=`name: ${t}; ${a?`path: ${a}; `:""}items: ${n.length}\n`}o.info(e)}}return{key:a,map:h,pageKeys:d}}))).then((async t=>{const a={},n=[];return t.filter((e=>null!==e)).forEach((({key:e,map:t,pageKeys:o})=>{a[e]=t,n.push(...o)})),await e.writeTemp("blog/category.js",`export const categoryMap = ${JSON.stringify(a)}\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&&o.info("All categories generated."),n}))},i=(e,a,n,p=!1)=>{const{type:s=[],slugify:i=(e=>e.replace(/[ _]/g,"-").toLowerCase())}=a;return Promise.all(s.map((async({key:a,sorter:s=(()=>-1),filter:g=(()=>!0),path:l="",layout:c="Layout"},u)=>{if("string"!=typeof a||!a)return o.error(`Invalid 'key' option ${a} in 'category[${u}]'`),null;const y={},f=[];e.env.isDebug&&o.info(`Generating ${a} type.\n`);for(const u in n){const h=n[u].filter(g).sort(s).map((({key:e})=>e));if(l){const n=`${u}${r(i(l.replace(/:key/g,a)))}`,s=await t.createPage(e,{path:n,frontmatter:{blog:{type:"type",key:a},layout:c}}),g=e.pages.findIndex((({path:e})=>e===n));-1===g?e.pages.push(s):e.pages[g].key!==s.key&&(e.pages.splice(g,1,s),p&&o.warn(`Overiding existed path ${n}`)),f.push(s.key),y[u]={path:s.path,keys:h},e.env.isDebug&&o.info(`Route ${u} in ${a} type: path: ${s.path}; items: ${h.length}\n`)}else y[u]={path:"",keys:h},e.env.isDebug&&o.info(`Route ${u} in ${a} type: items: ${h.length}\n`)}return{key:a,map:y,pageKeys:f}}))).then((async t=>{const a={},n=[];return t.filter((e=>null!==e)).forEach((({key:e,map:t,pageKeys:o})=>{a[e]=t,n.push(...o)})),await e.writeTemp("blog/type.js",`export const typeMap = ${JSON.stringify(a)}\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&&o.info("All types generated."),n}))},g=(a,r)=>{r.env.isDev&&e.addViteOptimizeDepsInclude(r,"@mr-hope/vuepress-shared/lib/client"),e.addViteSsrNoExternal(r,["@mr-hope/vuepress-shared","vuepress-plugin-blog2"]),e.addViteOptimizeDepsExclude(r,"vuepress-plugin-blog2");const{metaScope:g="_blog"}=a;let l=[];return{name:"vuepress-plugin-blog2",define:()=>({BLOG_META_SCOPE:g}),extendsPage(e){const{getInfo:t=(()=>({}))}=a;e.routeMeta={...""===g?t(e):{[g]:t(e)},...e.routeMeta}},onInitialized(e){const t=p(a,e);return Promise.all([s(e,a,t,!0).then((e=>{l.push(...e)})),i(e,a,t,!0).then((e=>{l.push(...e)}))]).then((()=>{e.env.isDebug&&o.info("temp file generated")}))},onWatched(e,r){if(a.hotReload){const g=n.default.watch("pages/**/*.js",{cwd:e.dir.temp(),ignoreInitial:!0}),c=()=>{const n=[],r=p(a,e);return Promise.all([s(e,a,r).then((e=>{n.push(...e)})),i(e,a,r).then((e=>{n.push(...e)}))]).then((async()=>{const a=l.filter((e=>!n.includes(e)));a.length?(e.env.isDebug&&o.info(`Removing following pages: ${a.toString()}`),a.forEach((t=>{e.pages.splice(e.pages.findIndex((({key:e})=>e===t)),1)})),await t.preparePagesComponents(e),await t.preparePagesData(e),await t.preparePagesRoutes(e)):n.length!==l.length&&(e.env.isDebug&&o.info("New pages detected"),await t.preparePagesComponents(e),await t.preparePagesData(e),await t.preparePagesRoutes(e)),l=n,e.env.isDebug&&o.info("temp file updated")}))};g.on("add",(()=>{c()})),g.on("change",(()=>{c()})),g.on("unlink",(()=>{c()})),r.push(g)}}}};exports.blog=e=>["blog2",e],exports.blogPlugin=g,exports.default=g; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "vuepress-plugin-blog2", | ||
"version": "2.0.0-alpha.38", | ||
"version": "2.0.0-alpha.39", | ||
"description": "Blog plugin for VuePress", | ||
@@ -45,3 +45,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@mr-hope/vuepress-shared": "2.0.0-alpha.38", | ||
"@mr-hope/vuepress-shared": "2.0.0-alpha.39", | ||
"@vuepress/client": "2.0.0-beta.35", | ||
@@ -55,3 +55,3 @@ "@vuepress/core": "2.0.0-beta.35", | ||
}, | ||
"gitHead": "0b629a9a729181863385f015e760adee841f6b4e" | ||
"gitHead": "46295cf6ddb109c7eab72859444fe2a8728045d3" | ||
} |
@@ -12,2 +12,13 @@ import { Logger } from "@mr-hope/vuepress-shared"; | ||
): PageMap => { | ||
const pageMap: PageMap = {}; | ||
// initialize pageMap | ||
Object.keys({ | ||
// make sure root locale exists | ||
"/": {}, | ||
...app.options.locales, | ||
}).forEach((path) => { | ||
pageMap[path] = []; | ||
}); | ||
const { | ||
@@ -17,6 +28,4 @@ filter = (page): boolean => | ||
} = options; | ||
const pageMap: PageMap = {}; | ||
app.pages.filter(filter).forEach((page) => { | ||
if (!pageMap[page.pathLocale]) pageMap[page.pathLocale] = []; | ||
pageMap[page.pathLocale].push(page); | ||
@@ -23,0 +32,0 @@ }); |
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
53114
1126
+ Added@mr-hope/vuepress-shared@2.0.0-alpha.39(transitive)
+ Added@types/node@22.10.0(transitive)
+ Addedmagic-string@0.30.14(transitive)
+ Addedundici-types@6.20.0(transitive)
+ Addedvue-router@4.5.0(transitive)
- Removed@mr-hope/vuepress-shared@2.0.0-alpha.38(transitive)
- Removed@types/node@22.9.1(transitive)
- Removedmagic-string@0.30.13(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedvue-router@4.4.5(transitive)