coralite 0.6.4 → 0.6.5
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/change-logs.md +18 -0
- package/lib/coralite.js +3 -5
- package/lib/html-module.js +14 -7
- package/lib/parse.js +4 -16
- package/package.json +1 -1
- package/types/index.js +9 -0
package/change-logs.md
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
# 🎁 Release notes (`v0.6.5`)
|
|
2
|
+
|
|
3
|
+
## Changes
|
|
4
|
+
- 4610baa (HEAD -> main, tag: v0.6.5, origin/main) chore: version bump - (*Thomas David*)
|
|
5
|
+
- be2511d ci: remove windows due to unavailability - (*Thomas David*)
|
|
6
|
+
- 821f212 test: cover aggregate filter option - (*Thomas David*)
|
|
7
|
+
- 48eaa76 docs: add CoraliteAggregate to aggregate param - (*Thomas David*)
|
|
8
|
+
- 39ab5ba docs: add CoraliteAggregate typedef - (*Thomas David*)
|
|
9
|
+
- 148dee9 feat: add filter to aggregate function - (*Thomas David*)
|
|
10
|
+
- 15cf0fd docs: add CoraliteAggregate typedef - (*Thomas David*)
|
|
11
|
+
- dbb5b8f feat: remove unused parseHTMLMeta ignoreByAttribute param - (*Thomas David*)
|
|
12
|
+
|
|
13
|
+
## Metadata
|
|
14
|
+
```
|
|
15
|
+
This version -------- v0.6.5
|
|
16
|
+
Previous version ---- v0.6.4
|
|
17
|
+
Total commits ------- 8
|
|
18
|
+
```
|
|
1
19
|
# 🎁 Release notes (`v0.6.4`)
|
|
2
20
|
|
|
3
21
|
## Changes
|
package/lib/coralite.js
CHANGED
|
@@ -5,10 +5,10 @@ import render from 'dom-serializer'
|
|
|
5
5
|
* @import {
|
|
6
6
|
* CoraliteElement,
|
|
7
7
|
* CoraliteTextNode,
|
|
8
|
-
* CoraliteAggregateTemplate,
|
|
9
8
|
* CoraliteAnyNode,
|
|
10
9
|
* CoraliteModule,
|
|
11
|
-
* CoraliteResult
|
|
10
|
+
* CoraliteResult,
|
|
11
|
+
* CoraliteAggregate
|
|
12
12
|
* } from '#types'
|
|
13
13
|
*/
|
|
14
14
|
|
|
@@ -50,9 +50,7 @@ export async function defineComponent (options) {
|
|
|
50
50
|
/**
|
|
51
51
|
* Aggregates HTML content from specified paths into a single collection of components.
|
|
52
52
|
*
|
|
53
|
-
* @param {
|
|
54
|
-
* @param {CoraliteAggregateTemplate | string} options.template - Templates used to display the result
|
|
55
|
-
* @param {string} options.path - The path to aggregate, relative to pages directory
|
|
53
|
+
* @param {CoraliteAggregate} options - Configuration object for the aggregation process
|
|
56
54
|
* @returns {Promise<(CoraliteElement | CoraliteTextNode)[]>}
|
|
57
55
|
*/
|
|
58
56
|
export async function aggregate (options) {
|
package/lib/html-module.js
CHANGED
|
@@ -4,17 +4,13 @@ import { createComponent, parseHTMLMeta } from './parse.js'
|
|
|
4
4
|
import { existsSync } from 'node:fs'
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @import { CoraliteTokenOptions, CoraliteModule, CoraliteDocument, CoraliteModuleValues, CoraliteAggregateTemplate } from '#types'
|
|
7
|
+
* @import { CoraliteTokenOptions, CoraliteModule, CoraliteDocument, CoraliteModuleValues, CoraliteAggregateTemplate, CoraliteAggregate } from '#types'
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Aggregates HTML content from specified paths into a single collection of components.
|
|
12
12
|
*
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {string} options.path - The path to aggregate, relative to pages directory
|
|
15
|
-
* @param {CoraliteAggregateTemplate | string} options.template - Templates used to display the result
|
|
16
|
-
* @param {boolean} [options.recursive] - Whether to recursively search subdirectories
|
|
17
|
-
* @param {CoraliteTokenOptions} [options.tokens] - Token configuration options
|
|
13
|
+
* @param {CoraliteAggregate} options - Configuration object for the aggregation process
|
|
18
14
|
* @param {CoraliteModuleValues} values - Default token values
|
|
19
15
|
* @param {Object.<string, CoraliteModule>} components - Available components library
|
|
20
16
|
* @param {CoraliteDocument} document - Current document being processed
|
|
@@ -66,8 +62,10 @@ export async function aggregate (options, values, components, document) {
|
|
|
66
62
|
|
|
67
63
|
for (let i = 0; i < pages.length; i++) {
|
|
68
64
|
const page = pages[i]
|
|
69
|
-
const meta = parseHTMLMeta(page.content
|
|
65
|
+
const meta = parseHTMLMeta(page.content)
|
|
70
66
|
const pageValues = Object.assign({}, values)
|
|
67
|
+
let isFilter = !!options.filter
|
|
68
|
+
let ignorePage = false
|
|
71
69
|
|
|
72
70
|
for (const key in meta) {
|
|
73
71
|
if (Object.prototype.hasOwnProperty.call(meta, key)) {
|
|
@@ -77,6 +75,10 @@ export async function aggregate (options, values, components, document) {
|
|
|
77
75
|
const item = data[i]
|
|
78
76
|
let suffix = ''
|
|
79
77
|
|
|
78
|
+
if (isFilter && !ignorePage) {
|
|
79
|
+
ignorePage = options.filter(item)
|
|
80
|
+
}
|
|
81
|
+
|
|
80
82
|
if (i > 0) {
|
|
81
83
|
suffix = '_' + i
|
|
82
84
|
}
|
|
@@ -86,6 +88,11 @@ export async function aggregate (options, values, components, document) {
|
|
|
86
88
|
}
|
|
87
89
|
}
|
|
88
90
|
|
|
91
|
+
// break if page is filtered
|
|
92
|
+
if (isFilter && !ignorePage) {
|
|
93
|
+
break
|
|
94
|
+
}
|
|
95
|
+
|
|
89
96
|
const component = await createComponent({
|
|
90
97
|
id: componentId,
|
|
91
98
|
values: pageValues,
|
package/lib/parse.js
CHANGED
|
@@ -19,8 +19,8 @@ import { invalidCustomTags, validTags } from './tags.js'
|
|
|
19
19
|
* CoraliteDocumentRoot,
|
|
20
20
|
* CoraliteContentNode,
|
|
21
21
|
* CoraliteModuleValues,
|
|
22
|
-
*
|
|
23
|
-
|
|
22
|
+
* IgnoreByAttribute,
|
|
23
|
+
CoraliteAggregate
|
|
24
24
|
* } from '#types'
|
|
25
25
|
*/
|
|
26
26
|
|
|
@@ -153,7 +153,6 @@ export function parseHTMLDocument (html, path, ignoreByAttribute) {
|
|
|
153
153
|
* Parses HTML string containing meta tags and extracts associated metadata.
|
|
154
154
|
*
|
|
155
155
|
* @param {string} string - HTML content containing meta tags
|
|
156
|
-
* @param {IgnoreByAttribute} ignoreByAttribute - IgnoreByAttribute option (optional) - If provided and true then the HTML tags will be ignored by this attribute name(s)
|
|
157
156
|
* @returns {Object.<string, CoraliteToken[]>}
|
|
158
157
|
*
|
|
159
158
|
* @example
|
|
@@ -168,7 +167,7 @@ export function parseHTMLDocument (html, path, ignoreByAttribute) {
|
|
|
168
167
|
* //}
|
|
169
168
|
* ```
|
|
170
169
|
*/
|
|
171
|
-
export function parseHTMLMeta (string
|
|
170
|
+
export function parseHTMLMeta (string) {
|
|
172
171
|
// stack to keep track of current element hierarchy
|
|
173
172
|
const stack = []
|
|
174
173
|
/** @type {Object.<string, CoraliteToken[]>} */
|
|
@@ -179,15 +178,6 @@ export function parseHTMLMeta (string, ignoreByAttribute) {
|
|
|
179
178
|
onopentag (name, attributes) {
|
|
180
179
|
if (name === 'meta') {
|
|
181
180
|
if (attributes.content) {
|
|
182
|
-
if (ignoreByAttribute) {
|
|
183
|
-
// ignore meta tags by attribute name
|
|
184
|
-
const ignore = findAttributesToIgnore(ignoreByAttribute, attributes)
|
|
185
|
-
|
|
186
|
-
if (ignore) {
|
|
187
|
-
return
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
|
|
191
181
|
if (attributes.property) {
|
|
192
182
|
addMetadata(meta, attributes.property, attributes.content)
|
|
193
183
|
}
|
|
@@ -761,9 +751,7 @@ export async function parseScript ({
|
|
|
761
751
|
*/
|
|
762
752
|
|
|
763
753
|
/**
|
|
764
|
-
* @param {
|
|
765
|
-
* @param {CoraliteAggregateTemplate} options.template - Templates used to display the result
|
|
766
|
-
* @param {string} options.path
|
|
754
|
+
* @param {CoraliteAggregate} options
|
|
767
755
|
*/
|
|
768
756
|
async aggregate (options) {
|
|
769
757
|
/** @type {string} */
|
package/package.json
CHANGED
package/types/index.js
CHANGED
|
@@ -141,3 +141,12 @@
|
|
|
141
141
|
/**
|
|
142
142
|
* @typedef {Array<Array<string, string>>} IgnoreByAttribute - An array of attribute names and values to ignore by element type.
|
|
143
143
|
*/
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* @typedef {Object} CoraliteAggregate – Configuration object for the aggregation process
|
|
147
|
+
* @property {string} path - The path to aggregate, relative to pages directory
|
|
148
|
+
* @property {CoraliteAggregateTemplate | string} template - Templates used to display the result
|
|
149
|
+
* @property {Function} [filter] - A function to filter out unwanted elements from the aggregated content.
|
|
150
|
+
* @property {boolean} [recursive] - Whether to recursively search subdirectories
|
|
151
|
+
* @property {CoraliteTokenOptions} [tokens] - Token configuration options
|
|
152
|
+
*/
|