@asymmetric-effort/specifyjs 0.1.0 → 0.1.3

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.
@@ -0,0 +1,2 @@
1
+ "use strict";var s=require("fs"),e=require("path");exports.specifyJsSeoPlugin=function(t){return{name:"specifyjs-seo",closeBundle(){const i=e.resolve(process.cwd(),"dist"),o=(new Date).toISOString().split("T")[0]??"",n=[...t.routes??["/"]],r=[];if(t.docsDir&&s.existsSync(t.docsDir)){!function(t,i){const o=[{dir:t,prefix:""}];for(;o.length>0;){const{dir:t,prefix:n}=o.pop(),r=s.readdirSync(t,{withFileTypes:!0});for(const s of r)s.isDirectory()?o.push({dir:e.join(t,s.name),prefix:n+s.name+"/"}):s.name.endsWith(".md")&&i.push(n+s.name.replace(".md",""))}}(t.docsDir,r);for(const s of r)n.push(`/#/docs/${s}`)}const p=function(s,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>${s}${e}</loc><lastmod>${t}</lastmod></url>`),"</urlset>"].join("\n")}(t.siteUrl,n,o);s.writeFileSync(e.join(i,"sitemap.xml"),p);const c=function(s,e){const t=["User-agent: *","Allow: /"];return e&&t.push(...e),t.push("",`Sitemap: ${s}/sitemap.xml`),t.join("\n")}(t.siteUrl,t.robotsRules);s.writeFileSync(e.join(i,"robots.txt"),c);const l=function(s,e){const t=[`# ${s.title??"Site"}`];if(s.description){t.push("");const e=s.description.split("\n");for(const s of e)t.push(`> ${s}`)}t.push(""),t.push(`## Website: ${s.siteUrl}`),s.repository&&t.push(`## Repository: ${s.repository}`),s.npmPackage&&t.push(`## npm: https://www.npmjs.com/package/${s.npmPackage}`);const i=e.filter(s=>s.startsWith("guides/")).map(s=>s.replace("guides/","")),o=e.filter(s=>s.startsWith("api/")).map(s=>s.replace("api/",""));if(i.length>0){t.push("","## Documentation","");for(const e of i)t.push(`- ${e}: ${s.siteUrl}/#/docs/guides/${e}`)}if(o.length>0){t.push("","## API Reference","");for(const e of o)t.push(`- ${e}: ${s.siteUrl}/#/docs/api/${e}`)}return s.npmPackage&&t.push("","## Install","","```",`npm install ${s.npmPackage}`,"```"),s.license&&t.push("",`## License: ${s.license}`),s.author&&t.push(`## Author: ${s.author}`),t.join("\n")}(t,r);s.writeFileSync(e.join(i,"llms.txt"),l),console.log(`Generated: sitemap.xml (${n.length} URLs), robots.txt, llms.txt`)}}};
2
+ //# sourceMappingURL=specifyjs-build.cjs.js.map
@@ -0,0 +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","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":"8EAqJM,SAA6BA,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,M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AAMd,KAAK,yCAAyC7B,EAAOoD,cAI7D,MAAMC,EAAaxC,EAChByC,OAAQC,GAAMA,EAAEC,WAAW,YAC3BnB,IAAKkB,GAAMA,EAAEvB,QAAQ,UAAW,KAC7ByB,EAAW5C,EAASyC,OAAQC,GAAMA,EAAEC,WAAW,SAASnB,IAAKkB,GAAMA,EAAEvB,QAAQ,OAAQ,KAE3F,GAAIqB,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"}
@@ -0,0 +1,43 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ /**
4
+ * SpecifyJS SEO Plugin for Vite
5
+ * Auto-generates sitemap.xml, robots.txt, and llms.txt at build time.
6
+ *
7
+ * Usage in vite.config.ts:
8
+ * import { specifyJsSeoPlugin } from '@asymmetric-effort/specifyjs/build';
9
+ * export default defineConfig({ plugins: [specifyJsSeoPlugin({ ... })] });
10
+ */
11
+
12
+ interface SeoPluginConfig {
13
+ /** Base URL of the site (e.g., 'https://example.com') */
14
+ siteUrl: string;
15
+ /** Site title for llms.txt */
16
+ title?: string;
17
+ /** Site description for llms.txt */
18
+ description?: string;
19
+ /** Hash-based routes to include in sitemap */
20
+ routes?: string[];
21
+ /** Path to docs directory (generates doc routes in sitemap) */
22
+ docsDir?: string;
23
+ /** npm package name for llms.txt install instructions */
24
+ npmPackage?: string;
25
+ /** Author name for llms.txt */
26
+ author?: string;
27
+ /** License for llms.txt */
28
+ license?: string;
29
+ /** Additional robots.txt rules */
30
+ robotsRules?: string[];
31
+ /** Repository URL for llms.txt */
32
+ repository?: string;
33
+ }
34
+ /**
35
+ * Create the SpecifyJS SEO Vite plugin.
36
+ *
37
+ * Generates sitemap.xml, robots.txt, and llms.txt in the build output directory
38
+ * during the closeBundle hook.
39
+ */
40
+ declare function specifyJsSeoPlugin(config: SeoPluginConfig): Plugin;
41
+
42
+ export { specifyJsSeoPlugin };
43
+ export type { SeoPluginConfig };
@@ -0,0 +1,2 @@
1
+ import s from"fs";import t from"path";function e(e){return{name:"specifyjs-seo",closeBundle(){const o=t.resolve(process.cwd(),"dist"),i=(new Date).toISOString().split("T")[0]??"",n=[...e.routes??["/"]],r=[];if(e.docsDir&&s.existsSync(e.docsDir)){!function(e,o){const i=[{dir:e,prefix:""}];for(;i.length>0;){const{dir:e,prefix:n}=i.pop(),r=s.readdirSync(e,{withFileTypes:!0});for(const s of r)s.isDirectory()?i.push({dir:t.join(e,s.name),prefix:n+s.name+"/"}):s.name.endsWith(".md")&&o.push(n+s.name.replace(".md",""))}}(e.docsDir,r);for(const s of r)n.push(`/#/docs/${s}`)}const p=function(s,t,e){return['<?xml version="1.0" encoding="UTF-8"?>','<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',...t.map(t=>` <url><loc>${s}${t}</loc><lastmod>${e}</lastmod></url>`),"</urlset>"].join("\n")}(e.siteUrl,n,i);s.writeFileSync(t.join(o,"sitemap.xml"),p);const c=function(s,t){const e=["User-agent: *","Allow: /"];return t&&e.push(...t),e.push("",`Sitemap: ${s}/sitemap.xml`),e.join("\n")}(e.siteUrl,e.robotsRules);s.writeFileSync(t.join(o,"robots.txt"),c);const l=function(s,t){const e=[`# ${s.title??"Site"}`];if(s.description){e.push("");const t=s.description.split("\n");for(const s of t)e.push(`> ${s}`)}e.push(""),e.push(`## Website: ${s.siteUrl}`),s.repository&&e.push(`## Repository: ${s.repository}`),s.npmPackage&&e.push(`## npm: https://www.npmjs.com/package/${s.npmPackage}`);const o=t.filter(s=>s.startsWith("guides/")).map(s=>s.replace("guides/","")),i=t.filter(s=>s.startsWith("api/")).map(s=>s.replace("api/",""));if(o.length>0){e.push("","## Documentation","");for(const t of o)e.push(`- ${t}: ${s.siteUrl}/#/docs/guides/${t}`)}if(i.length>0){e.push("","## API Reference","");for(const t of i)e.push(`- ${t}: ${s.siteUrl}/#/docs/api/${t}`)}return s.npmPackage&&e.push("","## Install","","```",`npm install ${s.npmPackage}`,"```"),s.license&&e.push("",`## License: ${s.license}`),s.author&&e.push(`## Author: ${s.author}`),e.join("\n")}(e,r);s.writeFileSync(t.join(o,"llms.txt"),l),console.log(`Generated: sitemap.xml (${n.length} URLs), robots.txt, llms.txt`)}}}export{e as specifyJsSeoPlugin};
2
+ //# sourceMappingURL=specifyjs-build.esm.js.map
@@ -0,0 +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,EAA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