├── .editorconfig
├── .github
└── workflows
│ └── main.yml
├── .gitignore
├── .npmrc
├── .prettierignore
├── build.js
├── funding.yml
├── index.js
├── license
├── package.json
├── readme.md
├── test.js
└── tsconfig.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = space
5 | indent_size = 2
6 | end_of_line = lf
7 | charset = utf-8
8 | trim_trailing_whitespace = true
9 | insert_final_newline = true
10 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: main
2 | on:
3 | - pull_request
4 | - push
5 | jobs:
6 | main:
7 | name: ${{matrix.node}}
8 | runs-on: ubuntu-latest
9 | steps:
10 | - uses: actions/checkout@v3
11 | - uses: actions/setup-node@v3
12 | with:
13 | node-version: ${{matrix.node}}
14 | - run: npm install
15 | - run: npm test
16 | - uses: codecov/codecov-action@v1
17 | strategy:
18 | matrix:
19 | node:
20 | - lts/hydrogen
21 | - node
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | *.d.ts
3 | *.log
4 | coverage/
5 | node_modules/
6 | yarn.lock
7 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
2 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | coverage/
2 | *.md
3 |
--------------------------------------------------------------------------------
/build.js:
--------------------------------------------------------------------------------
1 | import fs from 'node:fs/promises'
2 | import fetch from 'node-fetch'
3 | import {fromHtml} from 'hast-util-from-html'
4 | import {select, selectAll} from 'hast-util-select'
5 | import {toString} from 'hast-util-to-string'
6 |
7 | const response = await fetch(
8 | 'https://microformats.org/wiki/existing-rel-values'
9 | )
10 | const text = await response.text()
11 |
12 | const tree = fromHtml(text)
13 | const value = table('formats').concat(table('HTML5_link_type_extensions'))
14 |
15 | if (value.length === 0) {
16 | throw new Error('Couldn’t find any rels')
17 | }
18 |
19 | await fs.writeFile(
20 | 'index.js',
21 | '/**\n * List of valid values for `rel` on ``\n */\nexport const linkRel = ' +
22 | JSON.stringify(value.sort(), null, 2) +
23 | '\n'
24 | )
25 |
26 | /**
27 | * @param {string} name
28 | */
29 | function table(name) {
30 | const node = select('h2:has(#' + name + ') ~ table', tree)
31 |
32 | if (!node) {
33 | throw new Error('Missing node for name `' + name + '`')
34 | }
35 |
36 | const rows = selectAll('tr', node).slice(1)
37 |
38 | return rows
39 | .map((row) => selectAll('td', row).map((d) => toString(d).trim()))
40 | .filter((cells) => !/not allowed/i.test(cells[1]))
41 | .map((cells) => cells[0])
42 | }
43 |
--------------------------------------------------------------------------------
/funding.yml:
--------------------------------------------------------------------------------
1 | github: wooorm
2 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * List of valid values for `rel` on ``
3 | */
4 | export const linkRel = [
5 | 'DCTERMS.conformsTo',
6 | 'DCTERMS.contributor',
7 | 'DCTERMS.creator',
8 | 'DCTERMS.description',
9 | 'DCTERMS.hasFormat',
10 | 'DCTERMS.hasPart',
11 | 'DCTERMS.hasVersion',
12 | 'DCTERMS.isFormatOf',
13 | 'DCTERMS.isPartOf',
14 | 'DCTERMS.isReferencedBy',
15 | 'DCTERMS.isReplacedBy',
16 | 'DCTERMS.isRequiredBy',
17 | 'DCTERMS.isVersionOf',
18 | 'DCTERMS.license',
19 | 'DCTERMS.mediator',
20 | 'DCTERMS.publisher',
21 | 'DCTERMS.references',
22 | 'DCTERMS.relation',
23 | 'DCTERMS.replaces',
24 | 'DCTERMS.requires',
25 | 'DCTERMS.rightsHolder',
26 | 'DCTERMS.source',
27 | 'DCTERMS.subject',
28 | 'EditURI',
29 | 'about',
30 | 'alternate',
31 | 'amphtml',
32 | 'appendix',
33 | 'apple-touch-icon',
34 | 'apple-touch-icon-precomposed',
35 | 'apple-touch-startup-image',
36 | 'archived',
37 | 'attachment',
38 | 'authorization_endpoint',
39 | 'canonical',
40 | 'category',
41 | 'chapter',
42 | 'child',
43 | 'chrome-webstore-item',
44 | 'code-license',
45 | 'code-repository',
46 | 'component',
47 | 'content-license',
48 | 'content-repository',
49 | 'contents',
50 | 'copyright',
51 | 'discussion',
52 | 'dns-prefetch',
53 | 'donation',
54 | 'edit',
55 | 'enclosure',
56 | 'first',
57 | 'gbfs',
58 | 'glossary',
59 | 'gtfs-realtime',
60 | 'gtfs-static',
61 | 'help',
62 | 'home',
63 | 'http://docs.oasis-open.org/ns/cmis/link/200908/acl',
64 | 'hub',
65 | 'image_src',
66 | 'import',
67 | 'in-reply-to',
68 | 'index',
69 | 'issues',
70 | 'its-rules',
71 | 'jslicense',
72 | 'last',
73 | 'license',
74 | 'main',
75 | 'manifest',
76 | 'mask-icon',
77 | 'me',
78 | 'meta',
79 | 'micropub',
80 | 'next',
81 | 'openid.delegate',
82 | 'openid.server',
83 | 'openid2.local_id',
84 | 'openid2.provider',
85 | 'p3pv1',
86 | 'parent',
87 | 'pgpkey',
88 | 'pingback',
89 | 'preconnect',
90 | 'prerender',
91 | 'prev',
92 | 'previous',
93 | 'profile',
94 | 'publisher',
95 | 'radioepg',
96 | 'rendition',
97 | 'reply-to',
98 | 'root',
99 | 'schema.DCTERMS',
100 | 'section',
101 | 'service',
102 | 'shortlink',
103 | 'sidebar',
104 | 'sitemap',
105 | 'start',
106 | 'stylesheet',
107 | 'stylesheet/less',
108 | 'subresource',
109 | 'subsection',
110 | 'sword',
111 | 'syndication',
112 | 'timesheet',
113 | 'toc',
114 | 'token_endpoint',
115 | 'transformation',
116 | 'webmention',
117 | 'widget',
118 | 'wlwmanifest',
119 | 'yandex-tableau-widget'
120 | ]
121 |
--------------------------------------------------------------------------------
/license:
--------------------------------------------------------------------------------
1 | (The MIT License)
2 |
3 | Copyright (c) 2016 Titus Wormer
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | 'Software'), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be
14 | included in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "link-rel",
3 | "version": "2.0.1",
4 | "description": "List of link types for `rel` on `link`",
5 | "license": "MIT",
6 | "keywords": [
7 | "html",
8 | "link",
9 | "type",
10 | "rel",
11 | "attribute",
12 | "w3c"
13 | ],
14 | "repository": "wooorm/link-rel",
15 | "bugs": "https://github.com/wooorm/link-rel/issues",
16 | "funding": {
17 | "type": "github",
18 | "url": "https://github.com/sponsors/wooorm"
19 | },
20 | "author": "Titus Wormer (https://wooorm.com)",
21 | "contributors": [
22 | "Titus Wormer (https://wooorm.com)"
23 | ],
24 | "sideEffects": false,
25 | "type": "module",
26 | "main": "index.js",
27 | "types": "index.d.ts",
28 | "files": [
29 | "index.d.ts",
30 | "index.js"
31 | ],
32 | "devDependencies": {
33 | "@types/node": "^18.0.0",
34 | "c8": "^7.0.0",
35 | "hast-util-from-html": "^1.0.0",
36 | "hast-util-select": "^5.0.0",
37 | "hast-util-to-string": "^2.0.0",
38 | "node-fetch": "^3.0.0",
39 | "prettier": "^2.0.0",
40 | "remark-cli": "^11.0.0",
41 | "remark-preset-wooorm": "^9.0.0",
42 | "rimraf": "^3.0.0",
43 | "type-coverage": "^2.0.0",
44 | "typescript": "^4.0.0",
45 | "xo": "^0.52.0"
46 | },
47 | "scripts": {
48 | "prepack": "npm run build && npm run format",
49 | "generate": "node build.js",
50 | "build": "tsc --build --clean && tsc --build && type-coverage",
51 | "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
52 | "test-api": "node --conditions development test.js",
53 | "test-coverage": "c8 --check-coverage --100 --reporter lcov npm run test-api",
54 | "test": "npm run build && npm run format && npm run test-coverage"
55 | },
56 | "prettier": {
57 | "tabWidth": 2,
58 | "useTabs": false,
59 | "singleQuote": true,
60 | "bracketSpacing": false,
61 | "semi": false,
62 | "trailingComma": "none"
63 | },
64 | "xo": {
65 | "prettier": true
66 | },
67 | "remarkConfig": {
68 | "plugins": [
69 | "preset-wooorm"
70 | ]
71 | },
72 | "typeCoverage": {
73 | "atLeast": 100,
74 | "detail": true,
75 | "strict": true
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # link-rel
2 |
3 | [![Build][build-badge]][build]
4 | [![Coverage][coverage-badge]][coverage]
5 | [![Downloads][downloads-badge]][downloads]
6 | [![Size][size-badge]][size]
7 |
8 | List of valid values for `rel` on ``.
9 |
10 | ## Contents
11 |
12 | * [What is this?](#what-is-this)
13 | * [When should I use this?](#when-should-i-use-this)
14 | * [Install](#install)
15 | * [Use](#use)
16 | * [API](#api)
17 | * [`linkRel`](#linkrel)
18 | * [Types](#types)
19 | * [Compatibility](#compatibility)
20 | * [Contribute](#contribute)
21 | * [Security](#security)
22 | * [License](#license)
23 |
24 | ## What is this?
25 |
26 | This package is a list of specified and common values of `rel` attributes on
27 | `link` elements.
28 | The list comes from the [HTML spec][spec] and [MicroFormats][extensions].
29 |
30 | ## When should I use this?
31 |
32 | You can use this package to check if a certain value is valid value of a `rel`
33 | attribute on a `link` element.
34 | Alternatively, you can use [`html-link-types`][html-link-types] for just the
35 | specced values.
36 |
37 | ## Install
38 |
39 | This package is [ESM only][esm].
40 | In Node.js (version 14.14+, 16.0+), install with [npm][]:
41 |
42 | ```sh
43 | npm install link-rel
44 | ```
45 |
46 | In Deno with [`esm.sh`][esmsh]:
47 |
48 | ```js
49 | import {linkRel} from 'https://esm.sh/link-rel@2'
50 | ```
51 |
52 | In browsers with [`esm.sh`][esmsh]:
53 |
54 | ```html
55 |
58 | ```
59 |
60 | ## Use
61 |
62 | ```js
63 | import {linkRel} from 'link-rel'
64 |
65 | console.log(linkRel.length) //=> 112
66 |
67 | console.log(linkRel.slice(0, 10))
68 | ```
69 |
70 | Yields:
71 |
72 | ```js
73 | [
74 | 'DCTERMS.conformsTo',
75 | 'DCTERMS.contributor',
76 | 'DCTERMS.creator',
77 | 'DCTERMS.description',
78 | 'DCTERMS.hasFormat',
79 | 'DCTERMS.hasPart',
80 | 'DCTERMS.hasVersion',
81 | 'DCTERMS.isFormatOf',
82 | 'DCTERMS.isPartOf',
83 | 'DCTERMS.isReferencedBy'
84 | ]
85 | ```
86 |
87 | ## API
88 |
89 | This package exports the identifier `linkRel`.
90 | There is no default export.
91 |
92 | ### `linkRel`
93 |
94 | List of valid values for `rel` on `` (`Array`).
95 |
96 | ## Types
97 |
98 | This package is fully typed with [TypeScript][].
99 | It exports no additional types.
100 |
101 | ## Compatibility
102 |
103 | This package is at least compatible with all maintained versions of Node.js.
104 | As of now, that is Node.js 14.14+ and 16.0+.
105 | It also works in Deno and modern browsers.
106 |
107 | ## Contribute
108 |
109 | Yes please!
110 | See [How to Contribute to Open Source][contribute].
111 |
112 | ## Security
113 |
114 | This package is safe.
115 |
116 | ## License
117 |
118 | [MIT][license] © [Titus Wormer][author]
119 |
120 |
121 |
122 | [build-badge]: https://github.com/wooorm/link-rel/workflows/main/badge.svg
123 |
124 | [build]: https://github.com/wooorm/link-rel/actions
125 |
126 | [coverage-badge]: https://img.shields.io/codecov/c/github/wooorm/link-rel.svg
127 |
128 | [coverage]: https://codecov.io/github/wooorm/link-rel
129 |
130 | [downloads-badge]: https://img.shields.io/npm/dm/link-rel.svg
131 |
132 | [downloads]: https://www.npmjs.com/package/link-rel
133 |
134 | [size-badge]: https://img.shields.io/bundlephobia/minzip/link-rel.svg
135 |
136 | [size]: https://bundlephobia.com/result?p=link-rel
137 |
138 | [npm]: https://docs.npmjs.com/cli/install
139 |
140 | [esm]: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c
141 |
142 | [esmsh]: https://esm.sh
143 |
144 | [typescript]: https://www.typescriptlang.org
145 |
146 | [contribute]: https://opensource.guide/how-to-contribute/
147 |
148 | [license]: license
149 |
150 | [author]: https://wooorm.com
151 |
152 | [spec]: https://html.spec.whatwg.org/multipage/links.html#linkTypes
153 |
154 | [extensions]: http://microformats.org/wiki/existing-rel-values#HTML5_link_type_extensions
155 |
156 | [html-link-types]: https://github.com/wooorm/html-link-types
157 |
--------------------------------------------------------------------------------
/test.js:
--------------------------------------------------------------------------------
1 | import assert from 'node:assert/strict'
2 | import test from 'node:test'
3 | import {linkRel} from './index.js'
4 |
5 | test('linkRel', function () {
6 | assert.ok(Array.isArray(linkRel), 'should be an `array`')
7 |
8 | assert.doesNotThrow(function () {
9 | let index = -1
10 | while (++index < linkRel.length) {
11 | assert.strictEqual(typeof linkRel[index], 'string', linkRel[index])
12 | }
13 | }, 'should be a `string`s')
14 | })
15 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["**/**.js"],
3 | "exclude": ["coverage", "node_modules"],
4 | "compilerOptions": {
5 | "checkJs": true,
6 | "declaration": true,
7 | "emitDeclarationOnly": true,
8 | "exactOptionalPropertyTypes": true,
9 | "forceConsistentCasingInFileNames": true,
10 | "lib": ["es2020"],
11 | "module": "node16",
12 | "newLine": "lf",
13 | "skipLibCheck": true,
14 | "strict": true,
15 | "target": "es2020"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------