-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes GH-9. Reviewed-by: Christian Murphy <[email protected]> Reviewed-by: Titus Wormer <[email protected]>
- Loading branch information
1 parent
2ef53d3
commit c82fbed
Showing
7 changed files
with
146 additions
and
6 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
coverage/ | ||
rehype-document.js | ||
rehype-document.min.js | ||
*.md |
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 |
---|---|---|
|
@@ -26,17 +26,21 @@ | |
"Titus Wormer <[email protected]> (https://wooorm.com)" | ||
], | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"types/index.d.ts" | ||
], | ||
"types": "types/index.d.ts", | ||
"dependencies": { | ||
"@types/hast": "^2.3.0", | ||
"doctype": "^2.0.0", | ||
"hastscript": "^5.0.0", | ||
"unist-builder": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^16.0.0", | ||
"dtslint": "^3.4.2", | ||
"nyc": "^15.0.0", | ||
"prettier": "^1.0.0", | ||
"prettier": "^2.0.5", | ||
"rehype": "^9.0.0", | ||
"remark-cli": "^7.0.0", | ||
"remark-preset-wooorm": "^6.0.0", | ||
|
@@ -45,13 +49,14 @@ | |
"xo": "^0.28.0" | ||
}, | ||
"scripts": { | ||
"format": "remark . -qfo && prettier --write \"**/*.js\" && xo --fix", | ||
"format": "remark . -qfo && prettier --write . && xo --fix", | ||
"build-bundle": "browserify index.js -s rehypeDocument > rehype-document.js", | ||
"build-mangle": "browserify index.js -s rehypeDocument -p tinyify > rehype-document.min.js", | ||
"build": "npm run build-bundle && npm run build-mangle", | ||
"test-api": "node test", | ||
"test-coverage": "nyc --reporter lcov tape test.js", | ||
"test": "npm run format && npm run build && npm run test-coverage" | ||
"test-types": "dtslint types", | ||
"test": "npm run format && npm run build && npm run test-coverage && npm run test-types" | ||
}, | ||
"nyc": { | ||
"check-coverage": true, | ||
|
@@ -71,6 +76,7 @@ | |
"prettier": true, | ||
"esnext": false, | ||
"ignores": [ | ||
"**/*.ts", | ||
"rehype-document.js" | ||
] | ||
}, | ||
|
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
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,95 @@ | ||
// Minimum TypeScript Version: 3.2 | ||
import {Plugin} from 'unified' | ||
import {Properties} from 'hast' | ||
|
||
/** | ||
* Wrap a document around a fragment. | ||
*/ | ||
declare const document: Plugin<[document.Options?]> | ||
|
||
declare namespace document { | ||
interface Options { | ||
/** | ||
* Text to use as title | ||
* | ||
* default: name of file, if any | ||
*/ | ||
title?: string | ||
|
||
/** | ||
* Natural language of document. | ||
* | ||
* should be a [BCP 47](https://tools.ietf.org/html/bcp47) language tag. | ||
* | ||
* @default 'en' | ||
*/ | ||
language?: string | ||
|
||
/** | ||
* Whether to insert a `meta[viewport]`. | ||
* | ||
* @default true | ||
*/ | ||
responsive?: boolean | ||
|
||
/** | ||
* [Doctype](https://github.com/wooorm/doctype) to use. | ||
* | ||
* @default '5' | ||
*/ | ||
doctype?: string | ||
|
||
/** | ||
* CSS to include in `head` in `<style>` elements. | ||
* | ||
* @default [] | ||
*/ | ||
style?: string | string[] | ||
|
||
/** | ||
* Links to stylesheets to include in `head` | ||
* | ||
* @default [] | ||
*/ | ||
css?: string | string[] | ||
|
||
/** | ||
* Metadata to include in `head`. | ||
* | ||
* Each object is passed as | ||
* [`properties`](https://github.com/syntax-tree/hastscript#hselector-properties-children) | ||
* to [`hastscript`](https://github.com/syntax-tree/hastscript) with a | ||
* `meta` element. | ||
* | ||
* @default [] | ||
*/ | ||
meta?: Properties | Properties[] | ||
|
||
/** | ||
* Link tags to include in `head`. | ||
* | ||
* Each object is passed as | ||
* [`properties`](https://github.com/syntax-tree/hastscript#hselector-properties-children) | ||
* to [`hastscript`](https://github.com/syntax-tree/hastscript) with a `link` element. | ||
* | ||
* @default [] | ||
*/ | ||
link?: Properties | Properties[] | ||
|
||
/** | ||
* Inline scripts to include at end of `body`. | ||
* | ||
* @default [] | ||
*/ | ||
script?: string | string[] | ||
|
||
/** | ||
* External scripts to include at end of `body` | ||
* | ||
* @default [] | ||
*/ | ||
js?: string | string[] | ||
} | ||
} | ||
|
||
export = document |
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,20 @@ | ||
import unified = require('unified') | ||
import document = require('rehype-document') | ||
|
||
unified().use(document) | ||
unified().use(document, {title: ''}) | ||
unified().use(document, {language: ''}) | ||
unified().use(document, {responsive: false}) | ||
unified().use(document, {doctype: ''}) | ||
unified().use(document, {style: ''}) | ||
unified().use(document, {style: ['']}) | ||
unified().use(document, {css: ''}) | ||
unified().use(document, {css: ['']}) | ||
unified().use(document, {meta: {name: '', content: ''}}) | ||
unified().use(document, {meta: [{name: '', content: ''}]}) | ||
unified().use(document, {link: {name: '', content: ''}}) | ||
unified().use(document, {link: [{name: '', content: ''}]}) | ||
unified().use(document, {script: ''}) | ||
unified().use(document, {script: ['']}) | ||
unified().use(document, {js: ''}) | ||
unified().use(document, {js: ['']}) |
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,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"lib": ["es2015"], | ||
"strict": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"rehype-document": ["index.d.ts"] | ||
} | ||
} | ||
} |
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,8 @@ | ||
{ | ||
"extends": "dtslint/dtslint.json", | ||
"rules": { | ||
"no-redundant-jsdoc": false, | ||
"semicolon": false, | ||
"whitespace": false | ||
} | ||
} |