Skip to content

Commit

Permalink
feat: typescript rewrite (#54)
Browse files Browse the repository at this point in the history
* feat: typescript rewrite

* chore!: change minimum supported node version to 12

* chore: update google-fonts-helper

* docs: simplify readme

* typo

* test: mock consola
  • Loading branch information
ricardogobbosouza authored Mar 4, 2021
1 parent 2a7149d commit 81259ca
Show file tree
Hide file tree
Showing 34 changed files with 3,562 additions and 3,591 deletions.
3 changes: 0 additions & 3 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ node_modules
dist
.nuxt
coverage

# Plugin
lib/plugin.js
5 changes: 5 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"@nuxtjs/eslint-config-typescript"
]
}
6 changes: 0 additions & 6 deletions .eslintrc.js

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [10, 12]
node: [12, 14]

steps:
- uses: actions/setup-node@v2
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ node_modules
.DS_Store
coverage
dist
sw.*
.env
test/fixture/download/assets
165 changes: 1 addition & 164 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,174 +51,11 @@ yarn add --dev @nuxtjs/google-fonts # or npm install --save-dev @nuxtjs/google-f

:warning: If you are using Nuxt **< v2.9** you have to install the module as a `dependency` (No `--dev` or `--save-dev` flags) and use `modules` section in `nuxt.config.js` instead of `buildModules`.

### Using top level options

```js
export default {
buildModules: [
'@nuxtjs/google-fonts'
],
googleFonts: {
/* module options */
}
}
```

## Options

See [module options](https://google-fonts.nuxtjs.org/options).

### `families`

- Type: `Object`
- Default: `{}`

```js
{
families: {
Roboto: true,
'Josefin+Sans': true,
Lato: [100, 300],
Raleway: {
wght: [100, 400],
ital: [100]
},
}
}
```

See https://developers.google.com/fonts/docs/css2#quickstart_guides

### `display`

- Type: `String`
- Default: `null`

The font-display property lets you control what happens while the font is still loading or otherwise unavailable.

```js
{
display: 'swap' // 'auto' | 'block' | 'swap' | 'fallback' | 'optional'
}
```

See https://developers.google.com/fonts/docs/css2#use_font-display

### `subsets`

- Type: `Array[String]|String`
- Default: `[]`

Some of the fonts in the Google Font Directory support multiple scripts (like Latin, Cyrillic, and Greek for example). In order to specify which subsets should be downloaded the subset parameter should be appended to the URL.

See https://developers.google.com/fonts/docs/getting_started#specifying_script_subsets

### `prefetch`

- Type: `Boolean`
- Default: `true`

This option inject `<link rel =" dns-prefetch "href =" https://fonts.gstatic.com/ "/>` into your project header.

See https://developer.mozilla.org/en-US/docs/Web/Performance/dns-prefetch

### `preconnect`

- Type: `Boolean`
- Default: `true`

This option inject `<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin />` into your project header.

See https://developer.mozilla.org/en-US/docs/Web/Performance/dns-prefetch#Best_practices

### `preload`

- Type: `Boolean`
- Default: `true`

This option inject `<link rel="preload" as="style" href="https://fonts.googleapis.com/css2?family=Roboto" />` into your project header, optionally increase loading priority.

See https://developer.mozilla.org/pt-BR/docs/Web/HTML/Preloading_content

### `useStylesheet`

- Type: `Boolean`
- Default: `false`

This option inject `<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Roboto" />` into your project header, recommended for projects that use the AMP module that removes scripts.

### `download`

See [downloading Google Fonts](https://google-fonts.nuxtjs.org/downloading)

- Type: `Boolean`
- Default: `false`

This option you can download css and google sources for your local project.
This means that your project will not depend on these external resources.

> **Note:** The options below are only used when this option is enabled.
### `base64`

- Type: `Boolean`
- Default: `false`

This option encode the fonts and inject directly into the generated css file.

### `inject`

- Type: `Boolean`
- Default: `true`

This option inject the globally generated css file.

See https://nuxtjs.org/api/configuration-css/

### `overwriting`

- Type: `Boolean`
- Default: `false`

This option prevents files from being downloaded more than once.

### `outputDir`

- Type: `String`
- Default: `this.options.dir.assets`

Specifies the output directory for downloaded files.

### `stylePath`

- Type: `String`
- Default: `'css/fonts.css'`

Specifies the path of the css file to be generated.

### `fontsDir`

- Type: `String`
- Default: `'fonts'`

Specifies the directory where the fonts will be downloaded.

**Note:** This option is used if the `base64` option is disabled.

### `fontsPath`

- Type: `String`
- Default: `'~assets/fonts'`

Specifies the path of the fonts within the generated css file.

**Note:** This option is used if the `base64` option is disabled.

## Development

1. Clone this repository
2. Install dependencies using `yarn install` or `npm install`
3. Start development server using `npm run dev`
3. Start development server using `yarn dev` or `npm run dev`

## License

Expand Down
5 changes: 0 additions & 5 deletions commitlint.config.js

This file was deleted.

3 changes: 0 additions & 3 deletions docs/.env.example

This file was deleted.

10 changes: 3 additions & 7 deletions docs/package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{
"name": "docs",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate"
},
"dependencies": {
"@nuxt/content-theme-docs": "^0.10.1",
"nuxt": "^2.15.2"
"@nuxt/content-theme-docs": "latest",
"nuxt": "latest"
}
}
}
7 changes: 0 additions & 7 deletions husky.config.js

This file was deleted.

5 changes: 2 additions & 3 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module.exports = {
collectCoverage: true,
collectCoverageFrom: ['lib/**/*.js', '!lib/plugin.js'],
testEnvironment: 'node'
preset: '@nuxt/test-utils',
collectCoverageFrom: ['src/**']
}
3 changes: 0 additions & 3 deletions lib/logger.js

This file was deleted.

2 changes: 0 additions & 2 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# https://docs.netlify.com/configure-builds/file-based-configuration

[build]
base = "docs"
command = "yarn generate"
Expand Down
33 changes: 19 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,36 @@
"contributors": [
"Ricardo Gobbo de Souza <ricardogobbosouza@yahoo.com.br>"
],
"main": "lib/module.js",
"main": "./dist/module.js",
"types": "./dist/module.d.ts",
"files": [
"lib"
"dist"
],
"scripts": {
"dev": "nuxt test/fixture/basic",
"lint": "eslint --ext .js,.vue .",
"release": "yarn test && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && jest"
"build": "siroc build",
"prepublishOnly": "yarn build",
"dev": "nuxt dev test/fixture/basic",
"lint": "eslint --ext .js,.ts,.vue .",
"release": "yarn test && yarn build && standard-version && git push --follow-tags && npm publish",
"test": "yarn lint && yarn jest"
},
"dependencies": {
"consola": "^2.15.3",
"google-fonts-helper": "^1.2.0"
"defu": "^3.2.2",
"google-fonts-helper": "^2.0.1"
},
"devDependencies": {
"@commitlint/cli": "latest",
"@commitlint/config-conventional": "latest",
"@nuxtjs/eslint-config": "latest",
"@nuxtjs/module-test-utils": "latest",
"core-js": "2",
"@babel/preset-typescript": "latest",
"@nuxt/test-utils": "latest",
"@nuxt/types": "latest",
"@nuxtjs/eslint-config-typescript": "latest",
"@types/jest": "latest",
"@types/node": "latest",
"del": "latest",
"eslint": "latest",
"husky": "latest",
"jest": "latest",
"nuxt-edge": "latest",
"nuxt": "latest",
"siroc": "latest",
"standard-version": "latest"
},
"publishConfig": {
Expand Down
3 changes: 0 additions & 3 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
{
"extends": [
"@nuxtjs"
],
"ignoreDeps": [
"core-js"
]
}
Loading

0 comments on commit 81259ca

Please sign in to comment.