rehype-minify-meta-content
Advanced tools
Comparing version 1.0.1 to 1.0.2
42
index.js
@@ -12,36 +12,36 @@ /** | ||
'use strict'; | ||
'use strict' | ||
var comma = require('comma-separated-tokens'); | ||
var visit = require('unist-util-visit'); | ||
var is = require('hast-util-is-element'); | ||
var has = require('hast-util-has-property'); | ||
var comma = require('comma-separated-tokens') | ||
var visit = require('unist-util-visit') | ||
var is = require('hast-util-is-element') | ||
var has = require('hast-util-has-property') | ||
module.exports = content; | ||
module.exports = content | ||
var own = {}.hasOwnProperty; | ||
var own = {}.hasOwnProperty | ||
var handlers = {}; | ||
var handlers = {} | ||
handlers.viewport = viewport; | ||
handlers.keywords = collapse; | ||
handlers.robots = collapse; | ||
handlers['apple-itunes-app'] = collapse; | ||
handlers['apple-media-service-subscription'] = collapse; | ||
handlers.viewport = viewport | ||
handlers.keywords = collapse | ||
handlers.robots = collapse | ||
handlers['apple-itunes-app'] = collapse | ||
handlers['apple-media-service-subscription'] = collapse | ||
function content() { | ||
return transform; | ||
return transform | ||
} | ||
function transform(tree) { | ||
visit(tree, 'element', visitor); | ||
visit(tree, 'element', visitor) | ||
} | ||
function visitor(node) { | ||
var props = node.properties; | ||
var name = props.name; | ||
var props = node.properties | ||
var name = props.name | ||
if (is(node, 'meta') && has(node, 'content') && own.call(handlers, name)) { | ||
if (typeof props.content === 'string') { | ||
props.content = handlers[name](props.content); | ||
props.content = handlers[name](props.content) | ||
} | ||
@@ -54,11 +54,11 @@ } | ||
value.replace(/(\d+\.\d+)/, toNumber).replace(/user-scalable=\s*yes/, '') | ||
); | ||
) | ||
} | ||
function collapse(value) { | ||
return comma.stringify(comma.parse(value), {padLeft: false}); | ||
return comma.stringify(comma.parse(value), {padLeft: false}) | ||
} | ||
function toNumber(val) { | ||
return Number(val); | ||
return Number(val) | ||
} |
{ | ||
"name": "rehype-minify-meta-content", | ||
"version": "1.0.1", | ||
"description": "Minify `content` on `meta` elements", | ||
"version": "1.0.2", | ||
"description": "rehype plugin to minify `content` on `meta` elements", | ||
"license": "MIT", | ||
"keywords": [ | ||
"unified", | ||
"rehype", | ||
@@ -12,5 +13,5 @@ "hast", | ||
], | ||
"repository": "https://github.com/wooorm/rehype-minify/tree/master/packages/rehype-minify-meta-content", | ||
"bugs": "https://github.com/wooorm/rehype-minify/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (http://wooorm.com)", | ||
"repository": "https://github.com/rehypejs/rehype-minify/tree/master/packages/rehype-minify-meta-content", | ||
"bugs": "https://github.com/rehypejs/rehype-minify/issues", | ||
"author": "Titus Wormer <tituswormer@gmail.com> (https://wooorm.com)", | ||
"contributors": [ | ||
@@ -17,0 +18,0 @@ "Titus Wormer <tituswormer@gmail.com>" |
@@ -5,2 +5,10 @@ <!--This file is generated by `build-packages.js`--> | ||
[![Build][build-badge]][build] | ||
[![Coverage][coverage-badge]][coverage] | ||
[![Downloads][downloads-badge]][downloads] | ||
[![Size][size-badge]][size] | ||
[![Sponsors][sponsors-badge]][collective] | ||
[![Backers][backers-badge]][collective] | ||
[![Chat][chat-badge]][chat] | ||
Minify `content` on `meta` elements. | ||
@@ -13,2 +21,4 @@ | ||
[npm][]: | ||
```sh | ||
@@ -34,4 +44,54 @@ npm install rehype-minify-meta-content | ||
## Contribute | ||
See [`contributing.md`][contributing] in [`rehypejs/.github`][health] for ways | ||
to get started. | ||
See [`support.md`][support] for ways to get help. | ||
This project has a [Code of Conduct][coc]. | ||
By interacting with this repository, organisation, or community you agree to | ||
abide by its terms. | ||
## License | ||
[MIT](https://github.com/wooorm/rehype-minify/blob/master/LICENSE) © [Titus Wormer](http://wooorm.com) | ||
[MIT][license] © [Titus Wormer][author] | ||
[build-badge]: https://img.shields.io/travis/rehypejs/rehype-minify.svg | ||
[build]: https://travis-ci.org/rehypejs/rehype-minify | ||
[coverage-badge]: https://img.shields.io/codecov/c/github/rehypejs/rehype-minify.svg | ||
[coverage]: https://codecov.io/github/rehypejs/rehype-minify | ||
[downloads-badge]: https://img.shields.io/npm/dm/rehype-minify-meta-content.svg | ||
[downloads]: https://www.npmjs.com/package/rehype-minify-meta-content | ||
[size-badge]: https://img.shields.io/bundlephobia/minzip/rehype-minify-meta-content.svg | ||
[size]: https://bundlephobia.com/result?p=rehype-minify-meta-content | ||
[sponsors-badge]: https://opencollective.com/unified/sponsors/badge.svg | ||
[backers-badge]: https://opencollective.com/unified/backers/badge.svg | ||
[collective]: https://opencollective.com/unified | ||
[chat-badge]: https://img.shields.io/badge/join%20the%20community-on%20spectrum-7b16ff.svg | ||
[chat]: https://spectrum.chat/unified/rehype | ||
[npm]: https://docs.npmjs.com/cli/install | ||
[health]: https://github.com/rehypejs/.github | ||
[contributing]: https://github.com/rehypejs/.github/blob/master/contributing.md | ||
[support]: https://github.com/rehypejs/.github/blob/master/support.md | ||
[coc]: https://github.com/rehypejs/.github/blob/master/code-of-conduct.md | ||
[license]: https://github.com/rehypejs/rehype-minify/blob/master/license | ||
[author]: https://wooorm.com |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
4801
95