@t8/docsgen 0.3.3 → 0.3.4

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
@@ -318,7 +318,7 @@ function getIcon({ favicon, faviconType }) {
318
318
  }
319
319
 
320
320
  // src/bin/getInjectedContent.ts
321
- function getInjectedContent(ctx, page, target, mode = "append") {
321
+ function getInjectedContent(ctx, page, target, mode) {
322
322
  let injectedContent = ctx[mode]?.[target];
323
323
  if (!injectedContent) return "";
324
324
  return (Array.isArray(injectedContent) ? injectedContent : [injectedContent]).reduce((s, item) => {
@@ -704,15 +704,17 @@ async function setContent(ctx) {
704
704
  <!DOCTYPE html>
705
705
  <html lang="en" class="blank">
706
706
  <head>
707
+ ${getInjectedContent(ctx, "redirect", "head", "prepend")}
707
708
  <meta charset="utf-8">
708
709
  <meta name="viewport" content="width=device-width">
709
710
  <meta http-equiv="refresh" content="0; URL=${escapedRedirect}">
710
711
  ${iconTag}
711
- ${getInjectedContent(ctx, "redirect", "head")}
712
+ ${getInjectedContent(ctx, "redirect", "head", "append")}
712
713
  </head>
713
714
  <body>
715
+ ${getInjectedContent(ctx, "redirect", "body", "prepend")}
714
716
  ${counterContent}
715
- ${getInjectedContent(ctx, "redirect", "body")}
717
+ ${getInjectedContent(ctx, "redirect", "body", "append")}
716
718
  <script>window.location.replace("${escapedRedirect}");</script>
717
719
  </body>
718
720
  </html>
@@ -755,6 +757,7 @@ ${getInjectedContent(ctx, "redirect", "body")}
755
757
  <!DOCTYPE html>
756
758
  <html lang="en">
757
759
  <head>
760
+ ${getInjectedContent(ctx, "section", "head", "prepend")}
758
761
  <meta charset="utf-8">
759
762
  <meta name="viewport" content="width=device-width, initial-scale=1">
760
763
  <meta name="description" content="${plainTitle}: ${escapeHTML(stripHTML(nav[i]?.title, true))}">
@@ -764,9 +767,10 @@ ${getInjectedContent(ctx, "redirect", "body")}
764
767
  ${iconTag}
765
768
  ${nav[i + 1]?.id ? `<link rel="prefetch" href="${root}${contentDir}/${nav[i + 1]?.id}">` : ""}
766
769
  ${nav[i - 1]?.id ? `<link rel="prefetch" href="${root}${contentDir}/${nav[i - 1]?.id}">` : ""}
767
- ${getInjectedContent(ctx, "section", "head")}
770
+ ${getInjectedContent(ctx, "section", "head", "append")}
768
771
  </head>
769
772
  <body>
773
+ ${getInjectedContent(ctx, "section", "body", "prepend")}
770
774
  <div class="layout">
771
775
  <div class="${navContent ? "" : "no-nav "}body">
772
776
  <main>
@@ -792,9 +796,9 @@ ${navContent.replace(
792
796
  </div>
793
797
  </div>
794
798
 
795
- ${content.includes("<pre><code ") ? getInjectedContent(ctx, "section", ":has-code") || getDefaultCodeStyleContent(cssRoot.content) : ""}
799
+ ${content.includes("<pre><code ") ? getInjectedContent(ctx, "section", ":has-code", "append") || getDefaultCodeStyleContent(cssRoot.content) : ""}
796
800
  ${counterContent}
797
- ${getInjectedContent(ctx, "section", "body")}
801
+ ${getInjectedContent(ctx, "section", "body", "append")}
798
802
  </body>
799
803
  </html>
800
804
  `)
@@ -806,6 +810,7 @@ ${getInjectedContent(ctx, "section", "body")}
806
810
  <!DOCTYPE html>
807
811
  <html lang="en">
808
812
  <head>
813
+ ${getInjectedContent(ctx, "index", "head", "prepend")}
809
814
  <meta charset="utf-8">
810
815
  <meta name="viewport" content="width=device-width, initial-scale=1">
811
816
  <meta name="description" content="${plainTitle}${escapedPackageDescription ? `: ${escapedPackageDescription}` : ""}">
@@ -815,13 +820,15 @@ ${getInjectedContent(ctx, "section", "body")}
815
820
  ${iconTag}
816
821
  <link rel="prefetch" href="${root}start">
817
822
  ${nav[0] ? `<link rel="prefetch" href="${root}${contentDir}/${nav[0]?.id ?? ""}">` : ""}
818
- ${getInjectedContent(ctx, "index", "head")}
823
+ ${getInjectedContent(ctx, "index", "head", "append")}
819
824
  </head>
820
825
  <body>
826
+ ${getInjectedContent(ctx, "index", "body", "prepend")}
821
827
  <div class="layout">
822
828
  <main>
823
829
  <section class="aux intro-title">
824
830
  <div class="section-content">
831
+ ${getInjectedContent(ctx, "index", "cover", "prepend")}
825
832
  <h1>${coverTitle}</h1>
826
833
  <div class="description">
827
834
  ${descriptionContent}
@@ -833,6 +840,7 @@ ${getInjectedContent(ctx, "section", "body")}
833
840
  </p>
834
841
  ${backstory ? `<p class="ref"><a href="${backstory}">Backstory</a></p>` : ""}
835
842
  <p class="installation"><code>${installation}</code></p>
843
+ ${getInjectedContent(ctx, "index", "cover", "append")}
836
844
  </div>
837
845
  </section>
838
846
  ${intro || features || note ? `
@@ -850,9 +858,9 @@ ${intro || features || note ? `
850
858
  </main>
851
859
  </div>
852
860
 
853
- ${[description, intro, features, note].some((s) => s.includes("<pre><code ")) ? getInjectedContent(ctx, "index", ":has-code") || getDefaultCodeStyleContent(cssRoot.index) : ""}
861
+ ${[description, intro, features, note].some((s) => s.includes("<pre><code ")) ? getInjectedContent(ctx, "index", ":has-code", "append") || getDefaultCodeStyleContent(cssRoot.index) : ""}
854
862
  ${counterContent}
855
- ${getInjectedContent(ctx, "index", "body")}
863
+ ${getInjectedContent(ctx, "index", "body", "append")}
856
864
  </body>
857
865
  </html>
858
866
  `)
@@ -863,6 +871,7 @@ ${getInjectedContent(ctx, "index", "body")}
863
871
  <!DOCTYPE html>
864
872
  <html lang="en" class="blank">
865
873
  <head>
874
+ ${getInjectedContent(ctx, "start", "head", "prepend")}
866
875
  <meta charset="utf-8">
867
876
  <meta name="viewport" content="width=device-width">
868
877
  <meta http-equiv="refresh" content="0; URL=${root}${contentDir}/${nav[0]?.id}">
@@ -870,15 +879,16 @@ ${getInjectedContent(ctx, "index", "body")}
870
879
  <link rel="stylesheet" href="${cssRoot.index}/base.css">
871
880
  ${iconTag}
872
881
  <script>window.location.replace("${root}${contentDir}/${nav[0]?.id}");</script>
873
- ${getInjectedContent(ctx, "start", "head")}
882
+ ${getInjectedContent(ctx, "start", "head", "append")}
874
883
  </head>
875
884
  <body>
885
+ ${getInjectedContent(ctx, "start", "body", "prepend")}
876
886
  <div class="layout">
877
887
  <h1>${plainTitle}</h1>
878
888
  </div>
879
889
 
880
890
  ${counterContent}
881
- ${getInjectedContent(ctx, "start", "body")}
891
+ ${getInjectedContent(ctx, "start", "body", "append")}
882
892
  </body>
883
893
  </html>
884
894
  `)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t8/docsgen",
3
- "version": "0.3.3",
3
+ "version": "0.3.4",
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"},"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"]},"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"},"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"},"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"]},"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"},"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"},"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"},"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"]},"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"},"prepend":{"$ref":"#/definitions/ContentInjectionMap"},"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"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"ContentInjectionMap":{"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"}]},"cover":{"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"},"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"},"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"]},"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"},"prepend":{"$ref":"#/definitions/ContentInjectionMap"},"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"},"title":{"type":"string"},"version":{"type":"string"},"ymid":{"type":["number","string"]}},"type":"object"},"Page":{"enum":["index","start","section","redirect"],"type":"string"}}}
@@ -6,7 +6,7 @@ export function getInjectedContent(
6
6
  ctx: Context,
7
7
  page: Page,
8
8
  target: ContentInjectionTarget,
9
- mode: "append" | undefined = "append",
9
+ mode: "append" | "prepend",
10
10
  ) {
11
11
  let injectedContent = ctx[mode]?.[target];
12
12
 
@@ -94,15 +94,17 @@ export async function setContent(ctx: Context) {
94
94
  <!DOCTYPE html>
95
95
  <html lang="en" class="blank">
96
96
  <head>
97
+ ${getInjectedContent(ctx, "redirect", "head", "prepend")}
97
98
  <meta charset="utf-8">
98
99
  <meta name="viewport" content="width=device-width">
99
100
  <meta http-equiv="refresh" content="0; URL=${escapedRedirect}">
100
101
  ${iconTag}
101
- ${getInjectedContent(ctx, "redirect", "head")}
102
+ ${getInjectedContent(ctx, "redirect", "head", "append")}
102
103
  </head>
103
104
  <body>
105
+ ${getInjectedContent(ctx, "redirect", "body", "prepend")}
104
106
  ${counterContent}
105
- ${getInjectedContent(ctx, "redirect", "body")}
107
+ ${getInjectedContent(ctx, "redirect", "body", "append")}
106
108
  <script>window.location.replace("${escapedRedirect}");</script>
107
109
  </body>
108
110
  </html>
@@ -157,6 +159,7 @@ ${getInjectedContent(ctx, "redirect", "body")}
157
159
  <!DOCTYPE html>
158
160
  <html lang="en">
159
161
  <head>
162
+ ${getInjectedContent(ctx, "section", "head", "prepend")}
160
163
  <meta charset="utf-8">
161
164
  <meta name="viewport" content="width=device-width, initial-scale=1">
162
165
  <meta name="description" content="${plainTitle}: ${escapeHTML(stripHTML(nav[i]?.title, true))}">
@@ -166,9 +169,10 @@ ${getInjectedContent(ctx, "redirect", "body")}
166
169
  ${iconTag}
167
170
  ${nav[i + 1]?.id ? `<link rel="prefetch" href="${root}${contentDir}/${nav[i + 1]?.id}">` : ""}
168
171
  ${nav[i - 1]?.id ? `<link rel="prefetch" href="${root}${contentDir}/${nav[i - 1]?.id}">` : ""}
169
- ${getInjectedContent(ctx, "section", "head")}
172
+ ${getInjectedContent(ctx, "section", "head", "append")}
170
173
  </head>
171
174
  <body>
175
+ ${getInjectedContent(ctx, "section", "body", "prepend")}
172
176
  <div class="layout">
173
177
  <div class="${navContent ? "" : "no-nav "}body">
174
178
  <main>
@@ -196,12 +200,12 @@ ${navContent.replace(
196
200
 
197
201
  ${
198
202
  content.includes("<pre><code ")
199
- ? getInjectedContent(ctx, "section", ":has-code") ||
203
+ ? getInjectedContent(ctx, "section", ":has-code", "append") ||
200
204
  getDefaultCodeStyleContent(cssRoot.content)
201
205
  : ""
202
206
  }
203
207
  ${counterContent}
204
- ${getInjectedContent(ctx, "section", "body")}
208
+ ${getInjectedContent(ctx, "section", "body", "append")}
205
209
  </body>
206
210
  </html>
207
211
  `),
@@ -213,6 +217,7 @@ ${getInjectedContent(ctx, "section", "body")}
213
217
  <!DOCTYPE html>
214
218
  <html lang="en">
215
219
  <head>
220
+ ${getInjectedContent(ctx, "index", "head", "prepend")}
216
221
  <meta charset="utf-8">
217
222
  <meta name="viewport" content="width=device-width, initial-scale=1">
218
223
  <meta name="description" content="${plainTitle}${escapedPackageDescription ? `: ${escapedPackageDescription}` : ""}">
@@ -222,13 +227,15 @@ ${getInjectedContent(ctx, "section", "body")}
222
227
  ${iconTag}
223
228
  <link rel="prefetch" href="${root}start">
224
229
  ${nav[0] ? `<link rel="prefetch" href="${root}${contentDir}/${nav[0]?.id ?? ""}">` : ""}
225
- ${getInjectedContent(ctx, "index", "head")}
230
+ ${getInjectedContent(ctx, "index", "head", "append")}
226
231
  </head>
227
232
  <body>
233
+ ${getInjectedContent(ctx, "index", "body", "prepend")}
228
234
  <div class="layout">
229
235
  <main>
230
236
  <section class="aux intro-title">
231
237
  <div class="section-content">
238
+ ${getInjectedContent(ctx, "index", "cover", "prepend")}
232
239
  <h1>${coverTitle}</h1>
233
240
  <div class="description">
234
241
  ${descriptionContent}
@@ -240,6 +247,7 @@ ${getInjectedContent(ctx, "section", "body")}
240
247
  </p>
241
248
  ${backstory ? `<p class="ref"><a href="${backstory}">Backstory</a></p>` : ""}
242
249
  <p class="installation"><code>${installation}</code></p>
250
+ ${getInjectedContent(ctx, "index", "cover", "append")}
243
251
  </div>
244
252
  </section>
245
253
  ${
@@ -263,12 +271,12 @@ ${
263
271
 
264
272
  ${
265
273
  [description, intro, features, note].some((s) => s.includes("<pre><code "))
266
- ? getInjectedContent(ctx, "index", ":has-code") ||
274
+ ? getInjectedContent(ctx, "index", ":has-code", "append") ||
267
275
  getDefaultCodeStyleContent(cssRoot.index)
268
276
  : ""
269
277
  }
270
278
  ${counterContent}
271
- ${getInjectedContent(ctx, "index", "body")}
279
+ ${getInjectedContent(ctx, "index", "body", "append")}
272
280
  </body>
273
281
  </html>
274
282
  `),
@@ -279,6 +287,7 @@ ${getInjectedContent(ctx, "index", "body")}
279
287
  <!DOCTYPE html>
280
288
  <html lang="en" class="blank">
281
289
  <head>
290
+ ${getInjectedContent(ctx, "start", "head", "prepend")}
282
291
  <meta charset="utf-8">
283
292
  <meta name="viewport" content="width=device-width">
284
293
  <meta http-equiv="refresh" content="0; URL=${root}${contentDir}/${nav[0]?.id}">
@@ -286,15 +295,16 @@ ${getInjectedContent(ctx, "index", "body")}
286
295
  <link rel="stylesheet" href="${cssRoot.index}/base.css">
287
296
  ${iconTag}
288
297
  <script>window.location.replace("${root}${contentDir}/${nav[0]?.id}");</script>
289
- ${getInjectedContent(ctx, "start", "head")}
298
+ ${getInjectedContent(ctx, "start", "head", "append")}
290
299
  </head>
291
300
  <body>
301
+ ${getInjectedContent(ctx, "start", "body", "prepend")}
292
302
  <div class="layout">
293
303
  <h1>${plainTitle}</h1>
294
304
  </div>
295
305
 
296
306
  ${counterContent}
297
- ${getInjectedContent(ctx, "start", "body")}
307
+ ${getInjectedContent(ctx, "start", "body", "append")}
298
308
  </body>
299
309
  </html>
300
310
  `),
@@ -9,6 +9,6 @@ type InjectedContent =
9
9
  pages?: Page[];
10
10
  };
11
11
 
12
- export type ContentInjectionMap<T extends ContentInjectionTarget> = Partial<
13
- Record<T, InjectedContent | InjectedContent[]>
12
+ export type ContentInjectionMap = Partial<
13
+ Record<ContentInjectionTarget, InjectedContent | InjectedContent[]>
14
14
  >;
@@ -1 +1 @@
1
- export type ContentInjectionTarget = "head" | "body" | ":has-code";
1
+ export type ContentInjectionTarget = "head" | "body" | ":has-code" | "cover";
@@ -59,7 +59,8 @@ export type EntryConfig = {
59
59
  */
60
60
  jsorg?: boolean | string;
61
61
  ymid?: number | string;
62
- append?: ContentInjectionMap<"head" | "body" | ":has-code">;
62
+ append?: ContentInjectionMap;
63
+ prepend?: ContentInjectionMap;
63
64
  /** Link substitution map. */
64
65
  linkMap?: Record<string, string | undefined>;
65
66
  };