@ca-plant-list/ca-plant-list 0.1.1 → 0.1.2

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 (2) hide show
  1. package/lib/config.js +12 -3
  2. package/package.json +4 -1
package/lib/config.js CHANGED
@@ -7,18 +7,27 @@ class Config {
7
7
  static #config = {};
8
8
  static #packageDir = path.dirname( path.dirname( url.fileURLToPath( import.meta.url ) ) );
9
9
 
10
- static getConfigValue( prefix, name, dflt ) {
10
+ static getConfigValue( prefix, name, subcat, dflt ) {
11
11
  const obj = this.#config[ prefix ];
12
12
  if ( obj ) {
13
13
  if ( Object.hasOwn( obj, name ) ) {
14
- return obj[ name ];
14
+ const nameObj = obj[ name ];
15
+ if ( nameObj === undefined ) {
16
+ return dflt;
17
+ }
18
+ if ( subcat === undefined ) {
19
+ return nameObj;
20
+ }
21
+ if ( Object.hasOwn( nameObj, subcat ) ) {
22
+ return nameObj[ subcat ];
23
+ }
15
24
  }
16
25
  }
17
26
  return dflt;
18
27
  }
19
28
 
20
29
  static getLabel( name, dflt ) {
21
- return this.getConfigValue( "labels", name, dflt );
30
+ return this.getConfigValue( "labels", name, undefined, dflt );
22
31
  }
23
32
 
24
33
  static getPackageDir() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ca-plant-list/ca-plant-list",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Tools to create Jekyll files for a website listing plants in an area of California.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,6 +10,9 @@
10
10
  "homepage": "https://github.com/ca-plants/ca-plant-list",
11
11
  "type": "module",
12
12
  "exports": {
13
+ "./Config": {
14
+ "import": "./lib/config.js"
15
+ },
13
16
  "./CSV": {
14
17
  "import": "./lib/csv.js"
15
18
  },