@asymmetric-effort/specifyjs 0.1.10 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=require("fs"),e=require("path");function t(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}exports.specifyJsNoscriptPlugin=function(o){return{name:"specifyjs-noscript",closeBundle(){const i=e.resolve(process.cwd(),"dist"),s=e.join(i,"index.html");if(!n.existsSync(s))return void console.warn("[specifyjs-noscript] index.html not found in dist/");const r=function(n){const e=n.classPrefix??"ns",o=n.sections;if(0===o.length)return"";const i=o.map(n=>`<a href="#${n.id}" class="${e}-nav-link">${t(n.title)}</a>`).join("\n "),s=o.map(n=>{const o=n.html.replace(/<button[^>]*>([\s\S]*?)<\/button>/gi,"$1").replace(/<input[^>]*\/?>/gi,"").replace(/<select[^>]*>[\s\S]*?<\/select>/gi,"").replace(/<textarea[^>]*>[\s\S]*?<\/textarea>/gi,"").replace(/<\/?form[^>]*>/gi,"").replace(/\s+on\w+="[^"]*"/gi,"").replace(/\s+on\w+='[^']*'/gi,"").replace(/\s+style="[^"]*javascript:[^"]*"/gi,"").replace(/<script[^>]*>[\s\S]*?<\/script>/gi,"");return`\n <section id="${n.id}" class="${e}-section">\n <h2 class="${e}-section-title">${t(n.title)}</h2>\n <div class="${e}-section-content">\n ${o}\n </div>\n <p class="${e}-back-to-top"><a href="#${e}-top">Back to top</a></p>\n </section>`}).join("\n"),r=n.title?`<h1 class="${e}-title">${t(n.title)}</h1>`:"",c=n.description?`<p class="${e}-desc">${t(n.description)}</p>`:"",a=n.copyright?`<footer class="${e}-footer"><p>${t(n.copyright)}</p></footer>`:"";return`\n <noscript>\n <style>\n .${e}-container {\n max-width: 900px;\n margin: 0 auto;\n padding: 20px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n line-height: 1.6;\n color: #1f2937;\n }\n .${e}-title {\n font-size: 2rem;\n margin-bottom: 0.5rem;\n color: #0f172a;\n }\n .${e}-desc {\n font-size: 1.1rem;\n color: #64748b;\n margin-bottom: 1.5rem;\n }\n .${e}-nav {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 12px 0;\n border-bottom: 1px solid #e2e8f0;\n margin-bottom: 2rem;\n position: sticky;\n top: 0;\n background: white;\n z-index: 10;\n }\n .${e}-nav-link {\n padding: 6px 14px;\n border-radius: 6px;\n background: #f1f5f9;\n color: #3b82f6;\n text-decoration: none;\n font-size: 14px;\n font-weight: 500;\n }\n .${e}-nav-link:hover {\n background: #3b82f6;\n color: white;\n }\n .${e}-section {\n margin-bottom: 3rem;\n padding-bottom: 2rem;\n border-bottom: 1px solid #f1f5f9;\n }\n .${e}-section-title {\n font-size: 1.5rem;\n color: #1e293b;\n margin-bottom: 1rem;\n padding-top: 1rem;\n }\n .${e}-section-content h3 {\n font-size: 1.2rem;\n margin-top: 1.5rem;\n color: #334155;\n }\n .${e}-section-content p {\n margin: 0.5rem 0;\n }\n .${e}-section-content pre {\n background: #1e293b;\n color: #e2e8f0;\n padding: 12px 16px;\n border-radius: 6px;\n overflow-x: auto;\n font-size: 13px;\n line-height: 1.5;\n }\n .${e}-section-content code {\n background: #f1f5f9;\n padding: 2px 6px;\n border-radius: 3px;\n font-size: 0.9em;\n }\n .${e}-section-content pre code {\n background: none;\n padding: 0;\n }\n .${e}-section-content table {\n width: 100%;\n border-collapse: collapse;\n margin: 1rem 0;\n }\n .${e}-section-content th,\n .${e}-section-content td {\n padding: 8px 12px;\n border: 1px solid #e2e8f0;\n text-align: left;\n }\n .${e}-section-content th {\n background: #f8fafc;\n font-weight: 600;\n }\n .${e}-section-content img {\n max-width: 100%;\n height: auto;\n }\n .${e}-back-to-top {\n font-size: 13px;\n margin-top: 1.5rem;\n }\n .${e}-back-to-top a {\n color: #3b82f6;\n text-decoration: none;\n }\n .${e}-footer {\n margin-top: 3rem;\n padding-top: 1rem;\n border-top: 1px solid #e2e8f0;\n color: #94a3b8;\n font-size: 13px;\n text-align: center;\n }\n .${e}-js-notice {\n background: #fef3c7;\n border: 1px solid #f59e0b;\n border-radius: 6px;\n padding: 12px 16px;\n margin-bottom: 1.5rem;\n font-size: 14px;\n color: #92400e;\n }\n </style>\n <div id="${e}-top" class="${e}-container">\n ${r}\n ${c}\n <div class="${e}-js-notice">\n This page works best with JavaScript enabled. You are viewing a\n static version of the content.\n </div>\n <nav class="${e}-nav" aria-label="Section navigation">\n ${i}\n </nav>\n ${s}\n ${a}\n </div>\n </noscript>`}(o);if(!r)return void console.warn("[specifyjs-noscript] No sections provided, skipping.");const c=o.maxContentSize??524288,a=Buffer.byteLength(r,"utf-8");a>c&&console.warn(`[specifyjs-noscript] Noscript content is ${(a/1024).toFixed(0)}KB (limit: ${(c/1024).toFixed(0)}KB). Consider reducing section content.`);let p=n.readFileSync(s,"utf-8");p=p.replace("</body>",`${r}\n</body>`),n.writeFileSync(s,p,"utf-8"),console.log(`Generated: noscript fallback (${o.sections.length} sections, ${(a/1024).toFixed(1)}KB)`)}}},exports.specifyJsSeoPlugin=function(t){return{name:"specifyjs-seo",closeBundle(){const o=e.resolve(process.cwd(),"dist"),i=(new Date).toISOString().split("T")[0]??"",s=[...t.routes??["/"]],r=[];if(t.docsDir&&n.existsSync(t.docsDir)){!function(t,o){const i=[{dir:t,prefix:""}];for(;i.length>0;){const{dir:t,prefix:s}=i.pop(),r=n.readdirSync(t,{withFileTypes:!0});for(const n of r)n.isDirectory()?i.push({dir:e.join(t,n.name),prefix:s+n.name+"/"}):n.name.endsWith(".md")&&o.push(s+n.name.replace(".md",""))}}(t.docsDir,r);for(const n of r)s.push(`/#/docs/${n}`)}const c=function(n,e,t){return['<?xml version="1.0" encoding="UTF-8"?>','<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',...e.map(e=>` <url><loc>${n}${e}</loc><lastmod>${t}</lastmod></url>`),"</urlset>"].join("\n")}(t.siteUrl,s,i);n.writeFileSync(e.join(o,"sitemap.xml"),c);const a=function(n,e){const t=["User-agent: *","Allow: /"];return e&&t.push(...e),t.push("",`Sitemap: ${n}/sitemap.xml`),t.join("\n")}(t.siteUrl,t.robotsRules);n.writeFileSync(e.join(o,"robots.txt"),a);const p=function(n,e){const t=[`# ${n.title??"Site"}`];if(n.description){t.push("");const e=n.description.split("\n");for(const n of e)t.push(`> ${n}`)}t.push(""),t.push(`## Website: ${n.siteUrl}`),n.repository&&t.push(`## Repository: ${n.repository}`),n.npmPackage&&t.push(`## npm: https://www.npmjs.com/package/${n.npmPackage}`);const o=e.filter(n=>n.startsWith("guides/")).map(n=>n.replace("guides/","")),i=e.filter(n=>n.startsWith("api/")).map(n=>n.replace("api/",""));if(o.length>0){t.push("","## Documentation","");for(const e of o)t.push(`- ${e}: ${n.siteUrl}/#/docs/guides/${e}`)}if(i.length>0){t.push("","## API Reference","");for(const e of i)t.push(`- ${e}: ${n.siteUrl}/#/docs/api/${e}`)}return n.npmPackage&&t.push("","## Install","","```",`npm install ${n.npmPackage}`,"```"),n.license&&t.push("",`## License: ${n.license}`),n.author&&t.push(`## Author: ${n.author}`),t.join("\n")}(t,r);n.writeFileSync(e.join(o,"llms.txt"),p),console.log(`Generated: sitemap.xml (${s.length} URLs), robots.txt, llms.txt`)}}};
|
|
2
2
|
//# sourceMappingURL=specifyjs-build.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specifyjs-build.cjs.js","sources":["../../src/build/seo-plugin.ts"],"sourcesContent":[null],"names":["config","name","closeBundle","distDir","path","resolve","process","cwd","
|
|
1
|
+
{"version":3,"file":"specifyjs-build.cjs.js","sources":["../../src/build/noscript-plugin.ts","../../src/build/seo-plugin.ts"],"sourcesContent":[null,null],"names":["escapeHtml","str","replace","config","name","closeBundle","distDir","path","resolve","process","cwd","indexPath","join","fs","existsSync","console","warn","noscriptHtml","prefix","classPrefix","sections","length","navLinks","map","s","id","title","sectionBlocks","cleanHtml","html","desc","description","copyright","generateNoscriptHtml","maxSize","maxContentSize","noscriptSize","Buffer","byteLength","toFixed","readFileSync","writeFileSync","log","today","Date","toISOString","split","routes","docPaths","docsDir","rootDir","results","stack","dir","pop","entries","readdirSync","withFileTypes","entry","isDirectory","push","endsWith","walkDocs","dp","sitemap","siteUrl","r","generateSitemap","robots","extraRules","lines","generateRobots","robotsRules","llmsTxt","descLines","dl","repository","npmPackage","guideNames","filter","p","startsWith","apiNames","g","a","license","author","generateLlmsTxt"],"mappings":"mDA2RA,SAASA,EAAWC,GAClB,OAAOA,EACJC,QAAQ,KAAM,SACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,QACdA,QAAQ,KAAM,SACnB,iCAMM,SAAkCC,GACtC,MAAO,CACLC,KAAM,qBAEN,WAAAC,GACE,MAAMC,EAAUC,EAAKC,QAAQC,QAAQC,MAAO,QACtCC,EAAYJ,EAAKK,KAAKN,EAAS,cAErC,IAAKO,EAAGC,WAAWH,GAEjB,YADAI,QAAQC,KAAK,sDAIf,MAAMC,EAhNN,SAA+Bd,GACnC,MAAMe,EAASf,EAAOgB,aAAe,KAC/BC,EAAWjB,EAAOiB,SAExB,GAAwB,IAApBA,EAASC,OAAc,MAAO,GAGlC,MAAMC,EAAWF,EACdG,IAAKC,GAAM,aAAaA,EAAEC,cAAcP,eAAoBlB,EAAWwB,EAAEE,cACzEd,KAAK,gBAGFe,EAAgBP,EACnBG,IAAKC,IACJ,MAAMI,EAAqCJ,EAAEK,KArC5C3B,QAAQ,sCAAuC,MAE/CA,QAAQ,oBAAqB,IAE7BA,QAAQ,oCAAqC,IAE7CA,QAAQ,wCAAyC,IAEjDA,QAAQ,mBAAoB,IAE5BA,QAAQ,qBAAsB,IAC9BA,QAAQ,qBAAsB,IAE9BA,QAAQ,qCAAsC,IAE9CA,QAAQ,oCAAqC,IAuB9C,MAAO,wBACQsB,EAAEC,cAAcP,mCAChBA,oBAAyBlB,EAAW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+39,59 @@ interface SeoPluginConfig {
|
|
|
39
39
|
*/
|
|
40
40
|
declare function specifyJsSeoPlugin(config: SeoPluginConfig): Plugin;
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
/**
|
|
43
|
+
* SpecifyJS Noscript Plugin for Vite
|
|
44
|
+
*
|
|
45
|
+
* Generates a `<noscript>` fallback block inside the built index.html,
|
|
46
|
+
* providing a fully navigable static HTML document for environments
|
|
47
|
+
* where JavaScript is disabled (accessibility) or not executed
|
|
48
|
+
* (search engine crawlers).
|
|
49
|
+
*
|
|
50
|
+
* The noscript content is a single long-form document with:
|
|
51
|
+
* - A navigation bar with anchor links to each section
|
|
52
|
+
* - Each section rendered as semantic HTML (headings, paragraphs, lists)
|
|
53
|
+
* - Internal links mapped to `#section-id` anchors
|
|
54
|
+
*
|
|
55
|
+
* Usage in vite.config.ts:
|
|
56
|
+
* import { specifyJsNoscriptPlugin } from 'specifyjs/build';
|
|
57
|
+
* export default defineConfig({
|
|
58
|
+
* plugins: [
|
|
59
|
+
* specifyJsNoscriptPlugin({
|
|
60
|
+
* title: 'My App',
|
|
61
|
+
* sections: [
|
|
62
|
+
* { id: 'home', title: 'Home', html: '<h1>Welcome</h1><p>...</p>' },
|
|
63
|
+
* { id: 'docs', title: 'Docs', html: '<h2>Getting Started</h2>...' },
|
|
64
|
+
* ],
|
|
65
|
+
* }),
|
|
66
|
+
* ],
|
|
67
|
+
* });
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
interface NoscriptSection {
|
|
71
|
+
/** Anchor ID (used in href="#id" links) */
|
|
72
|
+
id: string;
|
|
73
|
+
/** Display title in the navigation bar */
|
|
74
|
+
title: string;
|
|
75
|
+
/** Static HTML content for this section.
|
|
76
|
+
* Can include headings, paragraphs, lists, tables, code blocks, images.
|
|
77
|
+
* Interactive elements (buttons, inputs) are stripped automatically. */
|
|
78
|
+
html: string;
|
|
79
|
+
}
|
|
80
|
+
interface NoscriptPluginConfig {
|
|
81
|
+
/** Page title shown at the top of the noscript document */
|
|
82
|
+
title?: string;
|
|
83
|
+
/** Subtitle / description shown below the title */
|
|
84
|
+
description?: string;
|
|
85
|
+
/** Sections to render in the noscript block */
|
|
86
|
+
sections: NoscriptSection[];
|
|
87
|
+
/** Copyright notice shown at the bottom */
|
|
88
|
+
copyright?: string;
|
|
89
|
+
/** CSS class prefix for noscript elements (default: 'ns') */
|
|
90
|
+
classPrefix?: string;
|
|
91
|
+
/** Maximum content length in bytes before truncation warning (default: 512KB) */
|
|
92
|
+
maxContentSize?: number;
|
|
93
|
+
}
|
|
94
|
+
declare function specifyJsNoscriptPlugin(config: NoscriptPluginConfig): Plugin;
|
|
95
|
+
|
|
96
|
+
export { specifyJsNoscriptPlugin, specifyJsSeoPlugin };
|
|
97
|
+
export type { NoscriptPluginConfig, NoscriptSection, SeoPluginConfig };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import
|
|
1
|
+
import n from"fs";import e from"path";function t(t){return{name:"specifyjs-seo",closeBundle(){const o=e.resolve(process.cwd(),"dist"),i=(new Date).toISOString().split("T")[0]??"",s=[...t.routes??["/"]],r=[];if(t.docsDir&&n.existsSync(t.docsDir)){!function(t,o){const i=[{dir:t,prefix:""}];for(;i.length>0;){const{dir:t,prefix:s}=i.pop(),r=n.readdirSync(t,{withFileTypes:!0});for(const n of r)n.isDirectory()?i.push({dir:e.join(t,n.name),prefix:s+n.name+"/"}):n.name.endsWith(".md")&&o.push(s+n.name.replace(".md",""))}}(t.docsDir,r);for(const n of r)s.push(`/#/docs/${n}`)}const c=function(n,e,t){return['<?xml version="1.0" encoding="UTF-8"?>','<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',...e.map(e=>` <url><loc>${n}${e}</loc><lastmod>${t}</lastmod></url>`),"</urlset>"].join("\n")}(t.siteUrl,s,i);n.writeFileSync(e.join(o,"sitemap.xml"),c);const a=function(n,e){const t=["User-agent: *","Allow: /"];return e&&t.push(...e),t.push("",`Sitemap: ${n}/sitemap.xml`),t.join("\n")}(t.siteUrl,t.robotsRules);n.writeFileSync(e.join(o,"robots.txt"),a);const p=function(n,e){const t=[`# ${n.title??"Site"}`];if(n.description){t.push("");const e=n.description.split("\n");for(const n of e)t.push(`> ${n}`)}t.push(""),t.push(`## Website: ${n.siteUrl}`),n.repository&&t.push(`## Repository: ${n.repository}`),n.npmPackage&&t.push(`## npm: https://www.npmjs.com/package/${n.npmPackage}`);const o=e.filter(n=>n.startsWith("guides/")).map(n=>n.replace("guides/","")),i=e.filter(n=>n.startsWith("api/")).map(n=>n.replace("api/",""));if(o.length>0){t.push("","## Documentation","");for(const e of o)t.push(`- ${e}: ${n.siteUrl}/#/docs/guides/${e}`)}if(i.length>0){t.push("","## API Reference","");for(const e of i)t.push(`- ${e}: ${n.siteUrl}/#/docs/api/${e}`)}return n.npmPackage&&t.push("","## Install","","```",`npm install ${n.npmPackage}`,"```"),n.license&&t.push("",`## License: ${n.license}`),n.author&&t.push(`## Author: ${n.author}`),t.join("\n")}(t,r);n.writeFileSync(e.join(o,"llms.txt"),p),console.log(`Generated: sitemap.xml (${s.length} URLs), robots.txt, llms.txt`)}}}function o(n){return n.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function i(t){return{name:"specifyjs-noscript",closeBundle(){const i=e.resolve(process.cwd(),"dist"),s=e.join(i,"index.html");if(!n.existsSync(s))return void console.warn("[specifyjs-noscript] index.html not found in dist/");const r=function(n){const e=n.classPrefix??"ns",t=n.sections;if(0===t.length)return"";const i=t.map(n=>`<a href="#${n.id}" class="${e}-nav-link">${o(n.title)}</a>`).join("\n "),s=t.map(n=>{const t=n.html.replace(/<button[^>]*>([\s\S]*?)<\/button>/gi,"$1").replace(/<input[^>]*\/?>/gi,"").replace(/<select[^>]*>[\s\S]*?<\/select>/gi,"").replace(/<textarea[^>]*>[\s\S]*?<\/textarea>/gi,"").replace(/<\/?form[^>]*>/gi,"").replace(/\s+on\w+="[^"]*"/gi,"").replace(/\s+on\w+='[^']*'/gi,"").replace(/\s+style="[^"]*javascript:[^"]*"/gi,"").replace(/<script[^>]*>[\s\S]*?<\/script>/gi,"");return`\n <section id="${n.id}" class="${e}-section">\n <h2 class="${e}-section-title">${o(n.title)}</h2>\n <div class="${e}-section-content">\n ${t}\n </div>\n <p class="${e}-back-to-top"><a href="#${e}-top">Back to top</a></p>\n </section>`}).join("\n"),r=n.title?`<h1 class="${e}-title">${o(n.title)}</h1>`:"",c=n.description?`<p class="${e}-desc">${o(n.description)}</p>`:"",a=n.copyright?`<footer class="${e}-footer"><p>${o(n.copyright)}</p></footer>`:"";return`\n <noscript>\n <style>\n .${e}-container {\n max-width: 900px;\n margin: 0 auto;\n padding: 20px;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;\n line-height: 1.6;\n color: #1f2937;\n }\n .${e}-title {\n font-size: 2rem;\n margin-bottom: 0.5rem;\n color: #0f172a;\n }\n .${e}-desc {\n font-size: 1.1rem;\n color: #64748b;\n margin-bottom: 1.5rem;\n }\n .${e}-nav {\n display: flex;\n flex-wrap: wrap;\n gap: 8px;\n padding: 12px 0;\n border-bottom: 1px solid #e2e8f0;\n margin-bottom: 2rem;\n position: sticky;\n top: 0;\n background: white;\n z-index: 10;\n }\n .${e}-nav-link {\n padding: 6px 14px;\n border-radius: 6px;\n background: #f1f5f9;\n color: #3b82f6;\n text-decoration: none;\n font-size: 14px;\n font-weight: 500;\n }\n .${e}-nav-link:hover {\n background: #3b82f6;\n color: white;\n }\n .${e}-section {\n margin-bottom: 3rem;\n padding-bottom: 2rem;\n border-bottom: 1px solid #f1f5f9;\n }\n .${e}-section-title {\n font-size: 1.5rem;\n color: #1e293b;\n margin-bottom: 1rem;\n padding-top: 1rem;\n }\n .${e}-section-content h3 {\n font-size: 1.2rem;\n margin-top: 1.5rem;\n color: #334155;\n }\n .${e}-section-content p {\n margin: 0.5rem 0;\n }\n .${e}-section-content pre {\n background: #1e293b;\n color: #e2e8f0;\n padding: 12px 16px;\n border-radius: 6px;\n overflow-x: auto;\n font-size: 13px;\n line-height: 1.5;\n }\n .${e}-section-content code {\n background: #f1f5f9;\n padding: 2px 6px;\n border-radius: 3px;\n font-size: 0.9em;\n }\n .${e}-section-content pre code {\n background: none;\n padding: 0;\n }\n .${e}-section-content table {\n width: 100%;\n border-collapse: collapse;\n margin: 1rem 0;\n }\n .${e}-section-content th,\n .${e}-section-content td {\n padding: 8px 12px;\n border: 1px solid #e2e8f0;\n text-align: left;\n }\n .${e}-section-content th {\n background: #f8fafc;\n font-weight: 600;\n }\n .${e}-section-content img {\n max-width: 100%;\n height: auto;\n }\n .${e}-back-to-top {\n font-size: 13px;\n margin-top: 1.5rem;\n }\n .${e}-back-to-top a {\n color: #3b82f6;\n text-decoration: none;\n }\n .${e}-footer {\n margin-top: 3rem;\n padding-top: 1rem;\n border-top: 1px solid #e2e8f0;\n color: #94a3b8;\n font-size: 13px;\n text-align: center;\n }\n .${e}-js-notice {\n background: #fef3c7;\n border: 1px solid #f59e0b;\n border-radius: 6px;\n padding: 12px 16px;\n margin-bottom: 1.5rem;\n font-size: 14px;\n color: #92400e;\n }\n </style>\n <div id="${e}-top" class="${e}-container">\n ${r}\n ${c}\n <div class="${e}-js-notice">\n This page works best with JavaScript enabled. You are viewing a\n static version of the content.\n </div>\n <nav class="${e}-nav" aria-label="Section navigation">\n ${i}\n </nav>\n ${s}\n ${a}\n </div>\n </noscript>`}(t);if(!r)return void console.warn("[specifyjs-noscript] No sections provided, skipping.");const c=t.maxContentSize??524288,a=Buffer.byteLength(r,"utf-8");a>c&&console.warn(`[specifyjs-noscript] Noscript content is ${(a/1024).toFixed(0)}KB (limit: ${(c/1024).toFixed(0)}KB). Consider reducing section content.`);let p=n.readFileSync(s,"utf-8");p=p.replace("</body>",`${r}\n</body>`),n.writeFileSync(s,p,"utf-8"),console.log(`Generated: noscript fallback (${t.sections.length} sections, ${(a/1024).toFixed(1)}KB)`)}}}export{i as specifyJsNoscriptPlugin,t as specifyJsSeoPlugin};
|
|
2
2
|
//# sourceMappingURL=specifyjs-build.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"specifyjs-build.esm.js","sources":["../../src/build/seo-plugin.ts"],"sourcesContent":[null],"names":["specifyJsSeoPlugin","config","name","closeBundle","distDir","path","resolve","process","cwd","today","Date","toISOString","split","routes","docPaths","docsDir","fs","existsSync","rootDir","results","stack","dir","prefix","length","pop","entries","readdirSync","withFileTypes","entry","isDirectory","push","join","endsWith","replace","walkDocs","dp","sitemap","siteUrl","map","r","generateSitemap","writeFileSync","robots","extraRules","lines","generateRobots","robotsRules","llmsTxt","title","description","descLines","dl","repository","npmPackage","guideNames","filter","p","startsWith","apiNames","g","a","license","author","generateLlmsTxt","console","log"],"mappings":"sCAqJM,SAAUA,EAAmBC,GACjC,MAAO,CACLC,KAAM,gBACN,WAAAC,GACE,MAAMC,EAAUC,EAAKC,QAAQC,QAAQC,MAAO,QACtCC,GAAQ,IAAIC,MAAOC,cAAcC,MAAM,KAAK,IAAM,GAGlDC,EAAS,IAAKZ,EAAOY,QAAU,CAAC,MAGhCC,EAAqB,GAC3B,GAAIb,EAAOc,SAAWC,EAAGC,WAAWhB,EAAOc,SAAU,EAtH3D,SAAkBG,EAAiBC,GACjC,MAAMC,EAAgD,CAAC,CAAEC,IAAKH,EAASI,OAAQ,KAC/E,KAAOF,EAAMG,OAAS,GAAG,CACvB,MAAMF,IAAEA,EAAGC,OAAEA,GAAWF,EAAMI,MACxBC,EAAUT,EAAGU,YAAYL,EAAK,CAAEM,eAAe,IACrD,IAAK,MAAMC,KAASH,EACdG,EAAMC,cACRT,EAAMU,KAAK,CAAET,IAAKhB,EAAK0B,KAAKV,EAAKO,EAAM1B,MAAOoB,OAAQA,EAASM,EAAM1B,KAAO,MACnE0B,EAAM1B,KAAK8B,SAAS,QAC7Bb,EAAQW,KAAKR,EAASM,EAAM1B,KAAK+B,QAAQ,MAAO,IAGtD,CACF,CA0GQC,CAASj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AAIqB,EAAW/B,OAAS,EAAG,CACzBqB,EAAMd,KAAK,GAAI,mBAAoB,IACnC,IAAK,MAAM6B,KAAKL,EACdV,EAAMd,KAAK,KAAK6B,MAAM1D,EAAOoC,yBAAyBsB,IAE1D,CAEA,GAAID,EAASnC,OAAS,EAAG,CACvBqB,EAAMd,KAAK,GAAI,mBAAoB,IACnC,IAAK,MAAM8B,KAAKF,EACdd,EAAMd,KAAK,KAAK8B,MAAM3D,EAAOoC,sBAAsBuB,IAEvD,CAaA,OAXI3D,EAAOoD,YACTT,EAAMd,KAAK,GAAI,aAAc,GAAI,MAAO,eAAe7B,EAAOoD,aAAc,OAG1EpD,EAAO4D,SACTjB,EAAMd,KAAK,GAAI,eAAe7B,EAAO4D,WAEnC5D,EAAO6D,QACTlB,EAAMd,KAAK,cAAc7B,EAAO6D,UAG3BlB,EAAMb,KAAK,KACpB,CAoCsBgC,CAAgB9D,EAAQa,GACxCE,EAAGyB,cAAcpC,EAAK0B,KAAK3B,EAAS,YAAa2C,GAEjDiB,QAAQC,IAAI,2BAA2BpD,EAAOU,qCAChD,EAEJ"}
|
|
1
|
+
{"version":3,"file":"specifyjs-build.esm.js","sources":["../../src/build/seo-plugin.ts","../../src/build/noscript-plugin.ts"],"sourcesContent":[null,null],"names":["specifyJsSeoPlugin","config","name","closeBundle","distDir","path","resolve","process","cwd","today","Date","toISOString","split","routes","docPaths","docsDir","fs","existsSync","rootDir","results","stack","dir","prefix","length","pop","entries","readdirSync","withFileTypes","entry","isDirectory","push","join","endsWith","replace","walkDocs","dp","sitemap","siteUrl","map","r","generateSitemap","writeFileSync","robots","extraRules","lines","generateRobots","robotsRules","llmsTxt","title","description","descLines","dl","repository","npmPackage","guideNames","filter","p","startsWith","apiNames","g","a","license","author","generateLlmsTxt","console","log","escapeHtml","str","specifyJsNoscriptPlugin","indexPath","warn","noscriptHtml","classPrefix","sections","navLinks","s","id","sectionBlocks","cleanHtml","html","desc","copyright","generateNoscriptHtml","maxSize","maxContentSize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