@t8/docsgen 0.4.21 → 0.4.22

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.
package/dist/bin.js CHANGED
@@ -432,12 +432,16 @@ function getPreviewContent(url, title) {
432
432
  let { pathname, searchParams } = new URL(url);
433
433
  let sandboxId = pathname.split("/").at(-1);
434
434
  let file = searchParams.get("file");
435
+ let height = searchParams.get("h");
435
436
  let previewURL = new URL(`https://codesandbox.io/embed/${sandboxId}`);
436
- let previewContent = title ? `<legend>${title}</legend>` : "";
437
+ let content = title ? `<legend>${title}</legend>` : "";
437
438
  previewURL.searchParams.set("view", "preview");
438
439
  if (file) previewURL.searchParams.set("module", file);
439
- previewContent += `<iframe src="${previewURL.href}"${title ? ` title="${title}"` : ""} sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" loading="lazy"></iframe>`;
440
- return previewContent;
440
+ let attrs = [`src="${previewURL.href}"`];
441
+ if (title) attrs.push(`title="${title}"`);
442
+ if (height) attrs.push(`style="height: ${height}px;"`);
443
+ content += `<iframe ${attrs.join(" ")} sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" loading="lazy"></iframe>`;
444
+ return content;
441
445
  }
442
446
  function getSectionPostprocess(linkMap) {
443
447
  return (content) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/docsgen",
3
- "version": "0.4.21",
3
+ "version": "0.4.22",
4
4
  "description": "",
5
5
  "main": "dist/bin.js",
6
6
  "type": "module",
@@ -7,18 +7,25 @@ function isPreviewURL(url: string) {
7
7
  function getPreviewContent(url: string, title?: string) {
8
8
  let { pathname, searchParams } = new URL(url);
9
9
  let sandboxId = pathname.split("/").at(-1);
10
+
10
11
  let file = searchParams.get("file");
12
+ let height = searchParams.get("h");
11
13
 
12
14
  let previewURL = new URL(`https://codesandbox.io/embed/${sandboxId}`);
13
- let previewContent = title ? `<legend>${title}</legend>` : "";
15
+ let content = title ? `<legend>${title}</legend>` : "";
14
16
 
15
17
  previewURL.searchParams.set("view", "preview");
16
18
 
17
19
  if (file) previewURL.searchParams.set("module", file);
18
20
 
19
- previewContent += `<iframe src="${previewURL.href}"${title ? ` title="${title}"` : ""} sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" loading="lazy"></iframe>`;
21
+ let attrs = [`src="${previewURL.href}"`];
22
+
23
+ if (title) attrs.push(`title="${title}"`);
24
+ if (height) attrs.push(`style="height: ${height}px;"`);
20
25
 
21
- return previewContent;
26
+ content += `<iframe ${attrs.join(" ")} sandbox="allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts" loading="lazy"></iframe>`;
27
+
28
+ return content;
22
29
  }
23
30
 
24
31
  export function getSectionPostprocess(
@@ -53,6 +60,7 @@ export function getSectionPostprocess(
53
60
  let nextHref = linkMap[href] ?? href;
54
61
 
55
62
  a.setAttribute("href", nextHref);
63
+
56
64
  if (/^(https?:)?\/\//.test(nextHref))
57
65
  a.setAttribute("target", "_blank");
58
66
  }