Socket
Socket
Sign inDemoInstall

manup

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    manup

Generates meta and link tags from your manifest.json


Version published
Weekly downloads
16
decreased by-38.46%
Maintainers
1
Install size
16.8 kB
Created
Weekly downloads
 

Readme

Source

ManUp.js

Provides the function manup() which given a Web App Manifest object generates according meta and link tags for older browsers. Output is an array of arrays of which the first value is the tag (meta or link) and the second value is the object of attribute/value pairs.

Install

npm i manup

Usage

import manup from 'manup';

const manifest = JSON.parse(fs.readFileSync('./manifest.json', 'utf8'));
const headElements = manup(manifest);

Example manifest.json:

{
  "short_name": "ManUp.js",
  "icons": [
    {
      "src": "/icon-192.png",
      "sizes": "192x192",
      "type": "image/png"
    }
  ],
  "start_url": "/",
  "display": "standalone",
  "theme_color": "#f44336"
}

Example output headElements array:

[
  [ 'meta', { name: 'theme-color', content: '#f44336' } ],
  [ 'meta', { name: 'mobile-web-app-capable', content: 'yes' } ],
  [ 'meta', { name: 'apple-mobile-web-app-capable', content: 'yes' } ],
  [ 'meta', { name: 'apple-mobile-web-app-title', content: 'ManUp.js' } ],
  [ 'meta', { name: 'application-name', content: 'ManUp.js' } ],
  [ 'meta', { name: 'msapplication-navbutton-color', content: '#f44336' } ],
  [ 'link', { rel: 'icon', sizes: '192x192', href: '/icon-192.png' } ]
]

Browsers will choose whether to use the manifest.json or the tags.

Usage with React

const Html = ({ headElements }) => (
  <html lang='en-EN'>
    <head>
      <title>ManUp.js</title>
      <link rel='manifest' href='/manifet.json' />
      {headElements.map(([tag, props], idx) =>
        React.createElement(tag, { ...props, key: idx })
      )}
    </head>
    <body>
      <div id='app' />
    </body>
  </html>
);

Props

The foundation for this comes from https://github.com/boyofgreen/ManUp.js -- thanks! The code was simplified and rewritten as a node module and some more supported tags added.

Keywords

FAQs

Last updated on 11 Sep 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc