Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move from nuxt-community/modules
- Loading branch information
Pooya Parsa
committed
Oct 4, 2017
0 parents
commit 8bf7968
Showing
23 changed files
with
4,315 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_size = 2 | ||
indent_style = space | ||
end_of_line = lf | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
module.exports = { | ||
root: true, | ||
parser: 'babel-eslint', | ||
parserOptions: { | ||
sourceType: 'module' | ||
}, | ||
env: { | ||
browser: true, | ||
node: true | ||
}, | ||
extends: 'standard', | ||
// required to lint *.vue files | ||
plugins: [ | ||
'html' | ||
], | ||
// add your custom rules here | ||
rules: { | ||
// allow paren-less arrow functions | ||
'arrow-parens': 0, | ||
// allow async-await | ||
'generator-star-spacing': 0, | ||
// allow debugger during development | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0, | ||
// do not allow console.logs etc... | ||
'no-console': 2 | ||
}, | ||
globals: {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules | ||
*.iml | ||
.idea | ||
*.log* | ||
modules/*/package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
workspaces-experimental true | ||
access public |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
<h1 align="center">PWA</h1> | ||
|
||
Progressive Web Apps (PWA) are reliable, fast,and engaging, although there are many things that can take a PWA from a baseline to exemplary experience. ([learn more](https://developers.google.com/web/progressive-web-apps)). | ||
|
||
Using Nuxt PWA you can supercharge your exciting or next Nuxt project with a heavily tested, updated and stable PWA config. | ||
|
||
<!-- PWA --> | ||
<h2 align="center">Quick Setup</h2> | ||
|
||
1. Install npm package: | ||
|
||
```js | ||
yarn add @nuxtjs/pwa | ||
``` | ||
|
||
2. Edit your `nuxt.config.js` file to add pwa module: | ||
|
||
```js | ||
{ | ||
modules: { | ||
'@nuxtjs/pwa', | ||
}, | ||
} | ||
``` | ||
|
||
3. Ensure `static` dir exists and optionally create `static/icon.png`. Recommended to be square png and >= `512x512px` | ||
|
||
4. Create or add this to `.gitignore`: | ||
|
||
``` | ||
sw.* | ||
workbox-* | ||
``` | ||
|
||
`@nuxtjs/pwa` is a preset module (IE a collection of smaller modules). Continue reading this docs, for detailed info and more customization. | ||
|
||
# Modules | ||
|
||
<!-- PWA --> | ||
<h2 align="center">PWA</h2> | ||
|
||
[![npm](https://img.shields.io/npm/dt/@nuxtjs/pwa.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/pwa) | ||
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/pwa/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/pwa) | ||
|
||
This module adds all other modules for full PWA experience with Nuxt with _almost_ zero-config! | ||
|
||
<!-- Manifest --> | ||
<h2 align="center">Manifest</h2> | ||
|
||
[![npm](https://img.shields.io/npm/dt/@nuxtjs/manifest.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/manifest) | ||
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/manifest/latest.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/manifest) | ||
|
||
This module adds [Web App Manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) with no pain! | ||
|
||
You can add additional options to `manifest` section of `nuxt.config.js` to override defaults: | ||
|
||
```js | ||
{ | ||
manifest: { | ||
name: 'My Awesome App', | ||
lang: 'fa' | ||
} | ||
} | ||
``` | ||
|
||
<!-- Meta --> | ||
<h2 align="center">Meta</h2> | ||
|
||
[![npm](https://img.shields.io/npm/dt/@nuxtjs/meta.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/meta) | ||
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/meta/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/meta) | ||
|
||
This module easily adds common meta tags into your project with zero-config needed. | ||
|
||
You can optionally override meta using either `manifest` or `meta` section of `nuxt.config.js`: | ||
|
||
```js | ||
{ | ||
meta: { | ||
// ... | ||
} | ||
} | ||
``` | ||
|
||
### options | ||
|
||
Meta / Link | Customize With | Default value | ||
---------------------------------------|-----------------------|------------------- | ||
`charset` | `charset` | `utf-8` | ||
`viewport` | `viewport` | `width=device-width, initial-scale=1, minimal-ui` | ||
`mobile-web-app-capable` | `mobileApp` | `true` | ||
`apple-mobile-web-app-capable` | `mobileAppIOS`* | **`false`** | ||
`apple-mobile-web-app-status-bar-style`| `appleStatusBarStyle`*| `default` | ||
`shortcut icon` + `apple-touch-icon` | `favicon` | `true` (to use options.icons) | ||
`title` | `name` | npm_package_name | ||
`description` | `description` | npm_package_description | ||
`theme-color` | `theme_color` | options.loading.color | ||
`lang` | `lang` | `en` | ||
`og:type` | `ogType` | `website` | ||
`og:title` | `ogTitle` | same as options.name | ||
`og:description` | `ogDescription` | same as options.description | ||
|
||
|
||
Please read this resources before setting IOS specific options: | ||
|
||
- https://developer.apple.com/library/content/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/MetaTags.html | ||
- https://medium.com/@firt/dont-use-ios-web-app-meta-tag-irresponsibly-in-your-progressive-web-apps-85d70f4438cb | ||
|
||
<!-- Workbox --> | ||
|
||
<h2 align="center">Workbox</h2> | ||
|
||
[![npm](https://img.shields.io/npm/dt/@nuxtjs/workbox.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/workbox) | ||
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/workbox/latest.svg?style=flat-square)](https://npmjs.com/package/@nuxtjs/workbox) | ||
|
||
Workbox is a collection of JavaScript libraries for Progressive Web Apps. | ||
([Learn more](https://github.com/GoogleChrome/workbox)) | ||
|
||
This module adds full offline support using workbox. | ||
|
||
### Options | ||
For list of available options | ||
see [generateSW](https://workboxjs.org/reference-docs/latest/module-workbox-build.html#.generateSW). | ||
|
||
<!-- Icon --> | ||
|
||
<h2 align="center">Icon</h2> | ||
|
||
[![npm](https://img.shields.io/npm/dt/@nuxtjs/icon.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/icon) | ||
[![npm (scoped with tag)](https://img.shields.io/npm/v/@nuxtjs/icon/latest.svg?style=flat-square)](https://www.npmjs.com/package/@nuxtjs/icon) | ||
|
||
This module automatically generates app icons and favicon with different sizes using [jimp](https://github.com/oliver-moran/jimp). | ||
|
||
- This module fills `manifest.icons[]` with proper paths to generated assets that is used by [manifest](../manifest) module. | ||
- Source icon is being resized using *cover* method. | ||
|
||
### options | ||
|
||
#### `iconSrc` | ||
- Default: `[srcDir]/static/icon.png` | ||
|
||
#### `sizes` | ||
- Default: `[16, 120, 144, 152, 192, 384, 512]` | ||
|
||
Array of sizes to be generated (Square). | ||
|
||
<h2 align="center">License</h2> | ||
|
||
MIT - Nuxt Community - Pooya Parsa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"lerna": "2.3.1", | ||
"useWorkspaces": true, | ||
"version": "independent", | ||
"npmClient": "yarn", | ||
"packages": [ | ||
"packages/*" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"private": true, | ||
"contributors": [ | ||
"Pooya Parsa <pooya@pi0.ir>" | ||
], | ||
"scripts": { | ||
"lerna": "lerna", | ||
"bootstrap": "lerna bootstrap", | ||
"lint": "eslint --ext .js packages", | ||
"release": "lerna publish -p --conventional-commits", | ||
"force-release": "for p in packages/*; do cd $p ; npm publish ; cd ../.. ; done" | ||
}, | ||
"workspaces": [ | ||
"packages/*" | ||
], | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^4.8.0", | ||
"eslint-config-standard": "^10.2.1", | ||
"eslint-plugin-html": "^3.2.2", | ||
"eslint-plugin-import": "^2.7.0", | ||
"eslint-plugin-node": "^5.2.0", | ||
"eslint-plugin-promise": "^3.5.0", | ||
"eslint-plugin-standard": "^3.0.1", | ||
"lerna": "^2.3.1", | ||
"standard-version": "^4.2.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. | ||
|
||
<a name="1.1.0"></a> | ||
# [1.1.0](https://github.com/nuxt/modules/compare/@nuxtjs/icon@1.0.1...@nuxtjs/icon@1.1.0) (2017-09-21) | ||
|
||
|
||
### Features | ||
|
||
* **icon:** set minimum size to 64 ([5bd9460](https://github.com/nuxt/modules/commit/5bd9460)) | ||
|
||
|
||
|
||
|
||
<a name="1.0.1"></a> | ||
## [1.0.1](https://github.com/nuxt/modules/compare/@nuxtjs/icon@1.0.0...@nuxtjs/icon@1.0.1) (2017-08-02) | ||
|
||
|
||
|
||
|
||
<a name="0.1.0"></a> | ||
# 0.1.0 (2017-06-06) | ||
|
||
|
||
### Bug Fixes | ||
|
||
* **icon:** fix iconSrc type ([9aaaba7](https://github.com/nuxt/modules/commit/9aaaba7)) | ||
|
||
|
||
### Features | ||
|
||
* 🖼️ icon module ([6201d2a](https://github.com/nuxt/modules/commit/6201d2a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
const fs = require('fs-extra') | ||
const path = require('path') | ||
const Jimp = require('jimp') | ||
|
||
const fixUrl = url => url.replace(/\/\//g, '/').replace(':/', '://') | ||
const isUrl = url => url.indexOf('http') === 0 || url.indexOf('//') === 0 | ||
|
||
module.exports = function nuxtIcon (options) { | ||
const iconSrc = options.iconSrc || path.resolve(this.options.srcDir, 'static', 'icon.png') | ||
const sizes = options.sizes || [64, 120, 144, 152, 192, 384, 512] | ||
|
||
// routerBase and publicPath | ||
const routerBase = this.options.router.base | ||
let publicPath = fixUrl(`${routerBase}/${this.options.build.publicPath}`) | ||
if (isUrl(this.options.build.publicPath)) { // CDN | ||
publicPath = this.options.build.publicPath | ||
if (publicPath.indexOf('//') === 0) { | ||
publicPath = '/' + publicPath // escape fixUrl | ||
} | ||
} | ||
|
||
// Ensure icon file exists | ||
if (!fs.existsSync(iconSrc)) { | ||
/* eslint-disable no-console */ | ||
console.warn('[@nuxtjs/icon]', path.relative(this.options.srcDir, iconSrc), 'not found! Please create one or disable icon module.') | ||
return | ||
} | ||
|
||
return Jimp.read(iconSrc).then(srcIcon => { | ||
// get base64 phash of source image | ||
const hash = srcIcon.hash() | ||
return Promise.all(sizes.map(size => new Promise((resolve, reject) => { | ||
srcIcon.clone().contain(size, size).getBuffer(Jimp.MIME_PNG, (err, buff) => { | ||
if (err) { | ||
return reject(err) | ||
} | ||
let fileName = `icons/icon_${size}.${hash}.png` | ||
resolve({ size, buff, fileName }) | ||
}) | ||
}))).then(icons => { | ||
// Fill manifest icons | ||
if (!this.options.manifest) { | ||
this.options.manifest = {} | ||
} | ||
if (!this.options.manifest.icons) { | ||
this.options.manifest.icons = [] | ||
} | ||
icons.forEach(icon => { | ||
this.options.manifest.icons.push({ | ||
src: fixUrl(`${publicPath}/${icon.fileName}`), | ||
sizes: `${icon.size}x${icon.size}`, | ||
type: `image/png` | ||
}) | ||
}) | ||
// Register webpack plugin to emit icons | ||
this.options.build.plugins.push({ | ||
apply (compiler) { | ||
compiler.plugin('emit', function (compilation, _cb) { | ||
icons.forEach(icon => { | ||
compilation.assets[icon.fileName] = { | ||
source: () => icon.buff, | ||
size: () => icon.buff.length | ||
} | ||
}) | ||
_cb() | ||
}) | ||
} | ||
}) | ||
}) | ||
}).catch(err => { | ||
console.error('[icon] unable to read', err) | ||
}) | ||
} | ||
|
||
module.exports.meta = require('./package.json') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "@nuxtjs/icon", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
"main": "index.js", | ||
"repository": "https://github.com/nuxt/modules", | ||
"homepage": "https://github.com/nuxt/modules/tree/master/modules/icon", | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"dependencies": { | ||
"fs-extra": "^3.0.1", | ||
"hash-sum": "^1.0.2", | ||
"jimp": "^0.2.28" | ||
} | ||
} |
Oops, something went wrong.