Skip to content

Commit 2db8306

Browse files
committed
fix build error
1 parent 97e4339 commit 2db8306

File tree

2 files changed

+74
-7
lines changed

2 files changed

+74
-7
lines changed

packages/pure/libs/icons.ts

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,6 @@ export const BuiltInIcons = {
136136
//line-md:heart-filled
137137
heart:
138138
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><path fill="#ea2727" fill-opacity="0" d="M12 8c0 0 0 0 0.76 -1c0.88 -1.16 2.18 -2 3.74 -2c2.49 0 4.5 2.01 4.5 4.5c0 0.93 -0.28 1.79 -0.76 2.5c-0.81 1.21 -8.24 9 -8.24 9c0 0 -7.43 -7.79 -8.24 -9c-0.48 -0.71 -0.76 -1.57 -0.76 -2.5c0 -2.49 2.01 -4.5 4.5 -4.5c1.56 0 2.87 0.84 3.74 2c0.76 1 0.76 1 0.76 1Z"><animate fill="freeze" attributeName="fill-opacity" begin="0.735s" dur="0.525s" values="0;1"/></path><path fill="none" stroke="#ea2727" stroke-dasharray="32" stroke-dashoffset="32" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.3" d="M12 8c0 0 0 0 -0.76 -1c-0.88 -1.16 -2.18 -2 -3.74 -2c-2.49 0 -4.5 2.01 -4.5 4.5c0 0.93 0.28 1.79 0.76 2.5c0.81 1.21 8.24 9 8.24 9M12 8c0 0 0 0 0.76 -1c0.88 -1.16 2.18 -2 3.74 -2c2.49 0 4.5 2.01 4.5 4.5c0 0.93 -0.28 1.79 -0.76 2.5c-0.81 1.21 -8.24 9 -8.24 9"><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.735s" values="32;0"/></path></svg>',
139-
//inner-link , icon-park-outline:preview-close
140-
inner_link:
141-
'<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><g fill="none" stroke-linejoin="round" stroke-width="1"><path fill="#2f88ff" stroke="#000" d="M24 36C35.0457 36 44 24 44 24C44 24 35.0457 12 24 12C12.9543 12 4 24 4 24C4 24 12.9543 36 24 36Z"/><path fill="#43ccf8" stroke="#fff" d="M24 29C26.7614 29 29 26.7614 29 24C29 21.2386 26.7614 19 24 19C21.2386 19 19 21.2386 19 24C19 26.7614 21.2386 29 24 29Z"/></g></svg>',
142-
//inner-link not_found, mingcute:eye-close-line
143-
inner_link_404:
144-
'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"><g fill="none"><path d="m12.593 23.258l-.011.002l-.071.035l-.02.004l-.014-.004l-.071-.035q-.016-.005-.024.005l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.017-.018m.265-.113l-.013.002l-.185.093l-.01.01l-.003.011l.018.43l.005.012l.008.007l.201.093q.019.005.029-.008l.004-.014l-.034-.614q-.005-.018-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.004-.011l.017-.43l-.003-.012l-.01-.01z"/><path fill="currentColor" d="M3.05 9.31a1 1 0 1 1 1.914-.577c2.086 6.986 11.982 6.987 14.07.004a1 1 0 1 1 1.918.57a9.5 9.5 0 0 1-1.813 3.417L20.414 14A1 1 0 0 1 19 15.414l-1.311-1.311a9.1 9.1 0 0 1-2.32 1.269l.357 1.335a1 1 0 1 1-1.931.518l-.364-1.357c-.947.14-1.915.14-2.862 0l-.364 1.357a1 1 0 1 1-1.931-.518l.357-1.335a9.1 9.1 0 0 1-2.32-1.27l-1.31 1.312A1 1 0 0 1 3.585 14l1.275-1.275c-.784-.936-1.41-2.074-1.812-3.414Z"/></g></svg>',
145-
146139
//twemoji:glowing-star
147140
star: '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 36 36"><path fill="#ffac33" d="M28.84 17.638c-.987 1.044-1.633 3.067-1.438 4.493l.892 6.441c.197 1.427-.701 2.087-1.996 1.469l-5.851-2.796c-1.295-.62-3.408-.611-4.7.018l-5.826 2.842c-1.291.629-2.193-.026-2.007-1.452l.843-6.449c.186-1.427-.475-3.444-1.47-4.481l-4.494-4.688c-.996-1.037-.655-2.102.755-2.365l6.37-1.188c1.41-.263 3.116-1.518 3.793-2.789L16.762.956c.675-1.271 1.789-1.274 2.473-.009L22.33 6.66c.686 1.265 2.4 2.507 3.814 2.758l6.378 1.141c1.412.252 1.761 1.314.774 2.359z"/><path fill="#ffd983" d="M9.783 2.181c1.023 1.413 2.446 4.917 1.717 5.447c-.728.531-3.607-1.91-4.63-3.323s-.935-2.668-.131-3.254c.804-.587 2.02-.282 3.044 1.13m19.348 2.124C28.109 5.718 25.23 8.16 24.5 7.627c-.729-.53.695-4.033 1.719-5.445C27.242.768 28.457.463 29.262 1.051c.803.586.89 1.841-.131 3.254M16.625 33.291c-.001-1.746.898-5.421 1.801-5.421c.897 0 1.798 3.675 1.797 5.42c0 1.747-.804 2.712-1.8 2.71c-.994.002-1.798-.962-1.798-2.709m16.179-9.262c-1.655-.539-4.858-2.533-4.579-3.395c.277-.858 4.037-.581 5.69-.041c1.655.54 2.321 1.605 2.013 2.556c-.308.95-1.469 1.42-3.124.88M2.083 20.594c1.655-.54 5.414-.817 5.694.044c.276.857-2.928 2.854-4.581 3.392c-1.654.54-2.818.07-3.123-.88c-.308-.95.354-2.015 2.01-2.556"/></svg>',
148141
//fluent:book-number-20-regular
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// https://github.com/rehypejs/rehype-external-links
2+
3+
import type { Element, ElementContent, Root } from 'hast'
4+
import { visit } from 'unist-util-visit'
5+
6+
import isAbsoluteUrl from '../utils/is-absolute-url'
7+
8+
export interface ExternalLinkOptions {
9+
content?: ElementContent | ElementContent[]
10+
contentProperties?: Record<string, unknown>
11+
protocols?: string[]
12+
}
13+
14+
const defaultProtocols = ['http', 'https']
15+
16+
/**
17+
* Automatically add `rel` (and `target`?) to external links.
18+
*
19+
* ###### Notes
20+
*
21+
* You should [likely not configure `target`][css-tricks].
22+
*
23+
* You should at least set `rel` to `['nofollow']`.
24+
* When using a `target`, add `noopener` and `noreferrer` to avoid exploitation
25+
* of the `window.opener` API.
26+
*
27+
* When using a `target`, you should set `content` to adhere to accessibility
28+
* guidelines by giving users advanced warning when opening a new window.
29+
*
30+
* [css-tricks]: https://css-tricks.com/use-target_blank/
31+
*
32+
* @param {Readonly<Options> | null | undefined} [options]
33+
* Configuration (optional).
34+
* @returns
35+
* Transform.
36+
*/
37+
export default function rehypeExternalLinks(options: ExternalLinkOptions = {}) {
38+
const { content, contentProperties = {}, protocols = defaultProtocols } = options
39+
40+
return function transformer(tree: Root): void {
41+
visit(tree, 'element', (node: Element) => {
42+
if (node.tagName === 'a' && typeof node.properties?.href === 'string') {
43+
const href = node.properties.href
44+
const protocol = href.startsWith('//')
45+
? 'http' // treat protocol-relative as http
46+
: href.slice(0, href.indexOf(':'))
47+
48+
if (href.startsWith('//') || (isAbsoluteUrl(href) && protocols.includes(protocol))) {
49+
node.properties = {
50+
...node.properties,
51+
rel: 'nofollow noopener noreferrer',
52+
target: '_blank'
53+
}
54+
55+
if (content) {
56+
const spanNode: Element = {
57+
type: 'element',
58+
tagName: 'span',
59+
properties: {
60+
...(contentProperties as Record<
61+
string,
62+
string | number | boolean | (string | number)[] | null | undefined
63+
>)
64+
},
65+
children: Array.isArray(content) ? content : [content]
66+
}
67+
68+
node.children.push(spanNode)
69+
}
70+
}
71+
}
72+
})
73+
}
74+
}

0 commit comments

Comments
 (0)