Skip to content

Commit

Permalink
Add improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Nov 13, 2022
1 parent a073dbb commit a3de7d3
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 12 deletions.
4 changes: 3 additions & 1 deletion build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ if (value.length === 0) {

await fs.writeFile(
'index.js',
'export const linkRel = ' + JSON.stringify(value.sort(), null, 2) + '\n'
'/**\n * List of valid values for `rel` on `<link>`\n */\nexport const linkRel = ' +
JSON.stringify(value.sort(), null, 2) +
'\n'
)

/**
Expand Down
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* List of valid values for `rel` on `<link>`
*/
export const linkRel = [
'DCTERMS.conformsTo',
'DCTERMS.contributor',
Expand Down
85 changes: 74 additions & 11 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,58 @@
[![Downloads][downloads-badge]][downloads]
[![Size][size-badge]][size]

List of values viable for use in `rel` attributes on `link` elements, as defined
by [HTML][spec] and [MicroFormats][extensions].
List of valid values for `rel` on `<link>`.

See [`html-link-types`][html-link-types] for just the specced types.
## Contents

## Install
* [What is this?](#what-is-this)
* [When should I use this?](#when-should-i-use-this)
* [Install](#install)
* [Use](#use)
* [API](#api)
* [`linkRel`](#linkrel)
* [Types](#types)
* [Compatibility](#compatibility)
* [Contribute](#contribute)
* [Security](#security)
* [License](#license)

## What is this?

This package is ESM only: Node 12+ is needed to use it and it must be `import`ed
instead of `require`d.
This package is a list of specified and common values of `rel` attributes on
`link` elements.
The list comes from the [HTML spec][spec] and [MicroFormats][extensions].

[npm][]:
## When should I use this?

You can use this package to check if a certain value is valid value of a `rel`
attribute on a `link` element.
Alternatively, you can use [`html-link-types`][html-link-types] for just the
specced values.

## Install

This package is [ESM only][esm].
In Node.js (version 14.14+, 16.0+), install with [npm][]:

```sh
npm install link-rel
```

In Deno with [`esm.sh`][esmsh]:

```js
import {linkRel} from 'https://esm.sh/link-rel@2'
```

In browsers with [`esm.sh`][esmsh]:

```html
<script type="module">
import {linkRel} from 'https://esm.sh/link-rel@2?bundle'
</script>
```

## Use

```js
Expand Down Expand Up @@ -50,13 +86,32 @@ Yields:

## API

This package exports the following identifiers: `linkRel`.
This package exports the identifier `linkRel`.
There is no default export.

### `linkRel`

`Array.<string>` — List of lowercase possible link types for `rel` on `link`
elements.
List of valid values for `rel` on `<link>` (`Array<string>`).

## Types

This package is fully typed with [TypeScript][].
It exports no additional types.

## Compatibility

This package is at least compatible with all maintained versions of Node.js.
As of now, that is Node.js 14.14+ and 16.0+.
It also works in Deno and modern browsers.

## Contribute

Yes please!
See [How to Contribute to Open Source][contribute].

## Security

This package is safe.

## License

Expand All @@ -82,11 +137,19 @@ elements.

[npm]: https://docs.npmjs.com/cli/install

[esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c

[esmsh]: https://esm.sh

[typescript]: https://www.typescriptlang.org

[contribute]: https://opensource.guide/how-to-contribute/

[license]: license

[author]: https://wooorm.com

[spec]: https://html.spec.whatwg.org/#linkTypes
[spec]: https://html.spec.whatwg.org/multipage/links.html#linkTypes

[extensions]: http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions

Expand Down

0 comments on commit a3de7d3

Please sign in to comment.