@t8/docsgen 0.2.44 → 0.2.46

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
@@ -117,6 +117,7 @@ function getLocation(ctx, path, preferredLocation) {
117
117
  // src/bin/stripHTML.ts
118
118
  import { JSDOM } from "jsdom";
119
119
  function stripHTML(content, replaceNbsp = false) {
120
+ if (!content) return "";
120
121
  try {
121
122
  let t = content.replaceAll("<sup>", " (").replaceAll("</sup>", ")");
122
123
  let s = new JSDOM(t).window.document.body.textContent;
@@ -411,26 +412,6 @@ ${navContent}
411
412
  </nav>`;
412
413
  }
413
414
 
414
- // src/bin/getTitle.ts
415
- function getTitle(ctx, { cover, originalContent, withPackageURL } = {}) {
416
- let { root, name, title: packageTitle, htmlTitle, scope } = ctx;
417
- if (originalContent && ![name, packageTitle].includes(originalContent.trim()))
418
- return originalContent;
419
- if (cover && htmlTitle) return htmlTitle;
420
- if (packageTitle) {
421
- let escapedTitle = escapeHTML(packageTitle);
422
- return withPackageURL ? `<a href="${root}" class="name">${escapedTitle}</a>` : `<span class="name">${escapedTitle}</span>`;
423
- }
424
- let scopeMatches = name?.match(/^(@[^/]+)\/?(.*)/);
425
- if (!scope || !scopeMatches) {
426
- let escapedName = escapeHTML(name);
427
- return withPackageURL ? `<a href="${root}" class="name">${escapedName}</a>` : `<span class="name">${escapedName}</span>`;
428
- }
429
- let title = `<a href="${scope}" class="scope">${scopeMatches[1]}</a><span class="sep">/</span>`;
430
- title += withPackageURL ? `<a href="${root}" class="name">${scopeMatches[2]}</a>` : `<span class="name">${scopeMatches[2]}</span>`;
431
- return title;
432
- }
433
-
434
415
  // src/bin/parsing/getParsedContent.ts
435
416
  import { JSDOM as JSDOM3 } from "jsdom";
436
417
  import Markdown from "markdown-it";
@@ -691,7 +672,8 @@ async function setContent(ctx) {
691
672
  root,
692
673
  contentDir = "",
693
674
  name,
694
- title: configTitle,
675
+ title,
676
+ htmlTitle,
695
677
  description: packageDescription,
696
678
  backstory,
697
679
  redirect
@@ -750,7 +732,7 @@ ${getInjectedContent(ctx, "redirect", "body")}
750
732
  return;
751
733
  }
752
734
  let {
753
- title,
735
+ title: parsedTitle,
754
736
  description,
755
737
  intro,
756
738
  features,
@@ -759,7 +741,10 @@ ${getInjectedContent(ctx, "redirect", "body")}
759
741
  sections,
760
742
  nav
761
743
  } = await getParsedContent(ctx);
762
- let escapedTitle = configTitle ? escapeHTML(configTitle) : title || escapeHTML(name);
744
+ let plainTitle = escapeHTML(
745
+ title || stripHTML(htmlTitle || parsedTitle, true) || name
746
+ );
747
+ let coverTitle = htmlTitle || parsedTitle || plainTitle;
763
748
  let descriptionContent = tweakTypography(description) || (escapedPackageDescription ? `<p>${tweakTypography(escapedPackageDescription)}<p>` : "");
764
749
  let navContent = await getNav(ctx, nav);
765
750
  let dirs = [contentDir];
@@ -783,8 +768,8 @@ ${getInjectedContent(ctx, "redirect", "body")}
783
768
  <head>
784
769
  <meta charset="utf-8">
785
770
  <meta name="viewport" content="width=device-width, initial-scale=1">
786
- <meta name="description" content="${escapedTitle}: ${escapeHTML(stripHTML(nav[i]?.title, true))}">
787
- <title>${escapeHTML(stripHTML(nav[i]?.title, true))} | ${escapedTitle}</title>
771
+ <meta name="description" content="${plainTitle}: ${escapeHTML(stripHTML(nav[i]?.title, true))}">
772
+ <title>${escapeHTML(stripHTML(nav[i]?.title, true))} | ${plainTitle}</title>
788
773
  <link rel="stylesheet" href="${cssRoot.content}/base.css">
789
774
  <link rel="stylesheet" href="${cssRoot.content}/section.css">
790
775
  ${iconTag}
@@ -796,7 +781,7 @@ ${getInjectedContent(ctx, "redirect", "body")}
796
781
  <div class="layout">
797
782
  <div class="${navContent ? "" : "no-nav "}body">
798
783
  <main>
799
- <h1>${getTitle(ctx, { withPackageURL: true })}</h1>
784
+ <h1><a href="${root}">${coverTitle}</a></h1>
800
785
  ${content}
801
786
 
802
787
  <p class="pagenav">
@@ -834,8 +819,8 @@ ${getInjectedContent(ctx, "section", "body")}
834
819
  <head>
835
820
  <meta charset="utf-8">
836
821
  <meta name="viewport" content="width=device-width, initial-scale=1">
837
- <meta name="description" content="${escapedTitle}${escapedPackageDescription ? `: ${escapedPackageDescription}` : ""}">
838
- <title>${escapedTitle}${escapedPackageDescription ? ` | ${escapedPackageDescription}` : ""}</title>
822
+ <meta name="description" content="${plainTitle}${escapedPackageDescription ? `: ${escapedPackageDescription}` : ""}">
823
+ <title>${plainTitle}${escapedPackageDescription ? ` | ${escapedPackageDescription}` : ""}</title>
839
824
  <link rel="stylesheet" href="${cssRoot.index}/base.css">
840
825
  <link rel="stylesheet" href="${cssRoot.index}/index.css">
841
826
  ${iconTag}
@@ -848,7 +833,7 @@ ${getInjectedContent(ctx, "section", "body")}
848
833
  <main>
849
834
  <section class="b1 intro-title">
850
835
  <div class="section-content">
851
- <h1>${getTitle(ctx, { cover: true })}</h1>
836
+ <h1>${coverTitle}</h1>
852
837
  <div class="description">
853
838
  ${descriptionContent}
854
839
  </div>
@@ -892,7 +877,7 @@ ${getInjectedContent(ctx, "index", "body")}
892
877
  <meta charset="utf-8">
893
878
  <meta name="viewport" content="width=device-width">
894
879
  <meta http-equiv="refresh" content="0; URL=${root}${contentDir}/${nav[0]?.id}">
895
- <title>${escapedTitle}</title>
880
+ <title>${plainTitle}</title>
896
881
  <link rel="stylesheet" href="${cssRoot.index}/base.css">
897
882
  ${iconTag}
898
883
  <script>window.location.replace("${root}${contentDir}/${nav[0]?.id}");</script>
@@ -900,7 +885,7 @@ ${getInjectedContent(ctx, "index", "body")}
900
885
  </head>
901
886
  <body>
902
887
  <div class="layout">
903
- <h1>${escapedTitle}</h1>
888
+ <h1>${plainTitle}</h1>
904
889
  </div>
905
890
 
906
891
  ${counterContent}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/docsgen",
3
- "version": "0.2.44",
3
+ "version": "0.2.46",
4
4
  "description": "",
5
5
  "main": "dist/bin.js",
6
6
  "type": "module",
package/schema.json CHANGED
@@ -1 +1 @@
1
- {"$ref":"#/definitions/Config","$schema":"http://json-schema.org/draft-07/schema#","definitions":{"Config":{"additionalProperties":false,"properties":{"$schema":{"type":"string"},"append":{"$ref":"#/definitions/ContentInjectionMap%3C(%22head%22%7C%22body%22%7C%22%3Ahas-code%22)%3E"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"baseColor":{"type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"entries":{"items":{"$ref":"#/definitions/EntryConfig"},"type":"array"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkColor":{"type":"string"},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"scope":{"description":"Scope URL.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"targetIds":{"items":{"type":"string"},"type":"array"},"theme":{"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"ContentInjectionMap<(\"head\"|\"body\"|\":has-code\")>":{"additionalProperties":false,"properties":{":has-code":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"body":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"head":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]}},"type":"object"},"EntryConfig":{"additionalProperties":false,"properties":{"append":{"$ref":"#/definitions/ContentInjectionMap%3C(%22head%22%7C%22body%22%7C%22%3Ahas-code%22)%3E"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"baseColor":{"type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkColor":{"type":"string"},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"scope":{"description":"Scope URL.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"theme":{"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"Page":{"enum":["index","start","section","redirect"],"type":"string"}}}
1
+ {"$ref":"#/definitions/Config","$schema":"http://json-schema.org/draft-07/schema#","definitions":{"Config":{"additionalProperties":false,"properties":{"$schema":{"type":"string"},"append":{"$ref":"#/definitions/ContentInjectionMap%3C(%22head%22%7C%22body%22%7C%22%3Ahas-code%22)%3E"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"baseColor":{"type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"entries":{"items":{"$ref":"#/definitions/EntryConfig"},"type":"array"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkColor":{"type":"string"},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"targetIds":{"items":{"type":"string"},"type":"array"},"theme":{"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"ContentInjectionMap<(\"head\"|\"body\"|\":has-code\")>":{"additionalProperties":false,"properties":{":has-code":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"body":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]},"head":{"anyOf":[{"type":"string"},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"},{"items":{"anyOf":[{"type":"string"},{"not":{}},{"additionalProperties":false,"properties":{"content":{"type":"string"},"pages":{"items":{"$ref":"#/definitions/Page"},"type":"array"}},"type":"object"}]},"type":"array"}]}},"type":"object"},"EntryConfig":{"additionalProperties":false,"properties":{"append":{"$ref":"#/definitions/ContentInjectionMap%3C(%22head%22%7C%22body%22%7C%22%3Ahas-code%22)%3E"},"assetsDir":{"description":"Directory path for assets, relative to `dir`. If not provided, the assets will be added via the package URLs.","type":"string"},"backstory":{"description":"Backstory link URL to be added to the front page.","type":"string"},"baseColor":{"type":"string"},"cname":{"description":"Content of the './CNAME' file.","type":"string"},"contentDir":{"description":"Generated section content directory.","type":"string"},"description":{"type":"string"},"dir":{"type":"string"},"favicon":{"description":"Favicon URL.","type":"string"},"faviconType":{"type":"string"},"htmlTitle":{"type":"string"},"id":{"type":"string"},"jsorg":{"description":"As a boolean, it means whether to add the '<package_name>.js.org' domain to the './CNAME' file.\n\nAs a string, it sets the '<jsorg_value>.js.org' domain to the './CNAME' file.","type":["boolean","string"]},"linkColor":{"type":"string"},"linkMap":{"additionalProperties":{"anyOf":[{"type":"string"},{"not":{}}]},"description":"Link substitution map.","type":"object"},"mainBranch":{"type":"string"},"name":{"type":"string"},"nav":{"description":"URL of an HTML file inserted into the navigation bar.","type":"string"},"npm":{"type":"string"},"redirect":{"description":"Redirection URL.","type":"string"},"remove":{"description":"Whether to remove the GitHub Pages branch and quit.","type":"boolean"},"repo":{"type":"string"},"root":{"description":"Main page root path.","type":"string"},"singlePage":{"description":"Whether to show all sections on a single page.","type":"boolean"},"source":{"type":"string"},"targetBranch":{"description":"Target branch.","examples":["gh-pages"],"type":"string"},"theme":{"type":"string"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"Page":{"enum":["index","start","section","redirect"],"type":"string"}}}
@@ -12,7 +12,6 @@ import { getIcon } from "./getIcon.ts";
12
12
  import { getInjectedContent } from "./getInjectedContent.ts";
13
13
  import { getNav } from "./getNav.ts";
14
14
  import { getRepoLink } from "./getRepoLink.ts";
15
- import { getTitle } from "./getTitle.ts";
16
15
  import { getParsedContent } from "./parsing/getParsedContent.ts";
17
16
  import { stripHTML } from "./stripHTML.ts";
18
17
  import { toFileContent } from "./toFileContent.ts";
@@ -48,7 +47,8 @@ export async function setContent(ctx: Context) {
48
47
  root,
49
48
  contentDir = "",
50
49
  name,
51
- title: configTitle,
50
+ title,
51
+ htmlTitle,
52
52
  description: packageDescription,
53
53
  backstory,
54
54
  redirect,
@@ -128,7 +128,7 @@ ${getInjectedContent(ctx, "redirect", "body")}
128
128
  }
129
129
 
130
130
  let {
131
- title,
131
+ title: parsedTitle,
132
132
  description,
133
133
  intro,
134
134
  features,
@@ -138,9 +138,10 @@ ${getInjectedContent(ctx, "redirect", "body")}
138
138
  nav,
139
139
  } = await getParsedContent(ctx);
140
140
 
141
- let escapedTitle = configTitle
142
- ? escapeHTML(configTitle)
143
- : title || escapeHTML(name);
141
+ let plainTitle = escapeHTML(
142
+ title || stripHTML(htmlTitle || parsedTitle, true) || name,
143
+ );
144
+ let coverTitle = htmlTitle || parsedTitle || plainTitle;
144
145
 
145
146
  let descriptionContent =
146
147
  tweakTypography(description) ||
@@ -173,8 +174,8 @@ ${getInjectedContent(ctx, "redirect", "body")}
173
174
  <head>
174
175
  <meta charset="utf-8">
175
176
  <meta name="viewport" content="width=device-width, initial-scale=1">
176
- <meta name="description" content="${escapedTitle}: ${escapeHTML(stripHTML(nav[i]?.title, true))}">
177
- <title>${escapeHTML(stripHTML(nav[i]?.title, true))} | ${escapedTitle}</title>
177
+ <meta name="description" content="${plainTitle}: ${escapeHTML(stripHTML(nav[i]?.title, true))}">
178
+ <title>${escapeHTML(stripHTML(nav[i]?.title, true))} | ${plainTitle}</title>
178
179
  <link rel="stylesheet" href="${cssRoot.content}/base.css">
179
180
  <link rel="stylesheet" href="${cssRoot.content}/section.css">
180
181
  ${iconTag}
@@ -186,7 +187,7 @@ ${getInjectedContent(ctx, "redirect", "body")}
186
187
  <div class="layout">
187
188
  <div class="${navContent ? "" : "no-nav "}body">
188
189
  <main>
189
- <h1>${getTitle(ctx, { withPackageURL: true })}</h1>
190
+ <h1><a href="${root}">${coverTitle}</a></h1>
190
191
  ${content}
191
192
 
192
193
  <p class="pagenav">
@@ -229,8 +230,8 @@ ${getInjectedContent(ctx, "section", "body")}
229
230
  <head>
230
231
  <meta charset="utf-8">
231
232
  <meta name="viewport" content="width=device-width, initial-scale=1">
232
- <meta name="description" content="${escapedTitle}${escapedPackageDescription ? `: ${escapedPackageDescription}` : ""}">
233
- <title>${escapedTitle}${escapedPackageDescription ? ` | ${escapedPackageDescription}` : ""}</title>
233
+ <meta name="description" content="${plainTitle}${escapedPackageDescription ? `: ${escapedPackageDescription}` : ""}">
234
+ <title>${plainTitle}${escapedPackageDescription ? ` | ${escapedPackageDescription}` : ""}</title>
234
235
  <link rel="stylesheet" href="${cssRoot.index}/base.css">
235
236
  <link rel="stylesheet" href="${cssRoot.index}/index.css">
236
237
  ${iconTag}
@@ -243,7 +244,7 @@ ${getInjectedContent(ctx, "section", "body")}
243
244
  <main>
244
245
  <section class="b1 intro-title">
245
246
  <div class="section-content">
246
- <h1>${getTitle(ctx, { cover: true })}</h1>
247
+ <h1>${coverTitle}</h1>
247
248
  <div class="description">
248
249
  ${descriptionContent}
249
250
  </div>
@@ -296,7 +297,7 @@ ${getInjectedContent(ctx, "index", "body")}
296
297
  <meta charset="utf-8">
297
298
  <meta name="viewport" content="width=device-width">
298
299
  <meta http-equiv="refresh" content="0; URL=${root}${contentDir}/${nav[0]?.id}">
299
- <title>${escapedTitle}</title>
300
+ <title>${plainTitle}</title>
300
301
  <link rel="stylesheet" href="${cssRoot.index}/base.css">
301
302
  ${iconTag}
302
303
  <script>window.location.replace("${root}${contentDir}/${nav[0]?.id}");</script>
@@ -304,7 +305,7 @@ ${getInjectedContent(ctx, "index", "body")}
304
305
  </head>
305
306
  <body>
306
307
  <div class="layout">
307
- <h1>${escapedTitle}</h1>
308
+ <h1>${plainTitle}</h1>
308
309
  </div>
309
310
 
310
311
  ${counterContent}
@@ -1,6 +1,8 @@
1
1
  import { JSDOM } from "jsdom";
2
2
 
3
3
  export function stripHTML(content: string, replaceNbsp = false) {
4
+ if (!content) return "";
5
+
4
6
  try {
5
7
  let t = content.replaceAll("<sup>", " (").replaceAll("</sup>", ")");
6
8
  let s = new JSDOM(t).window.document.body.textContent;
@@ -48,8 +48,6 @@ export type EntryConfig = {
48
48
  /** Favicon URL. */
49
49
  favicon?: string;
50
50
  faviconType?: string;
51
- /** Scope URL. */
52
- scope?: string;
53
51
  /** Redirection URL. */
54
52
  redirect?: string;
55
53
  /** Whether to remove the GitHub Pages branch and quit. */
@@ -1,48 +0,0 @@
1
- import type { Context } from "../types/Context.ts";
2
- import { escapeHTML } from "../utils/escapeHTML.ts";
3
-
4
- type GetTitleParams = {
5
- cover?: boolean;
6
- originalContent?: string;
7
- withPackageURL?: boolean;
8
- };
9
-
10
- export function getTitle(
11
- ctx: Context,
12
- { cover, originalContent, withPackageURL }: GetTitleParams = {},
13
- ) {
14
- let { root, name, title: packageTitle, htmlTitle, scope } = ctx;
15
-
16
- if (originalContent && ![name, packageTitle].includes(originalContent.trim()))
17
- return originalContent;
18
-
19
- if (cover && htmlTitle) return htmlTitle;
20
-
21
- if (packageTitle) {
22
- let escapedTitle = escapeHTML(packageTitle);
23
-
24
- return withPackageURL
25
- ? `<a href="${root}" class="name">${escapedTitle}</a>`
26
- : `<span class="name">${escapedTitle}</span>`;
27
- }
28
-
29
- let scopeMatches = name?.match(/^(@[^/]+)\/?(.*)/);
30
-
31
- if (!scope || !scopeMatches) {
32
- let escapedName = escapeHTML(name);
33
-
34
- return withPackageURL
35
- ? `<a href="${root}" class="name">${escapedName}</a>`
36
- : `<span class="name">${escapedName}</span>`;
37
- }
38
-
39
- let title =
40
- `<a href="${scope}" class="scope">${scopeMatches[1]}</a>` +
41
- '<span class="sep">/</span>';
42
-
43
- title += withPackageURL
44
- ? `<a href="${root}" class="name">${scopeMatches[2]}</a>`
45
- : `<span class="name">${scopeMatches[2]}</span>`;
46
-
47
- return title;
48
- }