coralite 0.11.2 → 0.11.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.
package/README.md CHANGED
@@ -7,11 +7,11 @@ coralite is a static site generator library built around the emerging [HTML modu
7
7
  </p>
8
8
 
9
9
  - Getting started
10
- - [Basic templating](./docs/basic-templating.md)
10
+ - [Basic templating](https://codeberg.org/tjdavid/coralite/src/branch/main/docs/basic-templating.md)
11
11
  - Reference
12
- - [Coralite CLI](./docs/coralite-cli.md)
13
- - [Coralite](./docs/coralite.md)
14
- - [Types](./docs/types.md)
12
+ - [Coralite CLI](https://codeberg.org/tjdavid/coralite/src/branch/main/docs/coralite-cli.md)
13
+ - [Coralite](https://codeberg.org/tjdavid/coralite/src/branch/main/docs/coralite.md)
14
+ - [Types](https://codeberg.org/tjdavid/coralite/src/branch/main/docs/types.md)
15
15
 
16
16
  ## Installation
17
17
 
package/bin/coralite.js CHANGED
@@ -1,4 +1,4 @@
1
- #!/usr/bin/env node --experimental-vm-modules --experimental-import-meta-resolve
1
+ #!/usr/bin/env -S node --experimental-vm-modules --experimental-import-meta-resolve
2
2
 
3
3
  import { getPkg, Coralite } from '#lib'
4
4
  import { Command } from 'commander'
package/lib/plugin.js CHANGED
@@ -1,23 +1,37 @@
1
1
  /**
2
2
  * @import Coralite from './coralite.js'
3
- * @import { CoralitePlugin } from '#types'
3
+ * @import { CoralitePlugin, CoralitePluginInstance } from '#types'
4
4
  */
5
5
 
6
6
  import { basename, dirname } from 'path'
7
7
  import { getHtmlFile } from './html.js'
8
8
 
9
9
  /**
10
- * @param {CoralitePlugin & ThisType<Coralite>} options
10
+ * Creates a new Coralite plugin instance based on provided configuration options.
11
+ *
12
+ * @param {CoralitePlugin & ThisType<Coralite>} options - Plugin configuration object
13
+ * @returns {CoralitePluginInstance} A plugin instance with processed templates and method
14
+ *
15
+ * @example
16
+ * const myPlugin = createPlugin({
17
+ * name: 'my-plugin',
18
+ * method: (options, context) => {
19
+ * // Plugin logic implementation
20
+ * },
21
+ * templates: ['src/components/header.html', 'src/components/footer.html']
22
+ * })
11
23
  */
12
24
  export function createPlugin ({
13
25
  name,
14
26
  method,
15
27
  templates = []
16
28
  }) {
29
+ // validate that the plugin method is a function
17
30
  if (typeof method !== 'function') {
18
31
  throw Error('Coralite plugins method expects a function')
19
32
  }
20
33
 
34
+ // process template files and store metadata
21
35
  const templateResults = []
22
36
  for (let i = 0; i < templates.length; i++) {
23
37
  const path = templates[i]
@@ -33,6 +47,7 @@ export function createPlugin ({
33
47
  })
34
48
  }
35
49
 
50
+ // return the plugin object with all configured properties
36
51
  return {
37
52
  name,
38
53
  method,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coralite",
3
- "version": "0.11.2",
3
+ "version": "0.11.3",
4
4
  "description": "HTML modules static site generator",
5
5
  "main": "./lib/coralite.js",
6
6
  "type": "module",
package/types/index.js CHANGED
@@ -217,7 +217,7 @@
217
217
  * @property {CoraliteModule} module - The module context the plugin is operating within (contains template/script)
218
218
  * @property {CoraliteElement} element - The specific HTML element the plugin is applied to (if applicable)
219
219
  * @property {Object} path - File path information for the current document/module being processed
220
- * @property {[string, string][]} excludeByAttribute - List of attribute name-value pairs to ignore during processing by element type
220
+ * @property {IgnoreByAttribute[]} excludeByAttribute - List of attribute name-value pairs to ignore during processing by element type
221
221
  * @property {string} id - Unique identifier for the value context.
222
222
  */
223
223