coralite 0.7.1 → 0.8.1

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.
@@ -28,6 +28,9 @@ jobs:
28
28
  - name: Install dependencies
29
29
  run: pnpm install
30
30
 
31
+ - name: Add symlink
32
+ run: pnpm link
33
+
31
34
  - name: Build HTML from templates
32
35
  run: pnpm run html
33
36
 
@@ -51,5 +51,8 @@ jobs:
51
51
  - name: Install dependencies
52
52
  run: pnpm install
53
53
 
54
+ - name: Add symlink
55
+ run: pnpm link
56
+
54
57
  - name: Build HTML from templates
55
58
  run: pnpm run html
package/bin/coralite.js CHANGED
@@ -1,6 +1,6 @@
1
- #!/usr/bin/env node --experimental-vm-modules
1
+ #!/usr/bin/env node --experimental-vm-modules --experimental-import-meta-resolve
2
2
 
3
- import { getSubDirectory, getPkg, coralite } from '#lib'
3
+ import { getPkg, coralite } from '#lib'
4
4
  import { Command } from 'commander'
5
5
  import { join } from 'node:path'
6
6
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
@@ -56,8 +56,8 @@ if (options.dryRun) {
56
56
  const document = documents[i]
57
57
 
58
58
  process.stdout.write('\n' + PAD + kleur.green('Document is ready!\n\n'))
59
- process.stdout.write(PAD + `${kleur.bold('- Path:')} ${join(document.item.parentPath, document.item.name)}\n`)
60
- process.stdout.write(PAD + `${kleur.bold('- Built in:')} ${Math.floor(document.duration)}ms\n\n`)
59
+ process.stdout.write(PAD + `${kleur.bold('- Path:')} ${document.item.path.pathname}\n`)
60
+ process.stdout.write(PAD + `${kleur.bold('- Built in:')} ${Math.floor(document.duration)}ms\n\n`)
61
61
  process.stdout.write(border + kleur.inverse(' Content start ') + border + '\n\n')
62
62
  process.stdout.write(document.html)
63
63
  process.stdout.write('\n\n' + border + kleur.inverse(' Content end ') + border + '\n')
@@ -65,15 +65,13 @@ if (options.dryRun) {
65
65
  } else {
66
66
  for (let i = 0; i < documents.length; i++) {
67
67
  const document = documents[i]
68
- // get pages sub directory
69
- const subDir = getSubDirectory(pages, document.item.parentPath)
70
- const dir = join(output, subDir)
68
+ const dir = join(output, document.item.path.dirname)
71
69
 
72
70
  if (!existsSync(dir)) {
73
71
  // create directory
74
72
  mkdirSync(dir)
75
73
  }
76
74
 
77
- writeFileSync(join(dir, document.item.name), document.html)
75
+ writeFileSync(join(output, document.item.path.pathname), document.html)
78
76
  }
79
77
  }
package/changelog.md CHANGED
@@ -1,12 +1,89 @@
1
+ # 🎁 Release notes (`v0.8.1`)
2
+
3
+ ## Changes
4
+ - 5d1b926 (HEAD -> main, tag: v0.8.1, origin/main) chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
5
+ - d25721b ci: fix linux symlink - ([Thomas David](https://codeberg.org/tjdavid))
6
+ - 934e063 ci: add coralite globally - ([Thomas David](https://codeberg.org/tjdavid))
7
+ - c46cf59 ci: add params to symlink - ([Thomas David](https://codeberg.org/tjdavid))
8
+ - a074fba ci: add symlink step to CI workflows - ([Thomas David](https://codeberg.org/tjdavid))
9
+ - 8351b36 fix(parser): add check for slot attribute before assigning to named slot - ([Thomas David](https://codeberg.org/tjdavid))
10
+ - 4c939b7 refactor: remove getSubDirectory function - ([Thomas David](https://codeberg.org/tjdavid))
11
+ - e2a82e0 refactor: use document.path properties for directory handling - ([Thomas David](https://codeberg.org/tjdavid))
12
+ - b6ca133 refactor: Update template variables to use $prefix notation - ([Thomas David](https://codeberg.org/tjdavid))
13
+ - 263e6a5 chore: update bin path - ([Thomas David](https://codeberg.org/tjdavid))
14
+ - b412225 chore: add bugs URL - ([Thomas David](https://codeberg.org/tjdavid))
15
+ - 2dc40c5 chore: update changelog - ([Thomas David](https://codeberg.org/tjdavid))
16
+ - f4ba391 chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
17
+
18
+ ## Metadata
19
+ ```
20
+ This version -------- v0.8.1
21
+ Previous version ---- v0.8.0
22
+ Total commits ------- 13
23
+ ```
24
+ # 🎁 Release notes (`v0.8.0`)
25
+
26
+ ## Changes
27
+ - 25c4669 (HEAD -> main, tag: v0.8.0, origin/main) feat(aggregate): add pagination support - ([Thomas David](https://codeberg.org/tjdavid))
28
+ - 1268e3c fix(aggregate): handle non-array metadata values correctly - ([Thomas David](https://codeberg.org/tjdavid))
29
+ - 42c3ae0 fix(aggregate): handle string and non-array limit values correctly - ([Thomas David](https://codeberg.org/tjdavid))
30
+ - 0538a80 fix(aggregate): Handle offset parsing robustly for numeric conversion - ([Thomas David](https://codeberg.org/tjdavid))
31
+ - 4d2fe56 feat(aggregate): Add metadata-based page filtering using options.filter - ([Thomas David](https://codeberg.org/tjdavid))
32
+ - 176c7f3 feat(lib/html-module): add support for custom sort function in aggregate - ([Thomas David](https://codeberg.org/tjdavid))
33
+ - 3acfb99 feat(lib/html-module): add pagination support with token validation - ([Thomas David](https://codeberg.org/tjdavid))
34
+ - 41b0e10 refactor(lib): integrate htmlparser2 and dom-serializer for improved HTML parsing - ([Thomas David](https://codeberg.org/tjdavid))
35
+ - 0c7fb5e refactor(html-module): update aggregate to use component element children and return Aggregation object - ([Thomas David](https://codeberg.org/tjdavid))
36
+ - 6bb83d3 refactor: restructure document rendering logic and add HTMLData type support - ([Thomas David](https://codeberg.org/tjdavid))
37
+ - 8d4b43c refactor: move coralite rendering logic to new renderDocument function - ([Thomas David](https://codeberg.org/tjdavid))
38
+ - c81786e types: add pagination configuration to CoraliteAggregate - ([Thomas David](https://codeberg.org/tjdavid))
39
+ - c8ddec4 feat(metadata): Update metadata token prefix to '$' - ([Thomas David](https://codeberg.org/tjdavid))
40
+ - ee57e18 feat: add parsePagination function for handling pagination templates - ([Thomas David](https://codeberg.org/tjdavid))
41
+ - 4471482 types: add Aggregation typedef and update imports - ([Thomas David](https://codeberg.org/tjdavid))
42
+ - 2772969 docs: Improve JSDoc clarity for parseHTMLDocument function - ([Thomas David](https://codeberg.org/tjdavid))
43
+ - 37e79db refactor: restructure html file path properties - ([Thomas David](https://codeberg.org/tjdavid))
44
+ - dab3a61 refactor: Export createTextNode function - ([Thomas David](https://codeberg.org/tjdavid))
45
+ - c538186 fix: handle custom element creation with proper tag validation - ([Thomas David](https://codeberg.org/tjdavid))
46
+ - 58d101d refactor: update addMetadata to support non-array values as array of objects - ([Thomas David](https://codeberg.org/tjdavid))
47
+ - d0fa67c docs: update parseHTMLMeta parameters and example documentation - ([Thomas David](https://codeberg.org/tjdavid))
48
+ - de8035e fix: correct path calculation in parseScript function - ([Thomas David](https://codeberg.org/tjdavid))
49
+ - b9c94ee refactor(parse): use scriptResult.values instead of computedValues when merging values - ([Thomas David](https://codeberg.org/tjdavid))
50
+ - 7b0be0c fix: correct script parsing path resolution and module identifier - ([Thomas David](https://codeberg.org/tjdavid))
51
+ - 803aa3e refactor(parse): refactor aggregate method to use helper and collect documents - ([Thomas David](https://codeberg.org/tjdavid))
52
+ - 2c77b44 fix: add warning when component is not found - ([Thomas David](https://codeberg.org/tjdavid))
53
+ - 885fd6c refactor(parseModule): remove html parameter and introduce lineOffset property - ([Thomas David](https://codeberg.org/tjdavid))
54
+ - 84c8a74 types: allow string or CoraliteToken[] as meta value types - ([Thomas David](https://codeberg.org/tjdavid))
55
+ - 0b9ce81 refactor: merge html.path into path object in parseHTMLDocument - ([Thomas David](https://codeberg.org/tjdavid))
56
+ - 1964a60 types: update JSDoc types for aggregate callbacks - ([Thomas David](https://codeberg.org/tjdavid))
57
+ - 2205c1a types: Refactor types to introduce CoraliteFilePath and improve module interface definitions - ([Thomas David](https://codeberg.org/tjdavid))
58
+ - c37fa7c docs: add CoraliteComponent import - ([Thomas David](https://codeberg.org/tjdavid))
59
+ - 281e07e refactor: rename getHTML to getHtmlFiles and add getHtmlFile function - ([Thomas David](https://codeberg.org/tjdavid))
60
+ - f91251a types: Update return type of createComponent to CoraliteComponent - ([Thomas David](https://codeberg.org/tjdavid))
61
+ - d6fab1e refactor: use cleanKeys for consistent naming conventions - ([Thomas David](https://codeberg.org/tjdavid))
62
+ - dfe3b06 docs: update aggregate comments - ([Thomas David](https://codeberg.org/tjdavid))
63
+ - 6a495f3 feat: add document data to component - ([Thomas David](https://codeberg.org/tjdavid))
64
+ - 17afeb4 feat: require experimental-import-meta-resolve for dynamic imports - ([Thomas David](https://codeberg.org/tjdavid))
65
+ - 34ccd76 feat: dynamic module linker - ([Thomas David](https://codeberg.org/tjdavid))
66
+ - 828bcaa feat: add console to script context - ([Thomas David](https://codeberg.org/tjdavid))
67
+ - 47ab7db chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
68
+ - 4c7f361 fix kleur dependencies - ([Thomas David](https://codeberg.org/tjdavid))
69
+ - 2f88f2d chore: update changelong - ([Thomas David](https://codeberg.org/tjdavid))
70
+ - aedf75f chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
71
+
72
+ ## Metadata
73
+ ```
74
+ This version -------- v0.8.0
75
+ Previous version ---- v0.7.0
76
+ Total commits ------- 44
77
+ ```
1
78
  # 🎁 Release notes (`v0.7.0`)
2
79
 
3
80
  ## Changes
4
- - d7b183d (HEAD -> main, tag: v0.7.0, origin/main) fix: use type helper to confirm child is a node - (*Thomas David*)
5
- - b574569 feat: check if slot is a node - (*Thomas David*)
6
- - de05e38 feat: type helper functions - (*Thomas David*)
7
- - 24f3935 test: cover nested components attributes - (*Thomas David*)
8
- - 8dc8f5d fix: apply nested custom component attribute values - (*Thomas David*)
9
- - 3fa3eb5 chore: version bump - (*Thomas David*)
81
+ - d7b183d (HEAD -> main, tag: v0.7.0, origin/main) fix: use type helper to confirm child is a node - ([Thomas David](https://codeberg.org/tjdavid))
82
+ - b574569 feat: check if slot is a node - ([Thomas David](https://codeberg.org/tjdavid))
83
+ - de05e38 feat: type helper functions - ([Thomas David](https://codeberg.org/tjdavid))
84
+ - 24f3935 test: cover nested components attributes - ([Thomas David](https://codeberg.org/tjdavid))
85
+ - 8dc8f5d fix: apply nested custom component attribute values - ([Thomas David](https://codeberg.org/tjdavid))
86
+ - 3fa3eb5 chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
10
87
 
11
88
  ## Metadata
12
89
  ```
@@ -17,11 +94,11 @@ Total commits ------- 6
17
94
  # 🎁 Release notes (`v0.6.9`)
18
95
 
19
96
  ## Changes
20
- - e79d7c9 (HEAD -> main, tag: v0.6.9, origin/main) fix: aggregation limit is offset by offset - (*[Thomas David](https://codeberg.org/tjdavid)*)
21
- - 6f8253f test: cover nested document root components - (*[Thomas David](https://codeberg.org/tjdavid)*)
22
- - 77d0e36 feat: create nested custom elements on document root - (*[Thomas David](https://codeberg.org/tjdavid)*)
23
- - 2c176e5 chore: update changelog - (*[Thomas David](https://codeberg.org/tjdavid)*)
24
- - f5a3639 chore: version bump - (*[Thomas David](https://codeberg.org/tjdavid)*)
97
+ - e79d7c9 (HEAD -> main, tag: v0.6.9, origin/main) fix: aggregation limit is offset by offset - ([Thomas David](https://codeberg.org/tjdavid))
98
+ - 6f8253f test: cover nested document root components - ([Thomas David](https://codeberg.org/tjdavid))
99
+ - 77d0e36 feat: create nested custom elements on document root - ([Thomas David](https://codeberg.org/tjdavid))
100
+ - 2c176e5 chore: update changelog - ([Thomas David](https://codeberg.org/tjdavid))
101
+ - f5a3639 chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
25
102
 
26
103
  ## Metadata
27
104
  ```
@@ -32,17 +109,17 @@ Total commits ------- 5
32
109
  # 🎁 Release notes (`v0.6.8`)
33
110
 
34
111
  ## Changes
35
- - 3b8fe8c (tag: v0.6.8, origin/main) test: use parseHTML - (*[Thomas David](https://codeberg.org/tjdavid)*)
36
- - f7d6ab9 test: add meta prefix to tokens - (*[Thomas David](https://codeberg.org/tjdavid)*)
37
- - 34c15d2 test: remove unused variables - (*[Thomas David](https://codeberg.org/tjdavid)*)
38
- - b39ac47 test: cover nested components - (*[Thomas David](https://codeberg.org/tjdavid)*)
39
- - 81c3da4 feat: computed slots parse strings - (*[Thomas David](https://codeberg.org/tjdavid)*)
40
- - 585b7d6 fix: remove slot attribute - (*[Thomas David](https://codeberg.org/tjdavid)*)
41
- - 00f68ef fix: process computed tokens before replacing values - (*[Thomas David](https://codeberg.org/tjdavid)*)
42
- - b13a016 feat: add identifier to SourceTextModule - (*[Thomas David](https://codeberg.org/tjdavid)*)
43
- - 6257a0f feat: aggregate add meta value namespace - (*[Thomas David](https://codeberg.org/tjdavid)*)
44
- - 469d5fe feat: aggregate handle page sort - (*[Thomas David](https://codeberg.org/tjdavid)*)
45
- - bd23fbe feat: aggregate handle page limit - (*[Thomas David](https://codeberg.org/tjdavid)*)
112
+ - 3b8fe8c (tag: v0.6.8, origin/main) test: use parseHTML - ([Thomas David](https://codeberg.org/tjdavid))
113
+ - f7d6ab9 test: add meta prefix to tokens - ([Thomas David](https://codeberg.org/tjdavid))
114
+ - 34c15d2 test: remove unused variables - ([Thomas David](https://codeberg.org/tjdavid))
115
+ - b39ac47 test: cover nested components - ([Thomas David](https://codeberg.org/tjdavid))
116
+ - 81c3da4 feat: computed slots parse strings - ([Thomas David](https://codeberg.org/tjdavid))
117
+ - 585b7d6 fix: remove slot attribute - ([Thomas David](https://codeberg.org/tjdavid))
118
+ - 00f68ef fix: process computed tokens before replacing values - ([Thomas David](https://codeberg.org/tjdavid))
119
+ - b13a016 feat: add identifier to SourceTextModule - ([Thomas David](https://codeberg.org/tjdavid))
120
+ - 6257a0f feat: aggregate add meta value namespace - ([Thomas David](https://codeberg.org/tjdavid))
121
+ - 469d5fe feat: aggregate handle page sort - ([Thomas David](https://codeberg.org/tjdavid))
122
+ - bd23fbe feat: aggregate handle page limit - ([Thomas David](https://codeberg.org/tjdavid))
46
123
 
47
124
  ## Metadata
48
125
  ```
@@ -53,10 +130,10 @@ Total commits ------- 11
53
130
  # 🎁 Release notes (`v0.6.7`)
54
131
 
55
132
  ## Changes
56
- - 7138a0b (HEAD -> main, tag: v0.6.7, origin/main) update repo url - (*[Thomas David](https://codeberg.org/tjdavid)*)
57
- - 41988a4 license change - (*[Thomas David](https://codeberg.org/tjdavid)*)
58
- - f471dbc chore: version bump - (*[Thomas David](https://codeberg.org/tjdavid)*)
59
- - 095e35c fix: aggregate filter single meta item - (*[Thomas David](https://codeberg.org/tjdavid)*)
133
+ - 7138a0b (HEAD -> main, tag: v0.6.7, origin/main) update repo url - ([Thomas David](https://codeberg.org/tjdavid))
134
+ - 41988a4 license change - ([Thomas David](https://codeberg.org/tjdavid))
135
+ - f471dbc chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
136
+ - 095e35c fix: aggregate filter single meta item - ([Thomas David](https://codeberg.org/tjdavid))
60
137
 
61
138
  ## Metadata
62
139
  ```
@@ -67,14 +144,14 @@ Total commits ------- 4
67
144
  # 🎁 Release notes (`v0.6.6`)
68
145
 
69
146
  ## Changes
70
- - 790c585 (HEAD -> main, tag: v0.6.6, origin/main) fix: computedSlots token param includes attrib values - (*[Thomas David](https://codeberg.org/tjdavid)*)
71
- - 505d4f0 feat: export parseHTML util - (*[Thomas David](https://codeberg.org/tjdavid)*)
72
- - d0fc52d docs: update CoraliteModuleValues type - (*[Thomas David](https://codeberg.org/tjdavid)*)
73
- - 6ad27ce feat: tokens parse HTML - (*[Thomas David](https://codeberg.org/tjdavid)*)
74
- - 9497c25 feat: export current document to template context - (*[Thomas David](https://codeberg.org/tjdavid)*)
75
- - df9a1a5 refactor: create reusable parseHTML function - (*[Thomas David](https://codeberg.org/tjdavid)*)
76
- - ebb388c feat: append rendered token to custom element slots - (*[Thomas David](https://codeberg.org/tjdavid)*)
77
- - 1f6ffd0 feat: add filtering to aggregate function - (*[Thomas David](https://codeberg.org/tjdavid)*)
147
+ - 790c585 (HEAD -> main, tag: v0.6.6, origin/main) fix: computedSlots token param includes attrib values - ([Thomas David](https://codeberg.org/tjdavid))
148
+ - 505d4f0 feat: export parseHTML util - ([Thomas David](https://codeberg.org/tjdavid))
149
+ - d0fc52d docs: update CoraliteModuleValues type - ([Thomas David](https://codeberg.org/tjdavid))
150
+ - 6ad27ce feat: tokens parse HTML - ([Thomas David](https://codeberg.org/tjdavid))
151
+ - 9497c25 feat: export current document to template context - ([Thomas David](https://codeberg.org/tjdavid))
152
+ - df9a1a5 refactor: create reusable parseHTML function - ([Thomas David](https://codeberg.org/tjdavid))
153
+ - ebb388c feat: append rendered token to custom element slots - ([Thomas David](https://codeberg.org/tjdavid))
154
+ - 1f6ffd0 feat: add filtering to aggregate function - ([Thomas David](https://codeberg.org/tjdavid))
78
155
 
79
156
  ## Metadata
80
157
  ```
@@ -85,14 +162,14 @@ Total commits ------- 8
85
162
  # 🎁 Release notes (`v0.6.5`)
86
163
 
87
164
  ## Changes
88
- - 4610baa (HEAD -> main, tag: v0.6.5, origin/main) chore: version bump - (*[Thomas David](https://codeberg.org/tjdavid)*)
89
- - be2511d ci: remove windows due to unavailability - (*[Thomas David](https://codeberg.org/tjdavid)*)
90
- - 821f212 test: cover aggregate filter option - (*[Thomas David](https://codeberg.org/tjdavid)*)
91
- - 48eaa76 docs: add CoraliteAggregate to aggregate param - (*[Thomas David](https://codeberg.org/tjdavid)*)
92
- - 39ab5ba docs: add CoraliteAggregate typedef - (*[Thomas David](https://codeberg.org/tjdavid)*)
93
- - 148dee9 feat: add filter to aggregate function - (*[Thomas David](https://codeberg.org/tjdavid)*)
94
- - 15cf0fd docs: add CoraliteAggregate typedef - (*[Thomas David](https://codeberg.org/tjdavid)*)
95
- - dbb5b8f feat: remove unused parseHTMLMeta ignoreByAttribute param - (*[Thomas David](https://codeberg.org/tjdavid)*)
165
+ - 4610baa (HEAD -> main, tag: v0.6.5, origin/main) chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
166
+ - be2511d ci: remove windows due to unavailability - ([Thomas David](https://codeberg.org/tjdavid))
167
+ - 821f212 test: cover aggregate filter option - ([Thomas David](https://codeberg.org/tjdavid))
168
+ - 48eaa76 docs: add CoraliteAggregate to aggregate param - ([Thomas David](https://codeberg.org/tjdavid))
169
+ - 39ab5ba docs: add CoraliteAggregate typedef - ([Thomas David](https://codeberg.org/tjdavid))
170
+ - 148dee9 feat: add filter to aggregate function - ([Thomas David](https://codeberg.org/tjdavid))
171
+ - 15cf0fd docs: add CoraliteAggregate typedef - ([Thomas David](https://codeberg.org/tjdavid))
172
+ - dbb5b8f feat: remove unused parseHTMLMeta ignoreByAttribute param - ([Thomas David](https://codeberg.org/tjdavid))
96
173
 
97
174
  ## Metadata
98
175
  ```
@@ -103,11 +180,11 @@ Total commits ------- 8
103
180
  # 🎁 Release notes (`v0.6.4`)
104
181
 
105
182
  ## Changes
106
- - 41771d5 (HEAD -> main, tag: v0.6.4, origin/main) chore: version bump - (*[Thomas David](https://codeberg.org/tjdavid)*)
107
- - ea2ef46 test: cover values param - (*[Thomas David](https://codeberg.org/tjdavid)*)
108
- - 60e70d3 feat: add props argument to tokens and slots functions - (*[Thomas David](https://codeberg.org/tjdavid)*)
109
- - 1ed074a chore: version bump - (*[Thomas David](https://codeberg.org/tjdavid)*)
110
- - 9d710c0 ci: fix publish needs ref - (*[Thomas David](https://codeberg.org/tjdavid)*)
183
+ - 41771d5 (HEAD -> main, tag: v0.6.4, origin/main) chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
184
+ - ea2ef46 test: cover values param - ([Thomas David](https://codeberg.org/tjdavid))
185
+ - 60e70d3 feat: add props argument to tokens and slots functions - ([Thomas David](https://codeberg.org/tjdavid))
186
+ - 1ed074a chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
187
+ - 9d710c0 ci: fix publish needs ref - ([Thomas David](https://codeberg.org/tjdavid))
111
188
 
112
189
  ## Metadata
113
190
  ```
@@ -119,19 +196,19 @@ Total commits ------- 5
119
196
  # 🎁 Release notes (`v0.6.3`)
120
197
 
121
198
  ## Changes
122
- - 6fe640d (HEAD -> main, tag: v0.6.3, origin/main) test: cover ignore by attribute - (*[Thomas David](https://codeberg.org/tjdavid)*)
123
- - a47ff8f types: add IgnoreByAttribute type - (*[Thomas David](https://codeberg.org/tjdavid)*)
124
- - 8547c37 feat: ignore element by attributes inside meta and component parsers - (*[Thomas David](https://codeberg.org/tjdavid)*)
125
- - f61ae88 docs: update ignore-attribute example with quotes - (*[Thomas David](https://codeberg.org/tjdavid)*)
126
- - d4a277d docs: create consistent path names in example - (*[Thomas David](https://codeberg.org/tjdavid)*)
127
- - 566463f docs: remove requirements section - (*[Thomas David](https://codeberg.org/tjdavid)*)
128
- - 2493ab3 style: import type new line - (*[Thomas David](https://codeberg.org/tjdavid)*)
129
- - 2e44174 ci: test before publish - (*[Thomas David](https://codeberg.org/tjdavid)*)
130
- - c1d5ce7 fix: add template id to script module error - (*[Thomas David](https://codeberg.org/tjdavid)*)
131
- - 4fabac1 ci: include self to test script - (*[Thomas David](https://codeberg.org/tjdavid)*)
132
- - efd34d0 fix: add --experimental-vm-modules to shebang - (*[Thomas David](https://codeberg.org/tjdavid)*)
133
- - 7da5d98 refactor: add type check before splicing children. - (*[Thomas David](https://codeberg.org/tjdavid)*)
134
- - 2e39027 fix: catch bad options for aggregate function - (*[Thomas David](https://codeberg.org/tjdavid)*)
199
+ - 6fe640d (HEAD -> main, tag: v0.6.3, origin/main) test: cover ignore by attribute - ([Thomas David](https://codeberg.org/tjdavid))
200
+ - a47ff8f types: add IgnoreByAttribute type - ([Thomas David](https://codeberg.org/tjdavid))
201
+ - 8547c37 feat: ignore element by attributes inside meta and component parsers - ([Thomas David](https://codeberg.org/tjdavid))
202
+ - f61ae88 docs: update ignore-attribute example with quotes - ([Thomas David](https://codeberg.org/tjdavid))
203
+ - d4a277d docs: create consistent path names in example - ([Thomas David](https://codeberg.org/tjdavid))
204
+ - 566463f docs: remove requirements section - ([Thomas David](https://codeberg.org/tjdavid))
205
+ - 2493ab3 style: import type new line - ([Thomas David](https://codeberg.org/tjdavid))
206
+ - 2e44174 ci: test before publish - ([Thomas David](https://codeberg.org/tjdavid))
207
+ - c1d5ce7 fix: add template id to script module error - ([Thomas David](https://codeberg.org/tjdavid))
208
+ - 4fabac1 ci: include self to test script - ([Thomas David](https://codeberg.org/tjdavid))
209
+ - efd34d0 fix: add --experimental-vm-modules to shebang - ([Thomas David](https://codeberg.org/tjdavid))
210
+ - 7da5d98 refactor: add type check before splicing children. - ([Thomas David](https://codeberg.org/tjdavid))
211
+ - 2e39027 fix: catch bad options for aggregate function - ([Thomas David](https://codeberg.org/tjdavid))
135
212
 
136
213
  ## Metadata
137
214
  ```
@@ -142,10 +219,10 @@ Total commits ------- 13
142
219
  # 🎁 Release notes (`v0.6.2`)
143
220
 
144
221
  ## Changes
145
- - be6c54c (HEAD -> main, tag: v0.6.2, origin/main) fix: update lock - (*[Thomas David](https://codeberg.org/tjdavid)*)
146
- - 15d9b4e chore: version bump - (*[Thomas David](https://codeberg.org/tjdavid)*)
147
- - fac695e fix: node v18 requires globalThis reference for crypto - (*[Thomas David](https://codeberg.org/tjdavid)*)
148
- - d7c551e doc: format doc links - (*[Thomas David](https://codeberg.org/tjdavid)*)
222
+ - be6c54c (HEAD -> main, tag: v0.6.2, origin/main) fix: update lock - ([Thomas David](https://codeberg.org/tjdavid))
223
+ - 15d9b4e chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
224
+ - fac695e fix: node v18 requires globalThis reference for crypto - ([Thomas David](https://codeberg.org/tjdavid))
225
+ - d7c551e doc: format doc links - ([Thomas David](https://codeberg.org/tjdavid))
149
226
 
150
227
  ## Metadata
151
228
  ```
@@ -156,14 +233,14 @@ Total commits ------- 4
156
233
  # 🎁 Release notes (`v0.6.1`)
157
234
 
158
235
  ## Changes
159
- - bcc1637 (HEAD -> main, tag: v0.6.1, origin/main) chore: version bump - (*[Thomas David](https://codeberg.org/tjdavid)*)
160
- - 95cfdba docs: add doc links - (*[Thomas David](https://codeberg.org/tjdavid)*)
161
- - 101a305 fix: render computedSlot nodes - (*[Thomas David](https://codeberg.org/tjdavid)*)
162
- - 11a35d8 feat: dynamically import modules - (*[Thomas David](https://codeberg.org/tjdavid)*)
163
- - e1364b9 docs: add CoraliteResult type - (*[Thomas David](https://codeberg.org/tjdavid)*)
164
- - 11c6405 docs: add @example to coralite - (*[Thomas David](https://codeberg.org/tjdavid)*)
165
- - a050263 docs: basic technical documentation - (*[Thomas David](https://codeberg.org/tjdavid)*)
166
- - 83fdddd docs: update dry run option - (*[Thomas David](https://codeberg.org/tjdavid)*)
236
+ - bcc1637 (HEAD -> main, tag: v0.6.1, origin/main) chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
237
+ - 95cfdba docs: add doc links - ([Thomas David](https://codeberg.org/tjdavid))
238
+ - 101a305 fix: render computedSlot nodes - ([Thomas David](https://codeberg.org/tjdavid))
239
+ - 11a35d8 feat: dynamically import modules - ([Thomas David](https://codeberg.org/tjdavid))
240
+ - e1364b9 docs: add CoraliteResult type - ([Thomas David](https://codeberg.org/tjdavid))
241
+ - 11c6405 docs: add @example to coralite - ([Thomas David](https://codeberg.org/tjdavid))
242
+ - a050263 docs: basic technical documentation - ([Thomas David](https://codeberg.org/tjdavid))
243
+ - 83fdddd docs: update dry run option - ([Thomas David](https://codeberg.org/tjdavid))
167
244
 
168
245
  ## Metadata
169
246
  ```
@@ -174,21 +251,21 @@ Total commits ------- 8
174
251
  # 🎁 Release notes (`v0.6.0`)
175
252
 
176
253
  ## Changes
177
- - 22d75e2 (HEAD -> main, tag: v0.6.0, origin/main) chore: version bump - (*[Thomas David](https://codeberg.org/tjdavid)*)
178
- - c5cc7cc lint: ignore playwright-report - (*[Thomas David](https://codeberg.org/tjdavid)*)
179
- - fdb3697 docs: add dry run option - (*[Thomas David](https://codeberg.org/tjdavid)*)
180
- - 891db2e feat: export coralite utils - (*[Thomas David](https://codeberg.org/tjdavid)*)
181
- - 9265681 test: cover ignore attribute - (*[Thomas David](https://codeberg.org/tjdavid)*)
182
- - 5d44661 fix: allow missing component to compile - (*[Thomas David](https://codeberg.org/tjdavid)*)
183
- - f3d6e65 docs: add remove prop to CoraliteElement - (*[Thomas David](https://codeberg.org/tjdavid)*)
184
- - 229fef5 feat: new option to ignore element by attribute name value pair - (*[Thomas David](https://codeberg.org/tjdavid)*)
185
- - c78dde1 chore: include kleur dep - (*[Thomas David](https://codeberg.org/tjdavid)*)
186
- - b10bbe8 feat: update cli to use coralite module - (*[Thomas David](https://codeberg.org/tjdavid)*)
187
- - 48fe816 docs: make defineComponent param tokens and slots optional - (*[Thomas David](https://codeberg.org/tjdavid)*)
188
- - 02a5e8f feat: move coralite to a module - (*[Thomas David](https://codeberg.org/tjdavid)*)
189
- - d336090 feat: get package.json util function - (*[Thomas David](https://codeberg.org/tjdavid)*)
190
- - e210844 feat: add document used in error message - (*[Thomas David](https://codeberg.org/tjdavid)*)
191
- - 1556a3b chore: version bump - (*[Thomas David](https://codeberg.org/tjdavid)*)
254
+ - 22d75e2 (HEAD -> main, tag: v0.6.0, origin/main) chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
255
+ - c5cc7cc lint: ignore playwright-report - ([Thomas David](https://codeberg.org/tjdavid))
256
+ - fdb3697 docs: add dry run option - ([Thomas David](https://codeberg.org/tjdavid))
257
+ - 891db2e feat: export coralite utils - ([Thomas David](https://codeberg.org/tjdavid))
258
+ - 9265681 test: cover ignore attribute - ([Thomas David](https://codeberg.org/tjdavid))
259
+ - 5d44661 fix: allow missing component to compile - ([Thomas David](https://codeberg.org/tjdavid))
260
+ - f3d6e65 docs: add remove prop to CoraliteElement - ([Thomas David](https://codeberg.org/tjdavid))
261
+ - 229fef5 feat: new option to ignore element by attribute name value pair - ([Thomas David](https://codeberg.org/tjdavid))
262
+ - c78dde1 chore: include kleur dep - ([Thomas David](https://codeberg.org/tjdavid))
263
+ - b10bbe8 feat: update cli to use coralite module - ([Thomas David](https://codeberg.org/tjdavid))
264
+ - 48fe816 docs: make defineComponent param tokens and slots optional - ([Thomas David](https://codeberg.org/tjdavid))
265
+ - 02a5e8f feat: move coralite to a module - ([Thomas David](https://codeberg.org/tjdavid))
266
+ - d336090 feat: get package.json util function - ([Thomas David](https://codeberg.org/tjdavid))
267
+ - e210844 feat: add document used in error message - ([Thomas David](https://codeberg.org/tjdavid))
268
+ - 1556a3b chore: version bump - ([Thomas David](https://codeberg.org/tjdavid))
192
269
 
193
270
  ## Metadata
194
271
  ```
package/lib/coralite.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createComponent, parseHTMLDocument, parseModule, getHTML } from '#lib'
1
+ import { createComponent, parseHTMLDocument, parseModule, getHtmlFiles } from '#lib'
2
2
  import render from 'dom-serializer'
3
3
 
4
4
  /**
@@ -8,8 +8,9 @@ import render from 'dom-serializer'
8
8
  * CoraliteAnyNode,
9
9
  * CoraliteModule,
10
10
  * CoraliteResult,
11
- * CoraliteAggregate
12
- * } from '#types'
11
+ * CoraliteAggregate,
12
+ * IgnoreByAttribute,
13
+ * HTMLData } from '#types'
13
14
  */
14
15
 
15
16
  /**
@@ -86,69 +87,128 @@ export async function coralite ({
86
87
  ignoreByAttribute
87
88
  }) {
88
89
  const startTime = performance.now()
89
- const htmlTemplates = await getHTML({
90
+ const htmlTemplates = await getHtmlFiles({
90
91
  path: templates,
91
92
  recursive: true
92
93
  })
93
- const htmlPages = await getHTML({
94
+ const htmlPages = await getHtmlFiles({
94
95
  path: pages,
95
96
  recursive: true
96
97
  })
97
98
 
98
99
  /** @type {Object.<string, CoraliteModule>} */
99
- const coraliteModules = {}
100
- /** @type {CoraliteResult[]} */
101
- const documents = []
100
+ const components = {}
102
101
 
103
102
  // create templates
104
103
  for (let i = 0; i < htmlTemplates.length; i++) {
105
104
  const html = htmlTemplates[i]
106
- const coraliteModule = parseModule(html.content, ignoreByAttribute)
105
+ const component = parseModule(html.content, {
106
+ ignoreByAttribute
107
+ })
107
108
 
108
- coraliteModules[coraliteModule.id] = coraliteModule
109
+ components[component.id] = {
110
+ ...component,
111
+ path: html.path
112
+ }
109
113
  }
110
114
 
115
+ /** @type {CoraliteResult[]} */
116
+ const documents = []
117
+
111
118
  for (let i = 0; i < htmlPages.length; i++) {
112
119
  const html = htmlPages[i]
113
- const document = parseHTMLDocument(html, {
120
+ await renderDocument({
121
+ html,
114
122
  pages,
115
- templates
116
- }, ignoreByAttribute)
117
-
118
- for (let i = 0; i < document.customElements.length; i++) {
119
- const customElement = document.customElements[i]
120
- const component = await createComponent({
121
- id: customElement.name,
122
- values: customElement.attribs,
123
- element: customElement,
124
- components: coraliteModules,
125
- document
126
- })
127
-
128
- if (!component) {
129
- // skip if no component
130
- continue
131
- }
123
+ templates,
124
+ ignoreByAttribute,
125
+ components,
126
+ startTime,
127
+ documents
128
+ })
129
+ }
130
+
131
+ return documents
132
+ }
133
+
134
+ /**
135
+ * Renders an HTML document using the provided configuration and components.
136
+ *
137
+ * @param {Object} param
138
+ * @param {HTMLData} param.html - The raw HTML content to render.
139
+ * @param {string} param.pages - Path to the root pages directory.
140
+ * @param {string} param.templates - Path to the root templates directory.
141
+ * @param {IgnoreByAttribute} param.ignoreByAttribute - An array of attribute names and values to ignore by element type.
142
+ * @param {Object} param.components - Components configuration used during rendering.
143
+ * @param {number} param.startTime - Timestamp when rendering started (for performance tracking).
144
+ * @param {CoraliteResult[]} [param.documents=[]] - Array of rendered documents to accumulate results.
145
+ * @param {boolean} [param.isHead=true] - Whether this is the head section (controls recursive rendering behavior).
146
+ *
147
+ * @returns {Promise<CoraliteResult[]>} A promise that resolves to an array of rendered document results.
148
+ */
149
+ async function renderDocument ({
150
+ html,
151
+ pages,
152
+ templates,
153
+ ignoreByAttribute,
154
+ components,
155
+ startTime,
156
+ documents = [],
157
+ isHead = true
158
+ }) {
159
+ const document = parseHTMLDocument(html, {
160
+ pages,
161
+ templates
162
+ }, ignoreByAttribute)
163
+
164
+ for (let i = 0; i < document.customElements.length; i++) {
165
+ const customElement = document.customElements[i]
166
+ const component = await createComponent({
167
+ id: customElement.name,
168
+ values: customElement.attribs,
169
+ element: customElement,
170
+ components,
171
+ document
172
+ })
132
173
 
133
- for (let i = 0; i < component.children.length; i++) {
134
- // update component parent
135
- component.children[i].parent = customElement.parent
174
+ if (component) {
175
+ const element = component.element
176
+ for (let i = 0; i < element.children.length; i++) {
177
+ // update component parent
178
+ element.children[i].parent = customElement.parent
136
179
  }
180
+
137
181
  const index = customElement.parent.children.indexOf(customElement, customElement.parentChildIndex)
138
182
  // replace custom element with template
139
- customElement.parent.children.splice(index, 1, ...component.children)
183
+ customElement.parent.children.splice(index, 1, ...element.children)
184
+
185
+ if (isHead && component.documents) {
186
+ for (let i = 0; i < component.documents.length; i++) {
187
+ const html = component.documents[i]
188
+ await renderDocument({
189
+ html,
190
+ pages,
191
+ templates,
192
+ ignoreByAttribute,
193
+ components,
194
+ startTime,
195
+ documents,
196
+ isHead: false
197
+ })
198
+ }
199
+ }
140
200
  }
201
+ }
141
202
 
142
- // render document
143
- // @ts-ignore
144
- const result = render(document.root)
203
+ // render document
204
+ // @ts-ignore
205
+ const result = render(document.root)
145
206
 
146
- documents.push({
147
- item: document,
148
- html: result,
149
- duration: performance.now() - startTime
150
- })
151
- }
207
+ documents.push({
208
+ item: document,
209
+ html: result,
210
+ duration: performance.now() - startTime
211
+ })
152
212
 
153
213
  return documents
154
214
  }
package/lib/get-html.js CHANGED
@@ -15,13 +15,13 @@ import { readdir, readFile } from 'node:fs/promises'
15
15
  *
16
16
  * @example
17
17
  * // Example usage:
18
- * const htmlFiles = await getHTML({
18
+ * const htmlFiles = await getHtmlFiles({
19
19
  * path: 'src',
20
20
  * recursive: true,
21
21
  * exclude: ['index.html', 'subdir/file2.html']
22
22
  * })
23
23
  */
24
- export default function getHTML ({ path, recursive = false, exclude = [] }) {
24
+ export function getHtmlFiles ({ path, recursive = false, exclude = [] }) {
25
25
  return new Promise((resolve, reject) => {
26
26
  const html = []
27
27
 
@@ -39,10 +39,17 @@ export default function getHTML ({ path, recursive = false, exclude = [] }) {
39
39
  && !exclude.includes(file.name)
40
40
  ) {
41
41
  const parentPath = file.parentPath || file.path
42
+ const dirname = parentPath.replace(path, '')
43
+ const name = file.name
42
44
 
43
45
  html.push({
44
- parentPath,
45
- name: file.name
46
+ path: {
47
+ pathname: join(dirname, name),
48
+ filename: name,
49
+ dirname,
50
+ page: parentPath,
51
+ pageName: join(parentPath, name)
52
+ }
46
53
  })
47
54
 
48
55
  promises.push(readFile(join(parentPath, file.name), { encoding: 'utf8' }))
@@ -62,3 +69,24 @@ export default function getHTML ({ path, recursive = false, exclude = [] }) {
62
69
  .catch(error => reject(error))
63
70
  })
64
71
  }
72
+
73
+ /**
74
+ * Reads an HTML file and returns its content as a string.
75
+ * @param {string} filename - The path to the HTML file.
76
+ * @returns {Promise<string>} A promise that resolves with the HTML content.
77
+ * @throws {Error} If the file cannot be read.
78
+ */
79
+ export async function getHtmlFile (filename) {
80
+ try {
81
+ const extension = extname(filename).toLowerCase()
82
+
83
+ if (extension === '.html') {
84
+ const data = await readFile(filename, 'utf8')
85
+ return data
86
+ }
87
+
88
+ throw new Error('Unexpected filename extension "' + extension +'"')
89
+ } catch (err) {
90
+ throw err
91
+ }
92
+ }