@t8/docsgen 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/dist/bin.js +756 -0
- package/dist/css/base.css +232 -0
- package/dist/css/code.css +30 -0
- package/dist/css/code.lightbulb.css +278 -0
- package/dist/css/index.css +212 -0
- package/dist/css/section.css +200 -0
- package/package.json +36 -0
- package/src/bin/cleanup.ts +11 -0
- package/src/bin/createFiles.ts +8 -0
- package/src/bin/fetchText.ts +16 -0
- package/src/bin/getConfig.ts +44 -0
- package/src/bin/getCounterContent.ts +17 -0
- package/src/bin/getNav.ts +64 -0
- package/src/bin/getParsedContent.ts +180 -0
- package/src/bin/getRepoLink.ts +9 -0
- package/src/bin/getSlug.ts +21 -0
- package/src/bin/getTitle.ts +49 -0
- package/src/bin/run.ts +31 -0
- package/src/bin/runEntry.ts +55 -0
- package/src/bin/setCName.ts +13 -0
- package/src/bin/setContent.ts +251 -0
- package/src/bin/setImages.ts +8 -0
- package/src/bin/toConfig.ts +14 -0
- package/src/bin/toFileContent.ts +3 -0
- package/src/bin/toRepoURL.ts +22 -0
- package/src/const/packageName.ts +1 -0
- package/src/css/base.css +232 -0
- package/src/css/code.css +30 -0
- package/src/css/code.lightbulb.css +278 -0
- package/src/css/index.css +212 -0
- package/src/css/section.css +200 -0
- package/src/types/BinConfig.ts +6 -0
- package/src/types/Context.ts +4 -0
- package/src/types/EntryConfig.ts +57 -0
- package/src/types/NavItem.ts +8 -0
- package/src/types/PackageMetadata.ts +11 -0
- package/src/types/Theme.ts +1 -0
- package/src/utils/escapeHTML.ts +17 -0
- package/src/utils/escapeRegExp.ts +4 -0
- package/src/utils/getIcon.ts +16 -0
- package/src/utils/getSVGDataURL.ts +9 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
html[data-theme="t8"] {
|
|
2
|
+
background:
|
|
3
|
+
linear-gradient(to bottom right, #90eec6, #9a70ce) 50% 50% / cover no-repeat;
|
|
4
|
+
}
|
|
5
|
+
@media (max-width: 840px) {
|
|
6
|
+
html[data-theme="t8"] {
|
|
7
|
+
background:
|
|
8
|
+
linear-gradient(to bottom, #90eec6, #9a70ce) 50% 50% / cover no-repeat;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
@media (prefers-color-scheme: dark) {
|
|
12
|
+
html[data-theme="t8"] {
|
|
13
|
+
background:
|
|
14
|
+
linear-gradient(to bottom right, #14a482, #6649b5) 50% 50% / cover
|
|
15
|
+
no-repeat;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
@media (max-width: 840px) and (prefers-color-scheme: dark) {
|
|
19
|
+
html[data-theme="t8"] {
|
|
20
|
+
background:
|
|
21
|
+
linear-gradient(to bottom, #14a482, #6649b5) 50% 50% / cover no-repeat;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
body {
|
|
25
|
+
min-height: 100vh;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.layout {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
min-height: 90vh;
|
|
32
|
+
align-items: center;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main {
|
|
37
|
+
--max-content-width: 32em;
|
|
38
|
+
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: flex-start;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
padding: 0;
|
|
43
|
+
margin: 6vh 0;
|
|
44
|
+
}
|
|
45
|
+
@media (max-width: 840px) {
|
|
46
|
+
main {
|
|
47
|
+
--max-content-width: 100%;
|
|
48
|
+
|
|
49
|
+
display: block;
|
|
50
|
+
margin: 0;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
h1 {
|
|
55
|
+
font-size: 2.5em;
|
|
56
|
+
font-weight: 900;
|
|
57
|
+
margin: 1.5rem 0;
|
|
58
|
+
}
|
|
59
|
+
@media (max-width: 840px) {
|
|
60
|
+
h1 {
|
|
61
|
+
font-size: 2.35em;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
h1 a {
|
|
65
|
+
position: relative;
|
|
66
|
+
}
|
|
67
|
+
h1 a::before {
|
|
68
|
+
content: "";
|
|
69
|
+
background-color: color(from var(--b1) srgb r g b / 0.3);
|
|
70
|
+
transform: skew(-15deg, -10deg);
|
|
71
|
+
border-radius: 0.4em;
|
|
72
|
+
position: absolute;
|
|
73
|
+
inset: 0.3em -0.25em 0.25em;
|
|
74
|
+
transition: inset 0.3s;
|
|
75
|
+
}
|
|
76
|
+
h1 a:hover {
|
|
77
|
+
text-decoration: none;
|
|
78
|
+
}
|
|
79
|
+
h1 a:hover::before {
|
|
80
|
+
inset: 0.25em -0.25em 0.2em;
|
|
81
|
+
}
|
|
82
|
+
header {
|
|
83
|
+
display: block;
|
|
84
|
+
text-align: center;
|
|
85
|
+
padding: 0 var(--content-padding-x);
|
|
86
|
+
}
|
|
87
|
+
@media (max-width: 840px) {
|
|
88
|
+
.badges {
|
|
89
|
+
margin: 0 2em;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
.description {
|
|
93
|
+
font-size: 1.1em;
|
|
94
|
+
margin: 0;
|
|
95
|
+
}
|
|
96
|
+
.description p {
|
|
97
|
+
margin-top: 0;
|
|
98
|
+
}
|
|
99
|
+
.actions {
|
|
100
|
+
--r: 1em;
|
|
101
|
+
|
|
102
|
+
font-size: 1.25em;
|
|
103
|
+
margin: 0.5em 0;
|
|
104
|
+
}
|
|
105
|
+
.actions a.button {
|
|
106
|
+
min-width: 32%;
|
|
107
|
+
}
|
|
108
|
+
@media (max-width: 840px) {
|
|
109
|
+
.actions {
|
|
110
|
+
font-size: 1.15em;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
.actions .sep {
|
|
114
|
+
display: none;
|
|
115
|
+
}
|
|
116
|
+
.ref {
|
|
117
|
+
font-size: 0.9em;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
section {
|
|
121
|
+
max-width: var(--max-content-width);
|
|
122
|
+
padding: 0 2.5em;
|
|
123
|
+
box-sizing: border-box;
|
|
124
|
+
}
|
|
125
|
+
section + section {
|
|
126
|
+
display: flex;
|
|
127
|
+
flex-direction: column;
|
|
128
|
+
align-self: stretch;
|
|
129
|
+
justify-content: center;
|
|
130
|
+
border-left: 0.1em solid var(--b1-medium);
|
|
131
|
+
}
|
|
132
|
+
section.intro-title {
|
|
133
|
+
text-align: center;
|
|
134
|
+
padding-top: 4em;
|
|
135
|
+
padding-bottom: 4em;
|
|
136
|
+
}
|
|
137
|
+
@media (max-width: 840px) {
|
|
138
|
+
section {
|
|
139
|
+
max-width: 100%;
|
|
140
|
+
padding: var(--content-padding-y) var(--content-padding-x);
|
|
141
|
+
}
|
|
142
|
+
section + section {
|
|
143
|
+
display: block;
|
|
144
|
+
border-left: none;
|
|
145
|
+
}
|
|
146
|
+
section.intro-title {
|
|
147
|
+
padding-top: 2em;
|
|
148
|
+
padding-bottom: 0;
|
|
149
|
+
}
|
|
150
|
+
section.intro {
|
|
151
|
+
padding-bottom: 2.5em;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
.features {
|
|
155
|
+
--link-color: color(from var(--c0) srgb r g b / 0.55);
|
|
156
|
+
--link-decoration: underline;
|
|
157
|
+
|
|
158
|
+
margin: 2em 0;
|
|
159
|
+
}
|
|
160
|
+
@media (max-width: 840px) {
|
|
161
|
+
.features {
|
|
162
|
+
padding: 0;
|
|
163
|
+
margin: 0;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
.features h2 {
|
|
167
|
+
font-size: 1.5em;
|
|
168
|
+
font-style: italic;
|
|
169
|
+
text-align: center;
|
|
170
|
+
border: none;
|
|
171
|
+
padding: 0.1em 0;
|
|
172
|
+
margin: 0.75em 0 0.5em;
|
|
173
|
+
}
|
|
174
|
+
.features > ul {
|
|
175
|
+
list-style: none;
|
|
176
|
+
padding: 0;
|
|
177
|
+
margin: 0.5em 0 0;
|
|
178
|
+
}
|
|
179
|
+
.features > ul > li {
|
|
180
|
+
background: var(--b1-light);
|
|
181
|
+
border-bottom: 0.25em solid var(--b1-medium);
|
|
182
|
+
border-radius: 0.5em;
|
|
183
|
+
padding: 0.9em 1.2em;
|
|
184
|
+
margin: 1em 0;
|
|
185
|
+
box-sizing: border-box;
|
|
186
|
+
}
|
|
187
|
+
@media (max-width: 840px) {
|
|
188
|
+
.features > ul > li {
|
|
189
|
+
width: 100%;
|
|
190
|
+
margin: 0.5em 0;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
.features > ul > li > ul {
|
|
194
|
+
list-style: disc;
|
|
195
|
+
}
|
|
196
|
+
.note {
|
|
197
|
+
padding: 0 3.5em;
|
|
198
|
+
margin: 1.5em 0;
|
|
199
|
+
}
|
|
200
|
+
@media (max-width: 840px) {
|
|
201
|
+
.note {
|
|
202
|
+
padding: 0;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
p.installation {
|
|
206
|
+
font-size: 1.25em;
|
|
207
|
+
text-align: center;
|
|
208
|
+
margin: 1em 0;
|
|
209
|
+
}
|
|
210
|
+
.installation code {
|
|
211
|
+
background: transparent;
|
|
212
|
+
}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
.body {
|
|
2
|
+
display: flex;
|
|
3
|
+
align-items: stretch;
|
|
4
|
+
padding: var(--content-padding-y) var(--content-padding-x);
|
|
5
|
+
}
|
|
6
|
+
.body > hr {
|
|
7
|
+
display: none;
|
|
8
|
+
}
|
|
9
|
+
@media (max-width: 840px) {
|
|
10
|
+
.body {
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
padding: 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
.body > nav {
|
|
16
|
+
width: 30%;
|
|
17
|
+
flex: none;
|
|
18
|
+
align-self: flex-start;
|
|
19
|
+
font-size: 0.9em;
|
|
20
|
+
background: var(--b1-light);
|
|
21
|
+
border-radius: var(--content-border-radius);
|
|
22
|
+
padding: 0.5rem var(--content-padding-x) 0.65rem;
|
|
23
|
+
margin: 0 0 0 var(--space-x);
|
|
24
|
+
box-sizing: border-box;
|
|
25
|
+
}
|
|
26
|
+
@media (max-width: 840px) {
|
|
27
|
+
.body > nav {
|
|
28
|
+
width: 100%;
|
|
29
|
+
font-size: inherit;
|
|
30
|
+
border-top: 0.35em solid var(--b1);
|
|
31
|
+
border-radius: 0;
|
|
32
|
+
padding: 0.25rem var(--content-padding-x) 0.35rem;
|
|
33
|
+
margin: 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
.body > nav section {
|
|
37
|
+
padding: 1rem 0;
|
|
38
|
+
}
|
|
39
|
+
.body > nav section + section {
|
|
40
|
+
border-top: 0.05rem solid var(--b1);
|
|
41
|
+
}
|
|
42
|
+
.body > nav section.related {
|
|
43
|
+
border-top: 0.15rem double var(--b1);
|
|
44
|
+
}
|
|
45
|
+
.body > nav h2,
|
|
46
|
+
.body > nav p.title {
|
|
47
|
+
font-size: 0.7rem;
|
|
48
|
+
font-weight: normal;
|
|
49
|
+
line-height: 1.2;
|
|
50
|
+
text-transform: uppercase;
|
|
51
|
+
color: color(from var(--c0) srgb r g b / 0.6);
|
|
52
|
+
margin: 1.1rem 0 0.75rem 0;
|
|
53
|
+
}
|
|
54
|
+
.body > nav h2:first-of-type,
|
|
55
|
+
.body > nav p.title:first-of-type {
|
|
56
|
+
margin-top: 0;
|
|
57
|
+
}
|
|
58
|
+
.body > nav ul {
|
|
59
|
+
line-height: 1.2;
|
|
60
|
+
padding: 0;
|
|
61
|
+
padding-inline-start: 1em;
|
|
62
|
+
margin: 0;
|
|
63
|
+
}
|
|
64
|
+
.body > nav > ul + ul {
|
|
65
|
+
border-top: 0.05rem solid var(--b1);
|
|
66
|
+
padding-top: 1.2em;
|
|
67
|
+
margin-top: 1.5em;
|
|
68
|
+
}
|
|
69
|
+
.body > nav ul ul {
|
|
70
|
+
margin: 0.65em 0 0.5em;
|
|
71
|
+
}
|
|
72
|
+
.body > nav li {
|
|
73
|
+
margin-top: 0;
|
|
74
|
+
margin-bottom: 0;
|
|
75
|
+
}
|
|
76
|
+
.body > nav li + li {
|
|
77
|
+
margin-top: 0.5em;
|
|
78
|
+
}
|
|
79
|
+
@media (max-width: 840px) {
|
|
80
|
+
.body > nav li + li {
|
|
81
|
+
margin-top: 0.65em;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
.body > nav > ul:last-child,
|
|
85
|
+
.body > nav > ul:last-child > li:last-child {
|
|
86
|
+
margin-bottom: 0;
|
|
87
|
+
}
|
|
88
|
+
.body > nav a.active {
|
|
89
|
+
font-weight: bold;
|
|
90
|
+
text-decoration: none;
|
|
91
|
+
color: inherit;
|
|
92
|
+
pointer-events: none;
|
|
93
|
+
}
|
|
94
|
+
.body > nav a.anchorjs-link {
|
|
95
|
+
display: none;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
main {
|
|
99
|
+
width: calc(70% - var(--space-x));
|
|
100
|
+
box-sizing: border-box;
|
|
101
|
+
}
|
|
102
|
+
@media (max-width: 840px) {
|
|
103
|
+
main {
|
|
104
|
+
width: 100%;
|
|
105
|
+
padding: var(--content-padding-y) var(--content-padding-x) 0;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
.body.no-nav {
|
|
109
|
+
--max-content-width: 45em;
|
|
110
|
+
}
|
|
111
|
+
.body.no-nav > main {
|
|
112
|
+
width: auto;
|
|
113
|
+
}
|
|
114
|
+
main p.sep {
|
|
115
|
+
font-size: 1.5em;
|
|
116
|
+
text-align: center;
|
|
117
|
+
margin: 0.5em 0;
|
|
118
|
+
}
|
|
119
|
+
main hr {
|
|
120
|
+
background: none transparent;
|
|
121
|
+
border: none;
|
|
122
|
+
border-top: 0.075em solid;
|
|
123
|
+
margin: var(--block-margin-y) 0;
|
|
124
|
+
}
|
|
125
|
+
main h1 {
|
|
126
|
+
font-size: 0.8rem;
|
|
127
|
+
font-weight: normal;
|
|
128
|
+
line-height: 1.1;
|
|
129
|
+
color: color(from var(--c0) srgb r g b / 0.5);
|
|
130
|
+
margin: 0;
|
|
131
|
+
}
|
|
132
|
+
h1 .sep {
|
|
133
|
+
margin: 0 0.1em;
|
|
134
|
+
}
|
|
135
|
+
@media (max-width: 840px) {
|
|
136
|
+
main h1 {
|
|
137
|
+
margin-top: 0;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
main h1 + h2 {
|
|
141
|
+
margin-top: 0.75rem;
|
|
142
|
+
}
|
|
143
|
+
main h2 {
|
|
144
|
+
border-bottom: var(--hr-border);
|
|
145
|
+
padding-bottom: 0.1em;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
.pagenav {
|
|
149
|
+
--icon-width: 1.25em;
|
|
150
|
+
|
|
151
|
+
display: flex;
|
|
152
|
+
justify-content: space-between;
|
|
153
|
+
gap: 1em;
|
|
154
|
+
background: var(--b1-light);
|
|
155
|
+
border-top: var(--hr-border);
|
|
156
|
+
padding: 0.6em 0.75em 0.75em;
|
|
157
|
+
margin: 1.5em 0 0;
|
|
158
|
+
}
|
|
159
|
+
@media (max-width: 840px) {
|
|
160
|
+
.pagenav {
|
|
161
|
+
padding: 1em var(--content-padding-x) 1.1em;
|
|
162
|
+
margin: 2em calc(-1 * var(--content-padding-x)) 0;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
.pagenav .prev,
|
|
166
|
+
.pagenav .next {
|
|
167
|
+
display: inline-block;
|
|
168
|
+
line-height: 1.2;
|
|
169
|
+
position: relative;
|
|
170
|
+
}
|
|
171
|
+
.pagenav .icon {
|
|
172
|
+
display: inline-block;
|
|
173
|
+
width: var(--icon-width);
|
|
174
|
+
box-sizing: border-box;
|
|
175
|
+
position: absolute;
|
|
176
|
+
top: 0;
|
|
177
|
+
}
|
|
178
|
+
.pagenav .prev {
|
|
179
|
+
text-align: left;
|
|
180
|
+
}
|
|
181
|
+
.pagenav .prev .icon {
|
|
182
|
+
left: 0;
|
|
183
|
+
}
|
|
184
|
+
.pagenav .next {
|
|
185
|
+
text-align: right;
|
|
186
|
+
}
|
|
187
|
+
.pagenav .next .icon {
|
|
188
|
+
right: 0;
|
|
189
|
+
}
|
|
190
|
+
.pagenav .prev {
|
|
191
|
+
padding-left: var(--icon-width);
|
|
192
|
+
}
|
|
193
|
+
.pagenav .next {
|
|
194
|
+
padding-right: var(--icon-width);
|
|
195
|
+
}
|
|
196
|
+
.pagenav .sep,
|
|
197
|
+
.pagenav .anchorjs-link,
|
|
198
|
+
.pagenav hr {
|
|
199
|
+
display: none;
|
|
200
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { Theme } from "./Theme";
|
|
2
|
+
|
|
3
|
+
export type EntryConfig = {
|
|
4
|
+
id?: string;
|
|
5
|
+
source?: string;
|
|
6
|
+
dir?: string;
|
|
7
|
+
colorScheme?: string;
|
|
8
|
+
theme?: Theme;
|
|
9
|
+
name?: string;
|
|
10
|
+
title?: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
version?: string;
|
|
13
|
+
repo?: string;
|
|
14
|
+
npm?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Target branch.
|
|
17
|
+
* @example "gh-pages"
|
|
18
|
+
*/
|
|
19
|
+
targetBranch?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @defaultValue "main"
|
|
22
|
+
*/
|
|
23
|
+
mainBranch?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Main page root path.
|
|
26
|
+
* @defaultValue "/"
|
|
27
|
+
*/
|
|
28
|
+
root?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Generated section content directory.
|
|
31
|
+
* @defaultValue "x"
|
|
32
|
+
*/
|
|
33
|
+
contentDir?: string;
|
|
34
|
+
/** Whether to show all sections on a single page. */
|
|
35
|
+
singlePage?: boolean;
|
|
36
|
+
/** Backstory link URL to be added to the front page. */
|
|
37
|
+
backstory?: string;
|
|
38
|
+
/** URL of an HTML file inserted into the navigation bar. */
|
|
39
|
+
nav?: string;
|
|
40
|
+
/** Scope URL */
|
|
41
|
+
scope?: string;
|
|
42
|
+
/** Redirection URL */
|
|
43
|
+
redirect?: string;
|
|
44
|
+
/** Whether to remove the GitHub Pages branch and quit. */
|
|
45
|
+
remove?: boolean;
|
|
46
|
+
/** Content of the './CNAME' file. */
|
|
47
|
+
cname?: string;
|
|
48
|
+
/**
|
|
49
|
+
* As a boolean, it means whether to add the
|
|
50
|
+
* '<package_name>.js.org' domain to the './CNAME' file.
|
|
51
|
+
*
|
|
52
|
+
* As a string, it sets the '<jsorg_value>.js.org' domain
|
|
53
|
+
* to the './CNAME' file.
|
|
54
|
+
*/
|
|
55
|
+
jsorg?: boolean | string;
|
|
56
|
+
ymid?: number | string;
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Theme = string | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
const htmlEntityMap: [string, string][] = [
|
|
2
|
+
["&", "&"],
|
|
3
|
+
["<", "<"],
|
|
4
|
+
[">", ">"],
|
|
5
|
+
['"', """],
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
export function escapeHTML(x: unknown): string {
|
|
9
|
+
let s = String(x);
|
|
10
|
+
|
|
11
|
+
if (!x) return "";
|
|
12
|
+
|
|
13
|
+
for (let [character, htmlEntity] of htmlEntityMap)
|
|
14
|
+
s = s.replaceAll(character, htmlEntity);
|
|
15
|
+
|
|
16
|
+
return s;
|
|
17
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function getIcon(baseColor = "gray") {
|
|
2
|
+
return `
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
|
4
|
+
<style>.b{fill:${baseColor};}.c0{fill:oklch(from ${baseColor} calc(100*(.78 - l)) 0 0 / .5);}.c1{fill:oklch(from ${baseColor} calc(100*(.78 - l)) 0 0 / .3);}.c2{fill:none;}</style>
|
|
5
|
+
<g stroke="none">
|
|
6
|
+
<path d="M0,15 L50,0 L100,15 L100,78 L50,100 L0,81z" stroke="none" class="b"/>
|
|
7
|
+
<path d="M0,15 L50,30 L100,15 L50,0z" stroke="none" class="c1"/>
|
|
8
|
+
<path d="M0,15 L50,30 L50,100 L0,81z" stroke="none" class="c0"/>
|
|
9
|
+
<path d="M50,30 L100,15 L100,78 L50,100z" stroke="none" class="c2"/>
|
|
10
|
+
</g>
|
|
11
|
+
</svg>
|
|
12
|
+
`
|
|
13
|
+
.trim()
|
|
14
|
+
.replace(/\s+/g, " ")
|
|
15
|
+
.replace(/> </g, "><");
|
|
16
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export function getSVGDataURL(svg: string) {
|
|
2
|
+
let base64SVG = "";
|
|
3
|
+
|
|
4
|
+
if (typeof window !== "undefined") base64SVG = window.btoa(svg);
|
|
5
|
+
else if (typeof Buffer !== "undefined")
|
|
6
|
+
base64SVG = Buffer.from(svg).toString("base64");
|
|
7
|
+
|
|
8
|
+
return `data:image/svg+xml;base64,${base64SVG}`;
|
|
9
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"include": ["src/**/*"],
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
|
5
|
+
"target": "ESNext",
|
|
6
|
+
"outDir": "dist",
|
|
7
|
+
"module": "nodenext",
|
|
8
|
+
"moduleResolution": "nodenext",
|
|
9
|
+
"strict": true,
|
|
10
|
+
"allowSyntheticDefaultImports": true,
|
|
11
|
+
"noUnusedLocals": true,
|
|
12
|
+
"noUnusedParameters": true
|
|
13
|
+
}
|
|
14
|
+
}
|