Skip to content

Commit 18cbea4

Browse files
authored
fix: expose axis registry functions (#118)
* fix: expose axis registry functions * docs: update changelog
1 parent 3bbdeb3 commit 18cbea4

File tree

6 files changed

+41
-6
lines changed

6 files changed

+41
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Google Font Metadata will log all notable changes within this file.
44

5+
# [4.2.1](https://github.com/fontsource/google-font-metadata/releases/tag/v4.2.1)
6+
7+
## Fixes
8+
9+
- Expose axis registry functions. [#118](https://github.com/fontsource/google-font-metadata/pull/118)
10+
511
# [4.2.0](https://github.com/fontsource/google-font-metadata/releases/tag/v4.2.0)
612

713
## Features

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,20 @@ npm install google-font-metadata
1717
The project exports the following data:
1818

1919
```ts
20-
import { APIv1, APIv2, APIVariable } from "google-font-metadata";
21-
const { APIv1, APIv2, APIVariable } = require("google-font-metadata");
20+
import {
21+
APIv1,
22+
APIv2,
23+
APIVariable,
24+
APILicense,
25+
APIRegistry,
26+
} from "google-font-metadata";
27+
const {
28+
APIv1,
29+
APIv2,
30+
APIVariable,
31+
APILicense,
32+
APIRegistry,
33+
} = require("google-font-metadata");
2234

2335
console.dir(APIv2);
2436
```
@@ -229,7 +241,7 @@ Scrapes the [Google Fonts Attribution](https://fonts.google.com/attribution) pag
229241

230242
Exports [`data/licenses.json`](https://github.com/fontsource/google-font-metadata/tree/main/data/licenses.json)
231243

232-
## Axis Registry
244+
## APIRegistry
233245

234246
```json
235247
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "google-font-metadata",
33
"description": "A metadata generator for Google Fonts.",
4-
"version": "4.2.0",
4+
"version": "4.2.1",
55
"author": "Ayuhito <[email protected]>",
66
"main": "./dist/index.js",
77
"module": "./dist/index.mjs",

src/data.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { dirname, join } from 'pathe';
44

55
import type {
66
APIResponse,
7+
AxesObject,
78
FontObjectV1,
89
FontObjectV2,
910
FontObjectVariable,
@@ -103,4 +104,17 @@ const APILicense = JSON.parse(
103104
)
104105
) as Licenses;
105106

106-
export { APIDirect, APILicense, APIv1, APIv2, APIVariable, APIVariableDirect };
107+
/**
108+
* This returns the axis registry of the supported Google Font variable axes.
109+
* {@link https://github.com/googlefonts/axisregistry}
110+
*
111+
* @remarks This can be updated using `npx gfm parse --registry`.
112+
*/
113+
const APIRegistry = JSON.parse(
114+
fs.readFileSync(
115+
join(dirname(fileURLToPath(import.meta.url)), '../data/axis-registry.json'),
116+
'utf8'
117+
)
118+
) as AxesObject[];
119+
120+
export { APIDirect, APILicense, APIRegistry,APIv1, APIv2, APIVariable, APIVariableDirect };

src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
export { fetchAPI } from './api-gen';
22
export { parsev1 } from './api-parser-v1';
33
export { parsev2 } from './api-parser-v2';
4+
export { generateAxis } from './axis-gen';
45
export {
56
APIDirect,
67
APILicense,
8+
APIRegistry,
79
APIv1,
810
APIv2,
911
APIVariable,
@@ -12,6 +14,7 @@ export {
1214
export { parseLicenses } from './license';
1315
export type {
1416
APIResponse,
17+
AxesObject,
1518
FontObject,
1619
FontObjectV1,
1720
FontObjectV2,

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ type StandardAxes = typeof STANDARD_AXES[number];
9393

9494
const isStandardAxesKey = (axesKey: string): axesKey is StandardAxes =>
9595
STANDARD_AXES.includes(axesKey as StandardAxes);
96-
interface AxesObject {
96+
export interface AxesObject {
9797
name: string;
9898
tag: string;
9999
min: number;

0 commit comments

Comments
 (0)