@kashi-ui/mcp 0.22.1 → 0.24.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.
@@ -122,8 +122,38 @@ export function readDoc(file) {
122
122
  return mdxToMarkdown(readFileSync(file, "utf8"));
123
123
  }
124
124
 
125
- /** همهٔ صفحه‌های MDX یک پوشه با عنوان و گروه از فهرست ناوبری سایت */
126
- export function collectDocs(root, nav, site = "https://kashi.sepantapouya.com") {
125
+ export const ELEMENTS_CDN = `<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@kashi-ui/css/dist/kashi.css">
126
+ <script type="module" src="https://cdn.jsdelivr.net/npm/@kashi-ui/elements/dist/cdn/kashi-elements.js"></script>`;
127
+ export const elementsImport = (module) => `import "@kashi-ui/css";\nimport "@kashi-ui/elements/${module}.js";`;
128
+
129
+ /** بخش «وب کامپوننت» یک صفحه از روی apps/docs/src/data/elements.ts؛ همان چیزی که سایت پایان صفحه نشان می‌دهد */
130
+ export function elementMarkdown(doc) {
131
+ const row = (cells) => `| ${cells.map(cell).join(" | ")} |`;
132
+ const out = [
133
+ "## وب کامپوننت",
134
+ "",
135
+ `همین کامپوننت بدون React، برای HTML، وردپرس، Vue، Svelte و Angular: ${doc.tags.map((t) => `\`<${t}>\``).join("، ")} در \`@kashi-ui/elements\`.${doc.note ? ` ${doc.note}` : ""}`,
136
+ "",
137
+ "نصب بدون ابزار ساخت (CDN):",
138
+ "",
139
+ "```html", ELEMENTS_CDN, "```",
140
+ "",
141
+ "یا با npm، فقط همین بخش:",
142
+ "",
143
+ "```bash", "npm i @kashi-ui/elements @kashi-ui/css", "```",
144
+ "",
145
+ "```js", elementsImport(doc.module), "```",
146
+ "",
147
+ "```html", doc.html, "```",
148
+ ];
149
+ if (doc.items?.length) out.push("", row(["عنصر", "کاربرد"]), "|---|---|", ...doc.items.map(([t, d]) => row([`<${t}>`, d])));
150
+ out.push("", "ویژگی‌ها:", "", row(["نام", "مقدار", "پیش‌فرض", "توضیح"]), "|---|---|---|---|", ...doc.attrs.map((a) => row(a)));
151
+ if (doc.api?.length) out.push("", "رویدادها و JavaScript:", "", row(["نام", "توضیح"]), "|---|---|", ...doc.api.map((a) => row(a)));
152
+ return out.join("\n");
153
+ }
154
+
155
+ /** همهٔ صفحه‌های MDX یک پوشه با عنوان و گروه از فهرست ناوبری سایت؛ elements بخش وب کامپوننت هر صفحه را اضافه می‌کند */
156
+ export function collectDocs(root, nav, site = "https://kashi.sepantapouya.com", elements = {}) {
127
157
  const groupOf = {};
128
158
  for (const g of nav) for (const item of g.items) groupOf[item.href] = { group: g.title, title: item.title };
129
159
  return globSync(`${root}/**/*.mdx`).sort().map((file) => {
@@ -133,6 +163,8 @@ export function collectDocs(root, nav, site = "https://kashi.sepantapouya.com")
133
163
  const n = groupOf[href];
134
164
  // راهنماها هم نمونه‌کد دارند (Button در صفحهٔ نصب)؛ فقط صفحه‌های کامپوننت کامپوننت معرفی می‌کنند
135
165
  const components = /^(components|persian)\//.test(rel) ? d.components : [];
136
- return { slug: rel || "intro", url: site + href, title: d.title || (n && n.title) || rel, description: d.description, group: n ? n.group : "", components, markdown: d.markdown };
166
+ const el = elements[href];
167
+ const markdown = el ? `${d.markdown}\n\n${elementMarkdown(el)}` : d.markdown;
168
+ return { slug: rel || "intro", url: site + href, title: d.title || (n && n.title) || rel, description: d.description, group: n ? n.group : "", components, markdown };
137
169
  });
138
170
  }