https://github.com/renddslow/make-document-headers
https://github.com/renddslow/make-document-headers
Last synced: 10 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/renddslow/make-document-headers
- Owner: Renddslow
- License: other
- Created: 2019-02-08T23:02:57.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-03T20:03:34.000Z (about 3 years ago)
- Last Synced: 2025-02-21T23:03:10.247Z (10 months ago)
- Language: JavaScript
- Size: 136 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Make Document Headers
>
## Install
```
yarn add make-document-headers
```
## Usage
```js
const makeDocumentHeaders = require('make-document-headers');
makeDocumentHeaders('Neat Site', [
{
type: 'meta',
attributes: {
name: 'viewport',
content: 'initial-scale=1.0',
},
selfClosing: true,
},
{
type: 'meta',
attributes: {
name: 'description',
content: 'This is the coolest site!',
},
selfClosing: true,
},
{
type: 'script',
attributes: {
src: 'http://cdn.example.com/hello.js',
},
children: '(function() { run(); })();',
},
]);
```
Generates:
```html
Neat Site
(function() { run(); })();
```
## API
### makeDocumentHeaders(title, tags)
**title**
Type: `string`
The document title
**tags**
Type: `Array`
An array of tag objects
**Tag**
- `type`: The tag type as a string (e.g. `script`, `meta`, `link`)
- `attributes`: An object of attributes where the key is the attribute and the value is the attribute value
- `selfClosing`: A boolean denoting whether or not the tag should be self-closing
- `children`: A string with the children to be nested inside the tag