Skip to content

Commit

Permalink
docs(readme): update (#119)
Browse files Browse the repository at this point in the history
Co-authored-by: Almanov Nikita <[email protected]>
  • Loading branch information
github-actions[bot] and nikkeyl authored Sep 1, 2024
1 parent bcc29e1 commit d5e9ae5
Showing 1 changed file with 10 additions and 39 deletions.
49 changes: 10 additions & 39 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

- [Installation](#installation)
- [Usage](#usage)
- [Naming Convention](#naming-convention)
- [Contributing](#contributing)
- [License](#license)

Expand All @@ -28,54 +27,26 @@ bun i -D @archoleat/validate-font-file-name

## Usage

```js
import { validateFontFileName } from '@archoleat/validate-font-file-name';

const validFontFileName = 'OpenSans-Regular.woff2';
const invalidFontFileName = 'OpenSans.woff2';
### Naming Convention

// returns: true
console.log(await validateFontFileName({ file: validFontFileName }));
The **font family** and **font weight** must be in **Pascal Case**
and separated by a **hyphen**.

// returns: {current time} [ERROR] 'OpenSans.woff2' doesn't match with '/(^[A-Z][a-z]+([A-Z][a-z]+)?)-(Thin|Hairline|ExtraLight|UltraLight|Light|Regular|Medium|SemiBold|DemiBold|Bold|ExtraBold|UltraBold|Black|Heavy|ExtraBlack|UltraBlack)\.(otf|ttf|woff|woff2)$/'.
console.log(await validateFontFileName({ file: invalidFontFileName }));
```
Extensions that are allowed: `otf`, `ttf`, `woff`, `woff2`.

### Your Regex
> Example: `OpenSans-SemiBold.woff2`.
You can also specify your regex:
It's not necessary to specify the `regex` parameter.

```js
import { validateFontFileName } from '@archoleat/validate-font-file-name';

// You can also specify `new RegExp()` and a regular `string`
const yourRegex = /OpenSans-regular/;

const validFontFileName = 'OpenSans-regular';
const invalidFontFileName = 'OpenSans.woff2';

// returns: true
console.log(await validateFontFileName({
file: validFontFileName,
regex: yourRegex,
}));

// returns: {current time} [ERROR] 'OpenSans.woff2' doesn't match with '/OpenSans-regular/'.
console.log(await validateFontFileName({
file: invalidFontFileName,
regex: yourRegex,
}));
await validateFontFileName({
file: 'path/to/file',
regex: /regex/ | new RegExp() | '',
});
```

## Naming Convention

The **font family** and **font weight** must be in **Pascal Case**
and separated by a **hyphen**.

Extensions that are allowed: `otf`, `ttf`, `woff`, `woff2`.

> `{FontFamily}-{FontWeight}.{extension}`
## Contributing

Please read [**CONTRIBUTING**](https://github.com/archoleat/.github/blob/main/CONTRIBUTING.md)
Expand Down

0 comments on commit d5e9ae5

Please sign in to comment.