@antora/document-converter 3.0.0-beta.2 → 3.0.0-beta.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.
@@ -33,7 +33,7 @@ function convertDocument (file, contentCatalog = undefined, asciidocConfig = {})
33
33
  const doc = loadAsciiDoc(file, contentCatalog, asciidocConfig)
34
34
  if (!file.asciidoc) {
35
35
  file.asciidoc = extractAsciiDocMetadata(doc)
36
- if (doc.hasAttribute('page-partial')) file.src.contents = file.contents
36
+ if (asciidocConfig.keepSource || 'page-partial' in file.asciidoc.attributes) file.src.contents = file.contents
37
37
  }
38
38
  file.contents = Buffer.from(doc.convert())
39
39
  file.mediaType = 'text/html'
@@ -45,30 +45,33 @@ function convertDocuments (contentCatalog, siteAsciiDocConfig = {}) {
45
45
  for (const [cacheKey, mainAsciiDocConfig] of mainAsciiDocConfigs) {
46
46
  headerAsciiDocConfigs.set(cacheKey, Object.assign({}, mainAsciiDocConfig, headerOverrides))
47
47
  }
48
- return contentCatalog
49
- .getPages((page) => page.out)
50
- .map((page) => {
51
- if (page.mediaType === 'text/asciidoc') {
52
- const asciidocConfig = headerAsciiDocConfigs.get(buildCacheKey(page.src))
53
- const { attributes } = (page.asciidoc = extractAsciiDocMetadata(
54
- loadAsciiDoc(page, contentCatalog, asciidocConfig || Object.assign({}, siteAsciiDocConfig, headerOverrides))
55
- ))
56
- Object.defineProperty(page, 'title', {
57
- get () {
58
- return this.asciidoc.doctitle
59
- },
60
- })
61
- registerPageAliases(attributes['page-aliases'], page, contentCatalog)
62
- if ('page-partial' in attributes) page.src.contents = page.contents
48
+ const keepSource = siteAsciiDocConfig.keepSource
49
+ const pages = contentCatalog
50
+ .getPages((page) => {
51
+ if (page.out) {
52
+ if (page.mediaType === 'text/asciidoc') {
53
+ const asciidocConfig = headerAsciiDocConfigs.get(buildCacheKey(page.src))
54
+ const { attributes } = (page.asciidoc = extractAsciiDocMetadata(
55
+ loadAsciiDoc(page, contentCatalog, asciidocConfig || Object.assign({}, siteAsciiDocConfig, headerOverrides))
56
+ ))
57
+ Object.defineProperty(page, 'title', {
58
+ get () {
59
+ return this.asciidoc.doctitle
60
+ },
61
+ })
62
+ registerPageAliases(attributes['page-aliases'], page, contentCatalog)
63
+ if (keepSource || 'page-partial' in attributes) page.src.contents = page.contents
64
+ }
65
+ return true
63
66
  }
64
- return page
65
67
  })
66
68
  .map((page) =>
67
69
  page.mediaType === 'text/asciidoc'
68
70
  ? convertDocument(page, contentCatalog, mainAsciiDocConfigs.get(buildCacheKey(page.src)) || siteAsciiDocConfig)
69
71
  : page
70
72
  )
71
- .map((page) => delete page.src.contents && page)
73
+ if (!keepSource) pages.forEach((page) => delete page.src.contents)
74
+ return pages
72
75
  }
73
76
 
74
77
  function buildCacheKey ({ component, version }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antora/document-converter",
3
- "version": "3.0.0-beta.2",
3
+ "version": "3.0.0-beta.3",
4
4
  "description": "Converts AsciiDoc documents to embeddable HTML for use in an Antora documentation pipeline.",
5
5
  "license": "MPL-2.0",
6
6
  "author": "OpenDevise Inc. (https://opendevise.com)",
@@ -17,7 +17,7 @@
17
17
  },
18
18
  "main": "lib/index.js",
19
19
  "dependencies": {
20
- "@antora/asciidoc-loader": "3.0.0-beta.2"
20
+ "@antora/asciidoc-loader": "3.0.0-beta.3"
21
21
  },
22
22
  "engines": {
23
23
  "node": ">=12.21.0"
@@ -35,5 +35,5 @@
35
35
  "static site",
36
36
  "web publishing"
37
37
  ],
38
- "gitHead": "5cd3f9cc70622e465cb44daf1aa2035ed5a35f54"
38
+ "gitHead": "45da95a2e2dea538379d2d9f42013d2208fb86c3"
39
39
  }