New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vuepress-plugin-sitemap2

Package Overview
Dependencies
Maintainers
1
Versions
307
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuepress-plugin-sitemap2 - npm Package Compare versions

Comparing version

to
2.0.0-rc.16

10

lib/node/index.js

@@ -1,6 +0,6 @@

import{getDirname as b,path as O,colors as y,fs as c}from"vuepress/utils";import{createConverter as P,ensureEndingSlash as U,Logger as D,isLinkHttp as M,removeEndingSlash as F,removeLeadingSlash as S,checkVersion as G}from"vuepress-shared/node";import{SitemapStream as N}from"sitemap";const k=t=>{const{deprecatedLogger:e}=P("sitemap");e({options:t,old:"urls",new:"extraUrls"}),e({options:t,old:"exclude",new:"excludeUrls"}),e({options:t,old:"outFile",new:"sitemapFilename"}),e({options:t,old:"dateFormatter",new:"modifyTimeGetter"})},q=b(import.meta.url),A=U(O.resolve(q,"../../templates")),L="vuepress-plugin-sitemap2",r=new D(L),v=[],E=({path:t,pathLocale:e})=>({defaultPath:t.replace(e,"/"),pathLocale:e}),X=(t,e)=>{const{changefreq:l="daily",excludeUrls:p=["/404.html"],modifyTimeGetter:d=a=>a.data.git?.updatedTime?new Date(a.data.git.updatedTime).toISOString():""}=e,{options:{base:g,locales:h},pages:w}=t,f=w.reduce((a,i)=>{const{defaultPath:o,pathLocale:u}=E(i),s=a.get(o)||[];return s.push(u),a.set(o,s)},new Map),m=new Map;return w.forEach(a=>{const i=a.frontmatter.sitemap;if(i===!1||((a.frontmatter.head||[]).find(n=>n[1].name==="robots")?.[1].content||"").split(/,/u).map(n=>n.trim()).includes("noindex")||p.includes(a.path))return;const o=d(a,t),{defaultPath:u}=E(a),s=f.get(u)||[];let x=[];s.length>1&&(t.env.isDebug&&s.forEach(n=>{!h[n].lang&&!v.includes(n)&&(r.warn(`"lang" option for ${n} is missing`),v.push(n))}),x=s.map(n=>({lang:h[n]?.lang||"en",url:`${g}${S(u.replace(/^\//u,n))}`})));const $={...l?{changefreq:l}:{},links:x,...o?{lastmod:o}:{},...i};t.env.isDebug&&r.info(`sitemap option for ${a.path}: ${JSON.stringify($,null,2)}`),m.set(a.path,$)}),m},I=async(t,e)=>{const{extraUrls:l=[],xmlNameSpace:p}=e,d=M(e.hostname)?F(e.hostname):`https://${F(e.hostname)}`,g=e.sitemapFilename?S(e.sitemapFilename):"sitemap.xml",h=e.sitemapXSLFilename?S(e.sitemapXSLFilename):"sitemap.xsl",w=e.sitemapXSLTemplate??`${A}sitemap.xsl`,{dir:f,options:{base:m}}=t;r.load(`Generating sitemap to ${y.cyan(`/${g}`)}`),await new Promise(i=>{const o=new N({hostname:d,...p?{xmlns:p}:{}}),u=X(t,e),s=f.dest(g),x=f.dest(h),$=c.createWriteStream(s);o.pipe($),u.forEach((n,T)=>o.write({url:`${m}${S(T)}`,...n})),$.on("finish",()=>{const n=c.readFileSync(s,{encoding:"utf-8"});c.writeFileSync(s,n.replace('<?xml version="1.0" encoding="UTF-8"?>',`<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="${m}${h}"?>
`)),c.copySync(w,x),i()}),l.forEach(n=>o.write({url:`${m}${S(n)}`})),o.end()}),r.succeed();const a=f.dest("robots.txt");if(c.existsSync(a)){r.load(`Appended sitemap path to ${y.cyan("robots.txt")}`);const i=`${(await c.readFile(a,{encoding:"utf8"})).replace(/^Sitemap: .*$/u,"")}
Sitemap: ${d}${m}${g}
`;await c.writeFile(a,i,{flag:"w"}),r.succeed()}},_=(t,e=!0)=>l=>{e&&k(t),G(l,L,"2.0.0-rc.2"),l.env.isDebug&&r.info("Options:",t);const p={name:L};return t.hostname?{...p,onGenerated:d=>I(d,t)}:(r.error(`Option ${y.magenta("hostname")} is required!`),p)};export{_ as sitemapPlugin};
import{getDirname as b,path as O,colors as y,fs as m}from"vuepress/utils";import{createConverter as P,ensureEndingSlash as U,Logger as D,isLinkHttp as M,removeEndingSlash as L,removeLeadingSlash as S}from"vuepress-shared/node";import{SitemapStream as G}from"sitemap";const N=t=>{const{deprecatedLogger:e}=P("sitemap");e({options:t,old:"urls",new:"extraUrls"}),e({options:t,old:"exclude",new:"excludeUrls"}),e({options:t,old:"outFile",new:"sitemapFilename"}),e({options:t,old:"dateFormatter",new:"modifyTimeGetter"})},q=b(import.meta.url),A=U(O.resolve(q,"../../templates")),F="vuepress-plugin-sitemap2",r=new D(F),v=[],E=({path:t,pathLocale:e})=>({defaultPath:t.replace(e,"/"),pathLocale:e}),X=(t,e)=>{const{changefreq:c="daily",excludeUrls:l=["/404.html"],modifyTimeGetter:d=a=>a.data.git?.updatedTime?new Date(a.data.git.updatedTime).toISOString():""}=e,{options:{base:g,locales:h},pages:w}=t,f=w.reduce((a,i)=>{const{defaultPath:s,pathLocale:u}=E(i),o=a.get(s)||[];return o.push(u),a.set(s,o)},new Map),p=new Map;return w.forEach(a=>{const i=a.frontmatter.sitemap;if(i===!1||((a.frontmatter.head||[]).find(n=>n[1].name==="robots")?.[1].content||"").split(/,/u).map(n=>n.trim()).includes("noindex")||l.includes(a.path))return;const s=d(a,t),{defaultPath:u}=E(a),o=f.get(u)||[];let x=[];o.length>1&&(t.env.isDebug&&o.forEach(n=>{!h[n].lang&&!v.includes(n)&&(r.warn(`"lang" option for ${n} is missing`),v.push(n))}),x=o.map(n=>({lang:h[n]?.lang||"en",url:`${g}${S(u.replace(/^\//u,n))}`})));const $={...c?{changefreq:c}:{},links:x,...s?{lastmod:s}:{},...i};t.env.isDebug&&r.info(`sitemap option for ${a.path}: ${JSON.stringify($,null,2)}`),p.set(a.path,$)}),p},k=async(t,e)=>{const{extraUrls:c=[],xmlNameSpace:l}=e,d=M(e.hostname)?L(e.hostname):`https://${L(e.hostname)}`,g=e.sitemapFilename?S(e.sitemapFilename):"sitemap.xml",h=e.sitemapXSLFilename?S(e.sitemapXSLFilename):"sitemap.xsl",w=e.sitemapXSLTemplate??`${A}sitemap.xsl`,{dir:f,options:{base:p}}=t;r.load(`Generating sitemap to ${y.cyan(`/${g}`)}`),await new Promise(i=>{const s=new G({hostname:d,...l?{xmlns:l}:{}}),u=X(t,e),o=f.dest(g),x=f.dest(h),$=m.createWriteStream(o);s.pipe($),u.forEach((n,T)=>s.write({url:`${p}${S(T)}`,...n})),$.on("finish",()=>{const n=m.readFileSync(o,{encoding:"utf-8"});m.writeFileSync(o,n.replace('<?xml version="1.0" encoding="UTF-8"?>',`<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="${p}${h}"?>
`)),m.copySync(w,x),i()}),c.forEach(n=>s.write({url:`${p}${S(n)}`})),s.end()}),r.succeed();const a=f.dest("robots.txt");if(m.existsSync(a)){r.load(`Appended sitemap path to ${y.cyan("robots.txt")}`);const i=`${(await m.readFile(a,{encoding:"utf8"})).replace(/^Sitemap: .*$/u,"")}
Sitemap: ${d}${p}${g}
`;await m.writeFile(a,i,{flag:"w"}),r.succeed()}},I=(t,e=!0)=>c=>{e&&N(t),c.env.isDebug&&r.info("Options:",t);const l={name:F};return t.hostname?{...l,onGenerated:d=>k(d,t)}:(r.error(`Option ${y.magenta("hostname")} is required!`),l)};export{I as sitemapPlugin};
//# sourceMappingURL=index.js.map
{
"name": "vuepress-plugin-sitemap2",
"version": "2.0.0-rc.15",
"version": "2.0.0-rc.16",
"description": "Sitemap plugin for vuepress",

@@ -40,3 +40,3 @@ "keywords": [

"sitemap": "^7.1.1",
"vuepress-shared": "2.0.0-rc.15"
"vuepress-shared": "2.0.0-rc.16"
},

@@ -43,0 +43,0 @@ "devDependencies": {

Sorry, the diff of this file is not supported yet