@nera-static/plugin-utils 1.0.0

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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +58 -0
  3. package/index.js +10 -0
  4. package/package.json +35 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [2025] [Michael Becker]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,58 @@
1
+ # @nera/plugin-utils
2
+
3
+ 🛠 Utility helpers for developing plugins for the [Nera](https://github.com/seebaermichi/nera) static site generator.
4
+
5
+ ---
6
+
7
+ ## 📦 Installation
8
+
9
+ ```bash
10
+ npm install @nera/plugin-utils
11
+ ```
12
+
13
+ ---
14
+
15
+ ## 📚 Features
16
+
17
+ Currently includes:
18
+
19
+ ### `getConfig(filePath: string): object`
20
+
21
+ Reads and parses a YAML config file, returning its contents as a JavaScript object.
22
+
23
+ #### Example usage:
24
+
25
+ ```js
26
+ import { getConfig } from '@nera/plugin-utils'
27
+
28
+ const config = getConfig('./path/to/config.yaml')
29
+ console.log(config.title)
30
+ ```
31
+
32
+ Returns `{}` if the file does not exist or is empty.
33
+
34
+ ---
35
+
36
+ ## 🧱 Use Case
37
+
38
+ This package is intended for use inside Nera plugins to simplify configuration loading from YAML files.
39
+
40
+ Example in a plugin:
41
+
42
+ ```js
43
+ import { getConfig } from '@nera/plugin-utils'
44
+
45
+ const config = getConfig(`${__dirname}/config/navigation.yaml`)
46
+ ```
47
+
48
+ ---
49
+
50
+ ## 🧑‍💻 Maintainers
51
+
52
+ Created and maintained by [@seebaermichi](https://github.com/seebaermichi)
53
+
54
+ ---
55
+
56
+ ## 📄 License
57
+
58
+ MIT
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ import fs from 'fs'
2
+ import yaml from 'js-yaml'
3
+
4
+ export function getConfig(filePath) {
5
+ if (fs.existsSync(filePath)) {
6
+ const content = fs.readFileSync(filePath, 'utf-8')
7
+ return yaml.load(content) || {}
8
+ }
9
+ return {}
10
+ }
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@nera-static/plugin-utils",
3
+ "version": "1.0.0",
4
+ "description": "Utility helpers for Nera plugins, e.g., YAML config loading",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": "./index.js"
9
+ },
10
+ "keywords": [
11
+ "nera",
12
+ "plugin",
13
+ "utils",
14
+ "yaml",
15
+ "config"
16
+ ],
17
+ "author": "Michael Becker",
18
+ "license": "MIT",
19
+ "files": [
20
+ "index.js",
21
+ "README.md"
22
+ ],
23
+ "dependencies": {
24
+ "js-yaml": "^4.1.0"
25
+ },
26
+ "devDependencies": {
27
+ "vitest": "^3.2.4"
28
+ },
29
+ "scripts": {
30
+ "test": "vitest run"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ }
35
+ }