njk-tool 0.0.1
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/bundle/app.min.cjs +13410 -0
- package/dist/bundle/app.min.cjs.map +1 -0
- package/dist/bundle/app.min.js +13407 -0
- package/dist/bundle/app.min.js.map +1 -0
- package/dist/bundle/src/base.style +347 -0
- package/dist/bundle/src/index.html +262 -0
- package/package.json +57 -0
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
/* Components.css */
|
|
2
|
+
|
|
3
|
+
/* END-Components.css */
|
|
4
|
+
|
|
5
|
+
/* TOC.css */
|
|
6
|
+
/* 基础样式 */
|
|
7
|
+
.article-toc {
|
|
8
|
+
position: fixed;
|
|
9
|
+
top: 50px;
|
|
10
|
+
right: 2rem;
|
|
11
|
+
max-height: calc(100vh - 4rem);
|
|
12
|
+
margin-left: 2rem;
|
|
13
|
+
font-size: 0.95rem;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/* 隐藏 checkbox */
|
|
17
|
+
.toc-toggle-checkbox {
|
|
18
|
+
position: absolute;
|
|
19
|
+
opacity: 0;
|
|
20
|
+
height: 0;
|
|
21
|
+
width: 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/* 切换按钮样式 */
|
|
25
|
+
.toc-toggle-label {
|
|
26
|
+
display: flex;
|
|
27
|
+
align-items: center;
|
|
28
|
+
background: #f8f9fa;
|
|
29
|
+
padding: 0.3rem 0.6rem;
|
|
30
|
+
border-radius: 4px;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
margin-bottom: 0.5rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.toc-icon {
|
|
36
|
+
font-size: 1.2rem;
|
|
37
|
+
margin-right: 0.3rem;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* 目录导航 */
|
|
41
|
+
.toc-nav {
|
|
42
|
+
padding: 0.5rem;
|
|
43
|
+
background: white;
|
|
44
|
+
border-radius: 6px;
|
|
45
|
+
box-shadow: 0 1px 3px rgba(0,0,0,0.1);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.toc-section {
|
|
49
|
+
margin-bottom: 0.8rem;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.toc-heading {
|
|
53
|
+
font-size: 1rem;
|
|
54
|
+
margin: 0 0 0.4rem 0;
|
|
55
|
+
padding-bottom: 0.2rem;
|
|
56
|
+
border-bottom: 1px solid #eee;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.toc-list {
|
|
60
|
+
list-style: none;
|
|
61
|
+
padding-left: 0.4rem;
|
|
62
|
+
margin: 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.toc-item {
|
|
66
|
+
margin: 0.2rem 0;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.toc-link {
|
|
70
|
+
display: block;
|
|
71
|
+
padding: 0.2rem 0.4rem;
|
|
72
|
+
color: #495057;
|
|
73
|
+
text-decoration: none;
|
|
74
|
+
border-radius: 3px;
|
|
75
|
+
transition: all 0.2s;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.toc-link:hover {
|
|
79
|
+
background: #f0f0f0;
|
|
80
|
+
color: #007bff;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* 层级缩进 */
|
|
84
|
+
.toc-link[data-level="2"] {
|
|
85
|
+
padding-left: 0.8rem;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.toc-link[data-level="3"] {
|
|
89
|
+
padding-left: 1.6rem;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/* 激活状态 */
|
|
93
|
+
.toc-link.active {
|
|
94
|
+
background: #e7f5ff;
|
|
95
|
+
color: #0066cc;
|
|
96
|
+
font-weight: 500;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/* 折叠功能实现 */
|
|
100
|
+
.toc-toggle-checkbox:not(:checked) ~ .toc-nav {
|
|
101
|
+
display: none;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* 响应式设计 */
|
|
105
|
+
@media (max-width: 768px) {
|
|
106
|
+
.article-toc {
|
|
107
|
+
margin-left: 1rem;
|
|
108
|
+
font-size: 0.9rem;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/* END-TOC.css */
|
|
112
|
+
|
|
113
|
+
/* Text.css */
|
|
114
|
+
|
|
115
|
+
/* END-Text.css */
|
|
116
|
+
|
|
117
|
+
/* Title.css */
|
|
118
|
+
.title-base {
|
|
119
|
+
--align: left;
|
|
120
|
+
--text-color: black;
|
|
121
|
+
--font-weight: 800;
|
|
122
|
+
--font-size: 18px;
|
|
123
|
+
color: var(--text-color);
|
|
124
|
+
text-align: var(--align);
|
|
125
|
+
font-weight: var(--font-weight);
|
|
126
|
+
font-size: var(--font-size);
|
|
127
|
+
padding: 8px 30px;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
h1 {
|
|
131
|
+
--align: left;
|
|
132
|
+
--text-color: #606266;
|
|
133
|
+
--margin: 36px 0 20px;
|
|
134
|
+
position: relative;
|
|
135
|
+
font-size: 35.2px;
|
|
136
|
+
padding: 0 0 4.8px;
|
|
137
|
+
margin: var(--margin);
|
|
138
|
+
color: var(--text-color);
|
|
139
|
+
text-align: var(--align);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
h2 {
|
|
143
|
+
--align: left;
|
|
144
|
+
--text-color: #606266;
|
|
145
|
+
--margin: 36px 0 20px;
|
|
146
|
+
position: relative;
|
|
147
|
+
font-size: 26.4px;
|
|
148
|
+
padding: 0 0 4.8px;
|
|
149
|
+
margin: var(--margin);
|
|
150
|
+
color: var(--text-color);
|
|
151
|
+
text-align: var(--align);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
h2::before,
|
|
155
|
+
h1::before {
|
|
156
|
+
display: none;
|
|
157
|
+
position: absolute;
|
|
158
|
+
content: "#";
|
|
159
|
+
color: #007bff;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
h1::before {
|
|
163
|
+
left: -26px;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
h2::before {
|
|
167
|
+
left: -18px;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
h1:hover::before,
|
|
171
|
+
h2:hover::before {
|
|
172
|
+
display: inline-block;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
.title-main {
|
|
176
|
+
--align: left;
|
|
177
|
+
--text-color: black;
|
|
178
|
+
--font-weight: 800;
|
|
179
|
+
--font-size: 28px;
|
|
180
|
+
color: var(--text-color);
|
|
181
|
+
text-align: var(--align);
|
|
182
|
+
font-weight: var(--font-weight);
|
|
183
|
+
font-size: var(--font-size);
|
|
184
|
+
padding: 8px 30px;
|
|
185
|
+
margin-bottom: 20px;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/* END-Title.css */
|
|
189
|
+
|
|
190
|
+
/* Notice.css */
|
|
191
|
+
/* Notice */
|
|
192
|
+
.notice {
|
|
193
|
+
margin: 16px 0;
|
|
194
|
+
padding: 12px 16px;
|
|
195
|
+
margin-bottom: 1rem;
|
|
196
|
+
border-radius: 4px;
|
|
197
|
+
font-size: 14px;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.notice-title {
|
|
201
|
+
font-weight: bold;
|
|
202
|
+
margin-bottom: 4px;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
/* 不同类型的通知样式 */
|
|
206
|
+
.notice-info {
|
|
207
|
+
background-color: #e8f4ff;
|
|
208
|
+
border-left: 4px solid #1890ff;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
.notice-warning {
|
|
212
|
+
background-color: #fff7e6;
|
|
213
|
+
border-left: 4px solid #faad14;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.notice-success {
|
|
217
|
+
background-color: #f6ffed;
|
|
218
|
+
border-left: 4px solid #52c41a;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
.notice-error {
|
|
222
|
+
background-color: #fff2f0;
|
|
223
|
+
border-left: 4px solid #f5222d;
|
|
224
|
+
}
|
|
225
|
+
/* END-Notice.css */
|
|
226
|
+
|
|
227
|
+
/* Block.css */
|
|
228
|
+
/* Block.njk */
|
|
229
|
+
.code-block {
|
|
230
|
+
margin: 16px 0;
|
|
231
|
+
border-radius: 4px;
|
|
232
|
+
overflow: hidden;
|
|
233
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.code-block pre {
|
|
237
|
+
margin: 0;
|
|
238
|
+
padding: 1rem;
|
|
239
|
+
background-color: #f5f5f5;
|
|
240
|
+
font-family: 'Courier New', monospace;
|
|
241
|
+
font-size: 14px;
|
|
242
|
+
line-height: 1.5;
|
|
243
|
+
white-space: pre-wrap;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.code-block code {
|
|
247
|
+
display: block;
|
|
248
|
+
overflow-x: auto;
|
|
249
|
+
|
|
250
|
+
}
|
|
251
|
+
/* END-Block.css */
|
|
252
|
+
|
|
253
|
+
/* Table.css */
|
|
254
|
+
.default-table {
|
|
255
|
+
margin: 0;
|
|
256
|
+
width: 80%;
|
|
257
|
+
border-collapse: collapse;
|
|
258
|
+
/* 合并边框 */
|
|
259
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
260
|
+
font-size: 14px;
|
|
261
|
+
color: #444444;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.thead-light th {
|
|
265
|
+
background-color: #f5f7fa;
|
|
266
|
+
color: #333333;
|
|
267
|
+
font-weight: 600;
|
|
268
|
+
padding: 12px 16px;
|
|
269
|
+
text-align: left;
|
|
270
|
+
border: 1px solid #e1e4e8;
|
|
271
|
+
font-size: 16px;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.default-row {
|
|
275
|
+
border: 1px solid #eee;
|
|
276
|
+
background-color: #fff;
|
|
277
|
+
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
.default-row:hover {
|
|
281
|
+
background-color: #f0f4f8;
|
|
282
|
+
color: rebeccapurple;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.default-cell {
|
|
286
|
+
padding: 10px 16px;
|
|
287
|
+
border: 1px solid #e1e4e8;
|
|
288
|
+
font-weight: 400;
|
|
289
|
+
font-size: 14px;
|
|
290
|
+
color: #444;
|
|
291
|
+
background-color: transparent;
|
|
292
|
+
}
|
|
293
|
+
/* END-Table.css */
|
|
294
|
+
|
|
295
|
+
/* Tab.css */
|
|
296
|
+
/* Tab 容器 */
|
|
297
|
+
.tab-container {
|
|
298
|
+
max-width: 600px;
|
|
299
|
+
margin: 0 auto;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/* 隐藏 Radio 按钮 */
|
|
303
|
+
.tab-radio {
|
|
304
|
+
display: none;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/* Tab 按钮样式 */
|
|
308
|
+
.tab-labels {
|
|
309
|
+
display: flex;
|
|
310
|
+
border-bottom: 1px solid #ccc;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
.tab-label {
|
|
314
|
+
padding: 5px 10px;
|
|
315
|
+
cursor: pointer;
|
|
316
|
+
background-color: #f1f1f1;
|
|
317
|
+
border: 1px solid #ccc;
|
|
318
|
+
border-bottom: none;
|
|
319
|
+
margin-right: 2px;
|
|
320
|
+
border-radius: 5px 5px 0 0;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
.tab-label:hover {
|
|
324
|
+
background-color: #ddd;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
.tab-radio:checked+.tab-label {
|
|
328
|
+
background-color: #fff;
|
|
329
|
+
border-bottom: 1px solid #fff;
|
|
330
|
+
margin-bottom: -1px;
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/* Tab 内容区域 */
|
|
334
|
+
.tab-content {
|
|
335
|
+
display: none;
|
|
336
|
+
padding: 20px;
|
|
337
|
+
border: 1px solid #ccc;
|
|
338
|
+
border-top: none;
|
|
339
|
+
}
|
|
340
|
+
/* END-Tab.css */
|
|
341
|
+
|
|
342
|
+
/* Base.css */
|
|
343
|
+
body {
|
|
344
|
+
margin: 0;
|
|
345
|
+
padding: 50px;
|
|
346
|
+
}
|
|
347
|
+
/* END-Base.css */
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
<!-- Head.njk -->
|
|
2
|
+
{% macro use_head(ctx) %}
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<title>{{ ctx.title }}</title>
|
|
7
|
+
{% if ctx.jsFiles%}
|
|
8
|
+
{% for css in ctx.cssFiles %}
|
|
9
|
+
<link rel="stylesheet" href="{{ css }}" />
|
|
10
|
+
{% endfor %}
|
|
11
|
+
{% endif %}
|
|
12
|
+
</head>
|
|
13
|
+
{% if ctx.jsFiles%}
|
|
14
|
+
{% for js in ctx.jsFiles %}
|
|
15
|
+
<script src="{{ js }}"></script>
|
|
16
|
+
{% endfor %}
|
|
17
|
+
{% endif %}
|
|
18
|
+
{% endmacro %}
|
|
19
|
+
<!-- /Head.njk -->
|
|
20
|
+
|
|
21
|
+
<!-- TOC.njk -->
|
|
22
|
+
{% macro use_toc(ctx) %}
|
|
23
|
+
<div class="article-toc">
|
|
24
|
+
<input type="checkbox" id="toc-toggle" class="toc-toggle-checkbox">
|
|
25
|
+
<label for="toc-toggle" class="toc-toggle-label">
|
|
26
|
+
<span class="toc-icon">≡</span>
|
|
27
|
+
<span class="toc-text">目录</span>
|
|
28
|
+
</label>
|
|
29
|
+
|
|
30
|
+
<nav class="toc-nav">
|
|
31
|
+
{% for section in ctx.data %}
|
|
32
|
+
<section class="toc-section">
|
|
33
|
+
{% if section.link %}
|
|
34
|
+
<h3 class="toc-heading">
|
|
35
|
+
<a href="{{ section.link }}" class="toc-link">{{ section.text }}</a>
|
|
36
|
+
</h3>
|
|
37
|
+
{% else%}
|
|
38
|
+
<h3 class="toc-heading">{{ section.text }}</h3>
|
|
39
|
+
{% endif %}
|
|
40
|
+
<ul class="toc-list">
|
|
41
|
+
{% for item in section.items %}
|
|
42
|
+
<li class="toc-item">
|
|
43
|
+
<a href="{{ item.link }}" class="toc-link" data-level="{{ loop.depth }}">
|
|
44
|
+
{% if loop.depth > 1 %}•{% endif %}
|
|
45
|
+
{{ item.text }}
|
|
46
|
+
</a>
|
|
47
|
+
</li>
|
|
48
|
+
{% endfor %}
|
|
49
|
+
</ul>
|
|
50
|
+
</section>
|
|
51
|
+
{% endfor %}
|
|
52
|
+
</nav>
|
|
53
|
+
</div>
|
|
54
|
+
{% endmacro %}
|
|
55
|
+
<!-- /TOC.njk -->
|
|
56
|
+
|
|
57
|
+
<!-- Title.njk -->
|
|
58
|
+
{% macro title_default(ctx) %}
|
|
59
|
+
<h1 style="text-align: center">{{ ctx.text }}</h1>
|
|
60
|
+
{% endmacro %}
|
|
61
|
+
{% macro title_h1(ctx) %}
|
|
62
|
+
<h1 id="{{ ctx.text }}" class="title-color" style="{{ ctx.style }}">
|
|
63
|
+
{{ ctx.text }}
|
|
64
|
+
</h1>
|
|
65
|
+
{% endmacro %}
|
|
66
|
+
{% macro title_h2(ctx) %}
|
|
67
|
+
<h2 id="{{ ctx.text }}" class="title-color" style="{{ ctx.style }}">
|
|
68
|
+
{{ ctx.text }}
|
|
69
|
+
</h2>
|
|
70
|
+
{% endmacro %}
|
|
71
|
+
{% macro title_h3(ctx) %}
|
|
72
|
+
<h3 id="{{ ctx.text }}" class="title-color" style="{{ ctx.style }}">
|
|
73
|
+
{{ ctx.text }}
|
|
74
|
+
</h3>
|
|
75
|
+
{% endmacro %}
|
|
76
|
+
{% macro title_table_default(ctx) %}
|
|
77
|
+
<h3 id="{{ ctx.text }}" class="title_table_default" style="{{ ctx.style }}">
|
|
78
|
+
{{ ctx.text }}
|
|
79
|
+
</h3>
|
|
80
|
+
{% endmacro %}
|
|
81
|
+
{% macro use_title(ctx) %}
|
|
82
|
+
{% if ctx.type == "h1" %}
|
|
83
|
+
{{ title_h1(ctx) }}
|
|
84
|
+
{% elif ctx.type == "h2" %}
|
|
85
|
+
{{ title_h2(ctx) }}
|
|
86
|
+
{% elif ctx.type == "h3" %}
|
|
87
|
+
{{ title_h3(ctx) }}
|
|
88
|
+
{% else %}
|
|
89
|
+
{{ title_default(ctx) }}
|
|
90
|
+
{% endif %}
|
|
91
|
+
{% endmacro %}
|
|
92
|
+
<!-- /Title.njk -->
|
|
93
|
+
|
|
94
|
+
<!-- Notice.njk -->
|
|
95
|
+
{% macro use_notice(ctx) %}
|
|
96
|
+
{% if ctx.type %}
|
|
97
|
+
{% set type = ctx.type %}
|
|
98
|
+
{% else %}
|
|
99
|
+
{% set type = "info" %}
|
|
100
|
+
{% endif %}
|
|
101
|
+
<div class="notice notice-{{ type }}">
|
|
102
|
+
<div class="notice-title">{{ type|capitalize }}:</div>
|
|
103
|
+
<pre class="notice-content">{{ ctx.text }}</pre>
|
|
104
|
+
</div>
|
|
105
|
+
{% endmacro %}
|
|
106
|
+
<!-- /Notice.njk -->
|
|
107
|
+
|
|
108
|
+
<!-- Block.njk -->
|
|
109
|
+
{% macro use_block(ctx) %}
|
|
110
|
+
<div class="code-block">
|
|
111
|
+
<pre><code>{{ ctx.text }}</code></pre>
|
|
112
|
+
</div>
|
|
113
|
+
{% endmacro %}
|
|
114
|
+
<!-- /Block.njk -->
|
|
115
|
+
|
|
116
|
+
<!-- Date.njk -->
|
|
117
|
+
{% macro use_date(ctx) %}
|
|
118
|
+
<div>Date:{{ ctx.text}}</div>
|
|
119
|
+
{% endmacro %}
|
|
120
|
+
{% macro use_checker(ctx) %}
|
|
121
|
+
<div>Checker:{{ ctx.text}}</div>
|
|
122
|
+
{% endmacro %}
|
|
123
|
+
<!-- /Date.njk -->
|
|
124
|
+
|
|
125
|
+
<!-- Table.njk -->
|
|
126
|
+
{% macro table_default(ctx) %}
|
|
127
|
+
{% if ctx.columns %}
|
|
128
|
+
{% set columns = ctx.columns %}
|
|
129
|
+
{% elif ctx.th %}
|
|
130
|
+
{% set columns = ctx.th %}
|
|
131
|
+
{% else %}
|
|
132
|
+
{% set columns = [] %}
|
|
133
|
+
{% endif %}
|
|
134
|
+
{% if ctx.data %}
|
|
135
|
+
{% set data = ctx.data %}
|
|
136
|
+
{% elif ctx.tbody %}
|
|
137
|
+
{% set data = ctx.tbody %}
|
|
138
|
+
{% endif %}
|
|
139
|
+
{% if ctx.title %}
|
|
140
|
+
{% set title = {text:ctx.title} %}
|
|
141
|
+
{{ title_h2(title) }}
|
|
142
|
+
{% endif %}
|
|
143
|
+
<table class="default-table">
|
|
144
|
+
<thead class="thead-light">
|
|
145
|
+
<tr>
|
|
146
|
+
{% for column in columns %}
|
|
147
|
+
<th>{{ column }}</th>
|
|
148
|
+
{% endfor %}
|
|
149
|
+
</tr>
|
|
150
|
+
</thead>
|
|
151
|
+
<tbody>
|
|
152
|
+
{% for row in data %}
|
|
153
|
+
<tr class="default-row">
|
|
154
|
+
{% if ctx.data %}
|
|
155
|
+
{% for column in columns %}
|
|
156
|
+
<td class="default-cell">{{ row[column] | replace("false", "❌") | replace("true", "✔️") }}</td>
|
|
157
|
+
{% endfor %}
|
|
158
|
+
{% else %}
|
|
159
|
+
{% for value in row %}
|
|
160
|
+
<td class="default-cell">{{ value | replace("false", "❌") | replace("true", "✔️") }}</td>
|
|
161
|
+
{% endfor %}
|
|
162
|
+
{% endif %}
|
|
163
|
+
</tr>
|
|
164
|
+
{% endfor %}
|
|
165
|
+
</tbody>
|
|
166
|
+
</table>
|
|
167
|
+
{% endmacro %}
|
|
168
|
+
{% macro use_table(ctx) %}
|
|
169
|
+
{% if ctx.type == "h1" %}
|
|
170
|
+
{{ title_h1(ctx) }}
|
|
171
|
+
{% else %}
|
|
172
|
+
{{ table_default(ctx) }}
|
|
173
|
+
{% endif %}
|
|
174
|
+
{% endmacro %}
|
|
175
|
+
<!-- /Table.njk -->
|
|
176
|
+
|
|
177
|
+
<!-- Tab.njk -->
|
|
178
|
+
{% macro useTab(tabs) %}
|
|
179
|
+
<style>
|
|
180
|
+
/* 显示选中的 Tab 内容 */
|
|
181
|
+
{% for tab in tabs %}
|
|
182
|
+
#{{tab.id}}:checked~#{{tab.content_id}} {
|
|
183
|
+
display: block;
|
|
184
|
+
}
|
|
185
|
+
{% endfor %}
|
|
186
|
+
</style>
|
|
187
|
+
<div class="tab-container">
|
|
188
|
+
{% for tab in tabs %}
|
|
189
|
+
<!-- Radio 按钮(隐藏) -->
|
|
190
|
+
<input {% if loop.first %} checked {% endif %} type="radio" name="tabs" id="{{ tab.id }}" class="tab-radio">
|
|
191
|
+
{% endfor %}
|
|
192
|
+
<!-- Tab 按钮(用 label 包裹) -->
|
|
193
|
+
<div class="tab-labels">
|
|
194
|
+
{% for tab in tabs %}
|
|
195
|
+
<label for="{{ tab.id }}" class="tab-label">{{ tab.title }}
|
|
196
|
+
</label>
|
|
197
|
+
{% endfor %}
|
|
198
|
+
</div>
|
|
199
|
+
<!-- Tab 内容 -->
|
|
200
|
+
{% for tab in tabs %}
|
|
201
|
+
<div id="{{ tab.content_id }}" class="tab-content">
|
|
202
|
+
{{ tab.content }}
|
|
203
|
+
</div>
|
|
204
|
+
{% endfor %}
|
|
205
|
+
</div>
|
|
206
|
+
{% endmacro %}
|
|
207
|
+
<!-- /Tab.njk -->
|
|
208
|
+
|
|
209
|
+
<!-- Component.njk -->
|
|
210
|
+
{% macro pick_component(ctx) %}
|
|
211
|
+
{% if ctx.tag == "head" %}
|
|
212
|
+
{{ use_head(ctx) }}
|
|
213
|
+
{% elif ctx.tag == "text" %}
|
|
214
|
+
{{ use_text(ctx) }}
|
|
215
|
+
{% elif ctx.tag == "title" %}
|
|
216
|
+
{{ use_title(ctx) }}
|
|
217
|
+
{% elif ctx.tag == "table" %}
|
|
218
|
+
{{ use_table(ctx) }}
|
|
219
|
+
{% elif ctx.tag == "toc" %}
|
|
220
|
+
{{ use_toc(ctx) }}
|
|
221
|
+
{% elif ctx.tag == "notice" %}
|
|
222
|
+
{{ use_notice(ctx) }}
|
|
223
|
+
{% elif ctx.tag == "block" %}
|
|
224
|
+
{{ use_block(ctx) }}
|
|
225
|
+
{% elif ctx.tag == "date" %}
|
|
226
|
+
{{ use_date(ctx) }}
|
|
227
|
+
{% elif ctx.tag == "checker" %}
|
|
228
|
+
{{ use_checker(ctx) }}
|
|
229
|
+
{% else %}
|
|
230
|
+
{{ title_default(ctx) }}
|
|
231
|
+
{% endif %}
|
|
232
|
+
{% endmacro %}
|
|
233
|
+
{% macro use_component(ctx) %}
|
|
234
|
+
{% if ctx.tag %}
|
|
235
|
+
{{ pick_component(ctx) }}
|
|
236
|
+
{% else %}
|
|
237
|
+
{% for i in ctx %}
|
|
238
|
+
{{ pick_component(i) }}
|
|
239
|
+
{% endfor %}
|
|
240
|
+
{% endif %}
|
|
241
|
+
{% endmacro %}
|
|
242
|
+
|
|
243
|
+
{{ use_component(ctx) }}
|
|
244
|
+
<!-- /Component.njk -->
|
|
245
|
+
|
|
246
|
+
<!-- Text.njk -->
|
|
247
|
+
{% macro text_default(ctx) %}
|
|
248
|
+
{{ ctx.text | replace("false", "❌") | replace("true", "✔️") }}
|
|
249
|
+
{% endmacro %}
|
|
250
|
+
|
|
251
|
+
{% macro bool_text(ctx) %}
|
|
252
|
+
{{ ctx.text | replace("false", "❌") | replace("true", "✔️") }}
|
|
253
|
+
{% endmacro %}
|
|
254
|
+
|
|
255
|
+
{% macro use_text(ctx) %}
|
|
256
|
+
{% if ctx.type == "h1" %}
|
|
257
|
+
{{ title_h1(ctx) }}
|
|
258
|
+
{% else %}
|
|
259
|
+
{{ text_default(ctx) }}
|
|
260
|
+
{% endif %}
|
|
261
|
+
{% endmacro %}
|
|
262
|
+
<!-- /Text.njk -->
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "njk-tool",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "nunjucks no JavaScript 模板工具,兼容jinja",
|
|
5
|
+
"main": "dist/bundle/app.min.cjs",
|
|
6
|
+
"module": "dist/bundle/app.min.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/bundle/app.min.cjs",
|
|
10
|
+
"import": "./dist/bundle/app.min.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
13
|
+
"author": "zggong",
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/SHgzg/njk-tool.git"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"peerDependencies": {
|
|
21
|
+
"nunjucks": "^3.2.4"
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist/bundle",
|
|
25
|
+
"LICENSE",
|
|
26
|
+
"README.md"
|
|
27
|
+
],
|
|
28
|
+
"scripts": {
|
|
29
|
+
"build": "rollup -c",
|
|
30
|
+
"prestart": "node ./build.js",
|
|
31
|
+
"dev": "npx tsc && node ./dist/dev/main.js"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"nunjucks",
|
|
35
|
+
"template"
|
|
36
|
+
],
|
|
37
|
+
"packageManager": "pnpm@10.9.0",
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"chokidar": "3.6.0",
|
|
40
|
+
"dotenv": "^16.5.0",
|
|
41
|
+
"express": "^5.1.0",
|
|
42
|
+
"nunjucks": "^3.2.4"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
46
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
47
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
48
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
49
|
+
"@types/express": "^5.0.2",
|
|
50
|
+
"@types/node": "^22.15.30",
|
|
51
|
+
"@types/nunjucks": "^3.2.6",
|
|
52
|
+
"rollup": "^4.45.1",
|
|
53
|
+
"rollup-plugin-copy": "^3.5.0",
|
|
54
|
+
"tslib": "^2.8.1",
|
|
55
|
+
"typescript": "^5.8.3"
|
|
56
|
+
}
|
|
57
|
+
}
|