njk-tool 0.0.12 → 0.0.13

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.
@@ -7,7 +7,6 @@ var require$$0$3 = require('path');
7
7
  var require$$2 = require('util');
8
8
  var require$$1 = require('stream');
9
9
  var require$$2$1 = require('os');
10
- var node_path = require('node:path');
11
10
  var node_url = require('node:url');
12
11
 
13
12
  var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
@@ -13298,622 +13297,783 @@ var TagType;
13298
13297
  TagType["Table"] = "table";
13299
13298
  })(TagType || (TagType = {}));
13300
13299
 
13301
- const styleText = `
13302
- <style>
13303
- /* Components.css */
13304
-
13305
- /* END-Components.css */
13306
-
13307
- /* TOC.css */
13308
- /* 基础样式 */
13309
- .article-toc {
13310
- position: fixed;
13311
- top: 50px;
13312
- right: 2rem;
13313
- max-height: calc(100vh - 4rem);
13314
- margin-left: 2rem;
13315
- font-size: 0.95rem;
13316
- }
13317
-
13318
- /* 隐藏 checkbox */
13319
- .toc-toggle-checkbox {
13320
- position: absolute;
13321
- opacity: 0;
13322
- height: 0;
13323
- width: 0;
13324
- }
13325
-
13326
- /* 切换按钮样式 */
13327
- .toc-toggle-label {
13328
- display: flex;
13329
- align-items: center;
13330
- background: #f8f9fa;
13331
- padding: 0.3rem 0.6rem;
13332
- border-radius: 4px;
13333
- cursor: pointer;
13334
- margin-bottom: 0.5rem;
13335
- }
13336
-
13337
- .toc-icon {
13338
- font-size: 1.2rem;
13339
- margin-right: 0.3rem;
13340
- }
13341
-
13342
- /* 目录导航 */
13343
- .toc-nav {
13344
- padding: 0.5rem;
13345
- background: white;
13346
- border-radius: 6px;
13347
- box-shadow: 0 1px 3px rgba(0,0,0,0.1);
13348
- }
13349
-
13350
- .toc-section {
13351
- margin-bottom: 0.8rem;
13352
- }
13353
-
13354
- .toc-heading {
13355
- font-size: 1rem;
13356
- margin: 0 0 0.4rem 0;
13357
- padding-bottom: 0.2rem;
13358
- border-bottom: 1px solid #eee;
13359
- }
13360
-
13361
- .toc-list {
13362
- list-style: none;
13363
- padding-left: 0.4rem;
13364
- margin: 0;
13365
- }
13366
-
13367
- .toc-item {
13368
- margin: 0.2rem 0;
13369
- }
13370
-
13371
- .toc-link {
13372
- display: block;
13373
- padding: 0.2rem 0.4rem;
13374
- color: #495057;
13375
- text-decoration: none;
13376
- border-radius: 3px;
13377
- transition: all 0.2s;
13378
- }
13379
-
13380
- .toc-link:hover {
13381
- background: #f0f0f0;
13382
- color: #007bff;
13383
- }
13384
-
13385
- /* 层级缩进 */
13386
- .toc-link[data-level="2"] {
13387
- padding-left: 0.8rem;
13388
- }
13389
-
13390
- .toc-link[data-level="3"] {
13391
- padding-left: 1.6rem;
13392
- }
13393
-
13394
- /* 激活状态 */
13395
- .toc-link.active {
13396
- background: #e7f5ff;
13397
- color: #0066cc;
13398
- font-weight: 500;
13399
- }
13400
-
13401
- /* 折叠功能实现 */
13402
- .toc-toggle-checkbox:not(:checked) ~ .toc-nav {
13403
- display: none;
13404
- }
13405
-
13406
- /* 响应式设计 */
13407
- @media (max-width: 768px) {
13408
- .article-toc {
13409
- margin-left: 1rem;
13410
- font-size: 0.9rem;
13411
- }
13412
- }
13413
- /* END-TOC.css */
13414
-
13415
- /* Text.css */
13416
-
13417
- /* END-Text.css */
13418
-
13419
- /* Title.css */
13420
- .title-base {
13421
- --align: left;
13422
- --text-color: black;
13423
- --font-weight: 800;
13424
- --font-size: 18px;
13425
- color: var(--text-color);
13426
- text-align: var(--align);
13427
- font-weight: var(--font-weight);
13428
- font-size: var(--font-size);
13429
- padding: 8px 30px;
13430
- }
13431
-
13432
- h1 {
13433
- --align: left;
13434
- --text-color: #606266;
13435
- --margin: 36px 0 20px;
13436
- position: relative;
13437
- font-size: 35.2px;
13438
- padding: 0 0 4.8px;
13439
- margin: var(--margin);
13440
- color: var(--text-color);
13441
- text-align: var(--align);
13442
- }
13443
-
13444
- h2 {
13445
- --align: left;
13446
- --text-color: #606266;
13447
- --margin: 36px 0 20px;
13448
- position: relative;
13449
- font-size: 26.4px;
13450
- padding: 0 0 4.8px;
13451
- margin: var(--margin);
13452
- color: var(--text-color);
13453
- text-align: var(--align);
13454
- }
13455
-
13456
- h2::before,
13457
- h1::before {
13458
- display: none;
13459
- position: absolute;
13460
- content: "#";
13461
- color: #007bff;
13462
- }
13463
-
13464
- h1::before {
13465
- left: -26px;
13466
- }
13467
-
13468
- h2::before {
13469
- left: -18px;
13470
- }
13471
-
13472
- h1:hover::before,
13473
- h2:hover::before {
13474
- display: inline-block;
13475
- }
13476
-
13477
- .title-main {
13478
- --align: left;
13479
- --text-color: black;
13480
- --font-weight: 800;
13481
- --font-size: 28px;
13482
- color: var(--text-color);
13483
- text-align: var(--align);
13484
- font-weight: var(--font-weight);
13485
- font-size: var(--font-size);
13486
- padding: 8px 30px;
13487
- margin-bottom: 20px;
13488
- }
13489
-
13490
- /* END-Title.css */
13491
-
13492
- /* Notice.css */
13493
- /* Notice */
13494
- .notice {
13495
- margin: 16px 0;
13496
- padding: 12px 16px;
13497
- margin-bottom: 1rem;
13498
- border-radius: 4px;
13499
- font-size: 14px;
13500
- }
13501
-
13502
- .notice-title {
13503
- font-weight: bold;
13504
- margin-bottom: 4px;
13505
- }
13506
-
13507
- /* 不同类型的通知样式 */
13508
- .notice-info {
13509
- background-color: #e8f4ff;
13510
- border-left: 4px solid #1890ff;
13511
- }
13512
-
13513
- .notice-warning {
13514
- background-color: #fff7e6;
13515
- border-left: 4px solid #faad14;
13516
- }
13517
-
13518
- .notice-success {
13519
- background-color: #f6ffed;
13520
- border-left: 4px solid #52c41a;
13521
- }
13522
-
13523
- .notice-error {
13524
- background-color: #fff2f0;
13525
- border-left: 4px solid #f5222d;
13526
- }
13527
- /* END-Notice.css */
13528
-
13529
- /* Block.css */
13530
- /* Block.njk */
13531
- .code-block {
13532
- margin: 16px 0;
13533
- border-radius: 4px;
13534
- overflow: hidden;
13535
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
13536
- }
13537
-
13538
- .code-block pre {
13539
- margin: 0;
13540
- padding: 1rem;
13541
- background-color: #f5f5f5;
13542
- font-family: 'Courier New', monospace;
13543
- font-size: 14px;
13544
- line-height: 1.5;
13545
- white-space: pre-wrap;
13546
- }
13547
-
13548
- .code-block code {
13549
- display: block;
13550
- overflow-x: auto;
13551
-
13552
- }
13553
- /* END-Block.css */
13554
-
13555
- /* Table.css */
13556
- .default-table {
13557
- margin: 0;
13558
- width: 80%;
13559
- border-collapse: collapse;
13560
- /* 合并边框 */
13561
- font-family: Arial, Helvetica, sans-serif;
13562
- font-size: 14px;
13563
- color: #444444;
13564
- }
13565
-
13566
- .thead-light th {
13567
- background-color: #f5f7fa;
13568
- color: #333333;
13569
- font-weight: 600;
13570
- padding: 12px 16px;
13571
- text-align: left;
13572
- border: 1px solid #e1e4e8;
13573
- font-size: 16px;
13574
- }
13575
-
13576
- .default-row {
13577
- border: 1px solid #eee;
13578
- background-color: #fff;
13579
-
13580
- }
13581
-
13582
- .default-row:hover {
13583
- background-color: #f0f4f8;
13584
- color: rebeccapurple;
13585
- }
13586
-
13587
- .default-cell {
13588
- padding: 10px 16px;
13589
- border: 1px solid #e1e4e8;
13590
- font-weight: 400;
13591
- font-size: 14px;
13592
- color: #444;
13593
- background-color: transparent;
13594
- }
13595
- /* END-Table.css */
13596
-
13597
- /* Tab.css */
13598
- /* Tab 容器 */
13599
- .tab-container {
13600
- max-width: 600px;
13601
- margin: 0 auto;
13602
- }
13603
-
13604
- /* 隐藏 Radio 按钮 */
13605
- .tab-radio {
13606
- display: none;
13607
- }
13608
-
13609
- /* Tab 按钮样式 */
13610
- .tab-labels {
13611
- display: flex;
13612
- border-bottom: 1px solid #ccc;
13613
- }
13614
-
13615
- .tab-label {
13616
- padding: 5px 10px;
13617
- cursor: pointer;
13618
- background-color: #f1f1f1;
13619
- border: 1px solid #ccc;
13620
- border-bottom: none;
13621
- margin-right: 2px;
13622
- border-radius: 5px 5px 0 0;
13623
- }
13624
-
13625
- .tab-label:hover {
13626
- background-color: #ddd;
13627
- }
13628
-
13629
- .tab-radio:checked+.tab-label {
13630
- background-color: #fff;
13631
- border-bottom: 1px solid #fff;
13632
- margin-bottom: -1px;
13633
- }
13634
-
13635
- /* Tab 内容区域 */
13636
- .tab-content {
13637
- display: none;
13638
- padding: 20px;
13639
- border: 1px solid #ccc;
13640
- border-top: none;
13641
- }
13642
- /* END-Tab.css */
13643
-
13644
- /* Base.css */
13645
- body {
13646
- margin: 0;
13647
- padding: 50px;
13648
- }
13649
- /* END-Base.css */
13650
- </style>
13651
- `;
13652
-
13653
- const templateText = `
13654
- <!-- Head.njk -->
13655
- {% macro use_head(ctx) %}
13656
- <head>
13657
- <meta charset="UTF-8" />
13658
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
13659
- <title>{{ ctx.title }}</title>
13660
- {% if ctx.jsFiles%}
13661
- {% for css in ctx.cssFiles %}
13662
- <link rel="stylesheet" href="{{ css }}" />
13663
- {% endfor %}
13664
- {% endif %}
13665
- </head>
13666
- {% if ctx.jsFiles%}
13667
- {% for js in ctx.jsFiles %}
13668
- <script src="{{ js }}"></script>
13669
- {% endfor %}
13670
- {% endif %}
13671
- {% endmacro %}
13672
- <!-- /Head.njk -->
13673
-
13674
- <!-- TOC.njk -->
13675
- {% macro use_toc(ctx) %}
13676
- <div class="article-toc">
13677
- <input type="checkbox" id="toc-toggle" class="toc-toggle-checkbox">
13678
- <label for="toc-toggle" class="toc-toggle-label">
13679
- <span class="toc-icon">≡</span>
13680
- <span class="toc-text">目录</span>
13681
- </label>
13682
-
13683
- <nav class="toc-nav">
13684
- {% for section in ctx.data %}
13685
- <section class="toc-section">
13686
- {% if section.link %}
13687
- <h3 class="toc-heading">
13688
- <a href="{{ section.link }}" class="toc-link">{{ section.text }}</a>
13689
- </h3>
13690
- {% else%}
13691
- <h3 class="toc-heading">{{ section.text }}</h3>
13692
- {% endif %}
13693
- <ul class="toc-list">
13694
- {% for item in section.items %}
13695
- <li class="toc-item">
13696
- <a href="{{ item.link }}" class="toc-link" data-level="{{ loop.depth }}">
13697
- {% if loop.depth > 1 %}•{% endif %}
13698
- {{ item.text }}
13699
- </a>
13700
- </li>
13701
- {% endfor %}
13702
- </ul>
13703
- </section>
13704
- {% endfor %}
13705
- </nav>
13706
- </div>
13707
- {% endmacro %}
13708
- <!-- /TOC.njk -->
13709
-
13710
- <!-- Title.njk -->
13711
- {% macro title_default(ctx) %}
13712
- <h1 style="text-align: center">{{ ctx.text }}</h1>
13713
- {% endmacro %}
13714
- {% macro title_h1(ctx) %}
13715
- <h1 id="{{ ctx.text }}" class="title-color" style="{{ ctx.style }}">
13716
- {{ ctx.text }}
13717
- </h1>
13718
- {% endmacro %}
13719
- {% macro title_h2(ctx) %}
13720
- <h2 id="{{ ctx.text }}" class="title-color" style="{{ ctx.style }}">
13721
- {{ ctx.text }}
13722
- </h2>
13723
- {% endmacro %}
13724
- {% macro title_h3(ctx) %}
13725
- <h3 id="{{ ctx.text }}" class="title-color" style="{{ ctx.style }}">
13726
- {{ ctx.text }}
13727
- </h3>
13728
- {% endmacro %}
13729
- {% macro title_table_default(ctx) %}
13730
- <h3 id="{{ ctx.text }}" class="title_table_default" style="{{ ctx.style }}">
13731
- {{ ctx.text }}
13732
- </h3>
13733
- {% endmacro %}
13734
- {% macro use_title(ctx) %}
13735
- {% if ctx.type == "h1" %}
13736
- {{ title_h1(ctx) }}
13737
- {% elif ctx.type == "h2" %}
13738
- {{ title_h2(ctx) }}
13739
- {% elif ctx.type == "h3" %}
13740
- {{ title_h3(ctx) }}
13741
- {% else %}
13742
- {{ title_default(ctx) }}
13743
- {% endif %}
13744
- {% endmacro %}
13745
- <!-- /Title.njk -->
13746
-
13747
- <!-- Notice.njk -->
13748
- {% macro use_notice(ctx) %}
13749
- {% if ctx.type %}
13750
- {% set type = ctx.type %}
13751
- {% else %}
13752
- {% set type = "info" %}
13753
- {% endif %}
13754
- <div class="notice notice-{{ type }}">
13755
- <div class="notice-title">{{ type|capitalize }}:</div>
13756
- <pre class="notice-content">{{ ctx.text }}</pre>
13757
- </div>
13758
- {% endmacro %}
13759
- <!-- /Notice.njk -->
13760
-
13761
- <!-- Block.njk -->
13762
- {% macro use_block(ctx) %}
13763
- <div class="code-block">
13764
- <pre><code>{{ ctx.text }}</code></pre>
13765
- </div>
13766
- {% endmacro %}
13767
- <!-- /Block.njk -->
13768
-
13769
- <!-- Date.njk -->
13770
- {% macro use_date(ctx) %}
13771
- <div>Date:{{ ctx.text}}</div>
13772
- {% endmacro %}
13773
- {% macro use_checker(ctx) %}
13774
- <div>Checker:{{ ctx.text}}</div>
13775
- {% endmacro %}
13776
- <!-- /Date.njk -->
13777
-
13778
- <!-- Table.njk -->
13779
- {% macro table_default(ctx) %}
13780
- {% if ctx.columns %}
13781
- {% set columns = ctx.columns %}
13782
- {% elif ctx.th %}
13783
- {% set columns = ctx.th %}
13784
- {% else %}
13785
- {% set columns = [] %}
13786
- {% endif %}
13787
- {% if ctx.data %}
13788
- {% set data = ctx.data %}
13789
- {% elif ctx.tbody %}
13790
- {% set data = ctx.tbody %}
13791
- {% endif %}
13792
- {% if ctx.title %}
13793
- {% set title = {text:ctx.title} %}
13794
- {{ title_h2(title) }}
13795
- {% endif %}
13796
- <table class="default-table">
13797
- <thead class="thead-light">
13798
- <tr>
13799
- {% for column in columns %}
13800
- <th>{{ column }}</th>
13801
- {% endfor %}
13802
- </tr>
13803
- </thead>
13804
- <tbody>
13805
- {% for row in data %}
13806
- <tr class="default-row">
13807
- {% if ctx.data %}
13808
- {% for column in columns %}
13809
- <td class="default-cell">{{ row[column] | replace("false", "❌") | replace("true", "✔️") }}</td>
13810
- {% endfor %}
13811
- {% else %}
13812
- {% for value in row %}
13813
- <td class="default-cell">{{ value | replace("false", "❌") | replace("true", "✔️") }}</td>
13814
- {% endfor %}
13815
- {% endif %}
13816
- </tr>
13817
- {% endfor %}
13818
- </tbody>
13819
- </table>
13820
- {% endmacro %}
13821
- {% macro use_table(ctx) %}
13822
- {% if ctx.type == "h1" %}
13823
- {{ title_h1(ctx) }}
13824
- {% else %}
13825
- {{ table_default(ctx) }}
13826
- {% endif %}
13827
- {% endmacro %}
13828
- <!-- /Table.njk -->
13829
-
13830
- <!-- Tab.njk -->
13831
- {% macro useTab(tabs) %}
13832
- <style>
13833
- /* 显示选中的 Tab 内容 */
13834
- {% for tab in tabs %}
13835
- #{{tab.id}}:checked~#{{tab.content_id}} {
13836
- display: block;
13837
- }
13838
- {% endfor %}
13839
- </style>
13840
- <div class="tab-container">
13841
- {% for tab in tabs %}
13842
- <!-- Radio 按钮(隐藏) -->
13843
- <input {% if loop.first %} checked {% endif %} type="radio" name="tabs" id="{{ tab.id }}" class="tab-radio">
13844
- {% endfor %}
13845
- <!-- Tab 按钮(用 label 包裹) -->
13846
- <div class="tab-labels">
13847
- {% for tab in tabs %}
13848
- <label for="{{ tab.id }}" class="tab-label">{{ tab.title }}
13849
- </label>
13850
- {% endfor %}
13851
- </div>
13852
- <!-- Tab 内容 -->
13853
- {% for tab in tabs %}
13854
- <div id="{{ tab.content_id }}" class="tab-content">
13855
- {{ tab.content }}
13856
- </div>
13857
- {% endfor %}
13858
- </div>
13859
- {% endmacro %}
13860
- <!-- /Tab.njk -->
13861
-
13862
- <!-- Component.njk -->
13863
- {% macro pick_component(ctx) %}
13864
- {% if ctx.tag == "head" %}
13865
- {{ use_head(ctx) }}
13866
- {% elif ctx.tag == "text" %}
13867
- {{ use_text(ctx) }}
13868
- {% elif ctx.tag == "title" %}
13869
- {{ use_title(ctx) }}
13870
- {% elif ctx.tag == "table" %}
13871
- {{ use_table(ctx) }}
13872
- {% elif ctx.tag == "toc" %}
13873
- {{ use_toc(ctx) }}
13874
- {% elif ctx.tag == "notice" %}
13875
- {{ use_notice(ctx) }}
13876
- {% elif ctx.tag == "block" %}
13877
- {{ use_block(ctx) }}
13878
- {% elif ctx.tag == "date" %}
13879
- {{ use_date(ctx) }}
13880
- {% elif ctx.tag == "checker" %}
13881
- {{ use_checker(ctx) }}
13882
- {% else %}
13883
- {{ title_default(ctx) }}
13884
- {% endif %}
13885
- {% endmacro %}
13886
- {% macro use_component(ctx) %}
13887
- {% if ctx.tag %}
13888
- {{ pick_component(ctx) }}
13889
- {% else %}
13890
- {% for i in ctx %}
13891
- {{ pick_component(i) }}
13892
- {% endfor %}
13893
- {% endif %}
13894
- {% endmacro %}
13895
-
13896
- {{ use_component(ctx) }}
13897
- <!-- /Component.njk -->
13898
-
13899
- <!-- Text.njk -->
13900
- {% macro text_default(ctx) %}
13901
- {{ ctx.text | replace("false", "❌") | replace("true", "✔️") }}
13902
- {% endmacro %}
13903
-
13904
- {% macro bool_text(ctx) %}
13905
- {{ ctx.text | replace("false", "❌") | replace("true", "✔️") }}
13906
- {% endmacro %}
13907
-
13908
- {% macro use_text(ctx) %}
13909
- {% if ctx.type == "h1" %}
13910
- {{ title_h1(ctx) }}
13911
- {% else %}
13912
- {{ text_default(ctx) }}
13913
- {% endif %}
13914
- {% endmacro %}
13915
- <!-- /Text.njk -->
13916
-
13300
+ const styleText = `<style>/* Components.css */
13301
+ /* END-Components.css */
13302
+ /* ContentTitle.css */
13303
+ .collapsible-container {
13304
+ --margin: 36px 0 20px;
13305
+ width: 100%;
13306
+ overflow: hidden;
13307
+ margin: var(--margin);
13308
+ }
13309
+ .collapsible-input {
13310
+ display: none;
13311
+ }
13312
+ .content-title:hover {
13313
+ color: #409EFF;
13314
+ }
13315
+ .collapsible-label {
13316
+ display: flex;
13317
+ justify-content: space-between;
13318
+ align-items: center;
13319
+ cursor: pointer;
13320
+ }
13321
+ .collapsible-label:hover {
13322
+ color: #409EFF;
13323
+ }
13324
+ .collapsible-input:checked~.collapsible-arrow {
13325
+ transform: rotate(90deg);
13326
+ }
13327
+ .collapsible-content {
13328
+ max-height: 0;
13329
+ overflow: hidden;
13330
+ transition: max-height 0.3s cubic-bezier(0, 1, 0, 1) 0.3s ease;
13331
+ }
13332
+ .collapsible-hover-content {
13333
+ max-height: 0;
13334
+ overflow: hidden;
13335
+ transition: max-height 0.3s cubic-bezier(0, 1, 0, 1) 0.3s ease;
13336
+ }
13337
+ .collapsible-container:hover>.collapsible-hover-content {
13338
+ max-height: 500px;
13339
+ }
13340
+ .collapsible-input:checked~.collapsible-content {
13341
+ max-height: 500px;
13342
+ /* 根据内容调整 */
13343
+ }
13344
+ .title-tag,
13345
+ .title-tag-small {
13346
+ align-items: center;
13347
+ margin-left: 4px;
13348
+ border-radius: 4px;
13349
+ color: white;
13350
+ background-color: #2196F3
13351
+ }
13352
+ .title-tag-titile-container{
13353
+ display: flex;
13354
+ align-items: center
13355
+ }
13356
+ .title-tag-small {
13357
+ font-size: 10px;
13358
+ padding: 2px 8px;
13359
+ }
13360
+ .title-tag {
13361
+ font-size: 10px;
13362
+ padding: 6px 10px;
13363
+ }
13364
+ /* END-ContentTitle.css */
13365
+ /* Divider.css */
13366
+ .divider-base {
13367
+ border: none;
13368
+ height: 1px;
13369
+ background: #e0e0e0;
13370
+ background-size: 100% 100%;
13371
+ margin: 20px 0;
13372
+ }
13373
+ /* END-Divider.css */
13374
+ /* TOC.css */
13375
+ /* 基础样式 */
13376
+ .article-toc {
13377
+ position: fixed;
13378
+ top: 50px;
13379
+ right: 2rem;
13380
+ max-height: calc(100vh - 4rem);
13381
+ margin-left: 2rem;
13382
+ font-size: 0.95rem;
13383
+ }
13384
+ /* 隐藏 checkbox */
13385
+ .toc-toggle-checkbox {
13386
+ position: absolute;
13387
+ opacity: 0;
13388
+ height: 0;
13389
+ width: 0;
13390
+ }
13391
+ /* 切换按钮样式 */
13392
+ .toc-toggle-label {
13393
+ display: flex;
13394
+ align-items: center;
13395
+ background: #f8f9fa;
13396
+ padding: 0.3rem 0.6rem;
13397
+ border-radius: 4px;
13398
+ cursor: pointer;
13399
+ margin-bottom: 0.5rem;
13400
+ }
13401
+ .toc-icon {
13402
+ font-size: 1.2rem;
13403
+ margin-right: 0.3rem;
13404
+ }
13405
+ /* 目录导航 */
13406
+ .toc-nav {
13407
+ padding: 0.5rem;
13408
+ background: white;
13409
+ border-radius: 6px;
13410
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
13411
+ }
13412
+ .toc-section {
13413
+ margin-bottom: 0.8rem;
13414
+ }
13415
+ .toc-heading {
13416
+ font-size: 1rem;
13417
+ margin: 0 0 0.4rem 0;
13418
+ padding-bottom: 0.2rem;
13419
+ border-bottom: 1px solid #eee;
13420
+ }
13421
+ .toc-list {
13422
+ list-style: none;
13423
+ padding-left: 0.4rem;
13424
+ margin: 0;
13425
+ }
13426
+ .toc-item {
13427
+ margin: 0.2rem 0;
13428
+ }
13429
+ .toc-link {
13430
+ display: block;
13431
+ padding: 0.2rem 0.4rem;
13432
+ color: #495057;
13433
+ text-decoration: none;
13434
+ border-radius: 3px;
13435
+ transition: all 0.2s;
13436
+ }
13437
+ .toc-link:hover {
13438
+ background: #f0f0f0;
13439
+ color: #007bff;
13440
+ }
13441
+ /* 层级缩进 */
13442
+ .toc-link[data-level="2"] {
13443
+ padding-left: 0.8rem;
13444
+ }
13445
+ .toc-link[data-level="3"] {
13446
+ padding-left: 1.6rem;
13447
+ }
13448
+ /* 激活状态 */
13449
+ .toc-link.active {
13450
+ background: #e7f5ff;
13451
+ color: #0066cc;
13452
+ font-weight: 500;
13453
+ }
13454
+ /* 折叠功能实现 */
13455
+ .toc-toggle-checkbox:not(:checked) ~ .toc-nav {
13456
+ display: none;
13457
+ }
13458
+ /* 响应式设计 */
13459
+ @media (max-width: 768px) {
13460
+ .article-toc {
13461
+ margin-left: 1rem;
13462
+ font-size: 0.9rem;
13463
+ }
13464
+ }
13465
+ /* END-TOC.css */
13466
+ /* Text.css */
13467
+ /* END-Text.css */
13468
+ /* Title.css */
13469
+ .title-base {
13470
+ --align: left;
13471
+ --text-color: black;
13472
+ --font-weight: 800;
13473
+ --font-size: 18px;
13474
+ color: var(--text-color);
13475
+ text-align: var(--align);
13476
+ font-weight: var(--font-weight);
13477
+ font-size: var(--font-size);
13478
+ padding: 8px 30px;
13479
+ }
13480
+ h1 {
13481
+ --align: left;
13482
+ --text-color: #606266;
13483
+ --margin: 36px 0 20px;
13484
+ position: relative;
13485
+ font-size: 35.2px;
13486
+ padding: 0 0 4.8px;
13487
+ margin: var(--margin);
13488
+ color: var(--text-color);
13489
+ text-align: var(--align);
13490
+ }
13491
+ h2 {
13492
+ --align: left;
13493
+ --text-color: #606266;
13494
+ --margin: 36px 0 20px;
13495
+ position: relative;
13496
+ font-size: 26.4px;
13497
+ padding: 0 0 4.8px;
13498
+ margin: var(--margin);
13499
+ color: var(--text-color);
13500
+ text-align: var(--align);
13501
+ }
13502
+ h3{
13503
+ --align: left;
13504
+ --text-color: #606266;
13505
+ --margin: 36px 0 20px;
13506
+ position: relative;
13507
+ padding: 0 0 4.8px;
13508
+ margin: var(--margin);
13509
+ color: var(--text-color);
13510
+ text-align: var(--align);
13511
+ }
13512
+ h2::before,
13513
+ h1::before {
13514
+ display: none;
13515
+ position: absolute;
13516
+ content: "#";
13517
+ color: #007bff;
13518
+ }
13519
+ h1::before {
13520
+ left: -26px;
13521
+ top: 5px;
13522
+ }
13523
+ h2::before {
13524
+ left: -18px;
13525
+ top: 5px;
13526
+ }
13527
+ h1:hover::before,
13528
+ h2:hover::before {
13529
+ display: inline-block;
13530
+ }
13531
+ .title-main {
13532
+ --align: left;
13533
+ --text-color: black;
13534
+ --font-weight: 800;
13535
+ --font-size: 28px;
13536
+ color: var(--text-color);
13537
+ text-align: var(--align);
13538
+ font-weight: var(--font-weight);
13539
+ font-size: var(--font-size);
13540
+ padding: 8px 30px;
13541
+ margin-bottom: 20px;
13542
+ }
13543
+ .title-center {
13544
+ text-align: center;
13545
+ }
13546
+ /* END-Title.css */
13547
+ /* Notice.css */
13548
+ /* Notice */
13549
+ .notice {
13550
+ margin: 16px 0;
13551
+ padding: 12px 16px;
13552
+ margin-bottom: 1rem;
13553
+ border-radius: 4px;
13554
+ font-size: 14px;
13555
+ line-height: 1.5rem;
13556
+ }
13557
+ .notice-title {
13558
+ font-weight: bold;
13559
+ margin-bottom: 4px;
13560
+ }
13561
+ /* 不同类型的通知样式 */
13562
+ .notice-info {
13563
+ background-color: #e8f4ff;
13564
+ border-left: 4px solid #1890ff;
13565
+ }
13566
+ .notice-warning {
13567
+ background-color: #fff7e6;
13568
+ border-left: 4px solid #faad14;
13569
+ }
13570
+ .notice-success {
13571
+ background-color: #f6ffed;
13572
+ border-left: 4px solid #52c41a;
13573
+ }
13574
+ .notice-error {
13575
+ background-color: #fff2f0;
13576
+ border-left: 4px solid #f5222d;
13577
+ }
13578
+ /* END-Notice.css */
13579
+ /* Block.css */
13580
+ /* Block.njk */
13581
+ .code-block {
13582
+ --block-margin: 0px
13583
+ margin: var(--block-margin) 0;
13584
+ border-radius: 4px;
13585
+ overflow: hidden;
13586
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
13587
+ }
13588
+ .code-block pre {
13589
+ margin: 0;
13590
+ padding: 1rem;
13591
+ background-color: #f5f5f5;
13592
+ font-family: 'Courier New', monospace;
13593
+ font-size: 14px;
13594
+ line-height: 1.5;
13595
+ white-space: pre-wrap;
13596
+ }
13597
+ .code-block code {
13598
+ display: block;
13599
+ overflow-x: auto;
13600
+ }
13601
+ /* END-Block.css */
13602
+ /* Date.css */
13603
+ /* END-Date.css */
13604
+ /* Table.css */
13605
+ .default-table {
13606
+ margin: 0;
13607
+ width: 80%;
13608
+ border-collapse: collapse;
13609
+ border-radius: 15px;
13610
+ /* 合并边框 */
13611
+ font-family: Arial, Helvetica, sans-serif;
13612
+ font-size: 14px;
13613
+ color: #444444;
13614
+ }
13615
+ .thead-light th {
13616
+ background-color: #f5f7fa;
13617
+ color: #333333;
13618
+ font-weight: 600;
13619
+ padding: 12px 16px;
13620
+ text-align: left;
13621
+ border: 1px solid #e1e4e8;
13622
+ font-size: 16px;
13623
+ }
13624
+ .default-row {
13625
+ border: 1px solid #eee;
13626
+ background-color: #fff;
13627
+ }
13628
+ .default-row:hover {
13629
+ background-color: #f0f4f8;
13630
+ color: rebeccapurple;
13631
+ }
13632
+ .default-cell {
13633
+ padding: 10px 16px;
13634
+ border: 1px solid #e1e4e8;
13635
+ font-weight: 400;
13636
+ font-size: 14px;
13637
+ color: #444;
13638
+ background-color: transparent;
13639
+ }
13640
+ /* END-Table.css */
13641
+ /* Tab.css */
13642
+ /* Tab 容器 */
13643
+ .tab-container {
13644
+ max-width: 600px;
13645
+ margin: 0 auto;
13646
+ }
13647
+ /* 隐藏 Radio 按钮 */
13648
+ .tab-radio {
13649
+ display: none;
13650
+ }
13651
+ /* Tab 按钮样式 */
13652
+ .tab-labels {
13653
+ display: flex;
13654
+ border-bottom: 1px solid #ccc;
13655
+ }
13656
+ .tab-label {
13657
+ padding: 5px 10px;
13658
+ cursor: pointer;
13659
+ background-color: #f1f1f1;
13660
+ border: 1px solid #ccc;
13661
+ border-bottom: none;
13662
+ margin-right: 2px;
13663
+ border-radius: 5px 5px 0 0;
13664
+ }
13665
+ .tab-label:hover {
13666
+ background-color: #ddd;
13667
+ }
13668
+ .tab-radio:checked+.tab-label {
13669
+ background-color: #fff;
13670
+ border-bottom: 1px solid #fff;
13671
+ margin-bottom: -1px;
13672
+ }
13673
+ /* Tab 内容区域 */
13674
+ .tab-content {
13675
+ display: none;
13676
+ padding: 20px;
13677
+ border: 1px solid #ccc;
13678
+ border-top: none;
13679
+ }
13680
+ /* END-Tab.css */
13681
+ /* Base.css */
13682
+ body {
13683
+ margin: 0;
13684
+ padding: 0;
13685
+ font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
13686
+ }
13687
+ a {
13688
+ text-decoration: none;
13689
+ }
13690
+ a:hover {
13691
+ color: #409EFF;
13692
+ }
13693
+ .email-main-container {
13694
+ margin: 0;
13695
+ min-width: 1000px;
13696
+ padding: 0 5rem;
13697
+ }
13698
+ /* END-Base.css */
13699
+ </style>`;
13700
+
13701
+ const templateText = `<!-- Head.njk -->
13702
+ {% macro use_head(ctx) %}
13703
+ <head>
13704
+ <meta charset="UTF-8" />
13705
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
13706
+ <title>{{ ctx.title }}</title>
13707
+ {% if ctx.jsFiles%}
13708
+ {% for css in ctx.cssFiles %}
13709
+ <link rel="stylesheet" href="{{ css }}" />
13710
+ {% endfor %}
13711
+ {% endif %}
13712
+ </head>
13713
+ {% if ctx.jsFiles%}
13714
+ {% for js in ctx.jsFiles %}
13715
+ <script src="{{ js }}"></script>
13716
+ {% endfor %}
13717
+ {% endif %}
13718
+ {% endmacro %}
13719
+ <!-- /Head.njk -->
13720
+ <!-- TOC.njk -->
13721
+ {% macro use_toc(ctx) %}
13722
+ <div class="article-toc">
13723
+ <input type="checkbox" id="toc-toggle" class="toc-toggle-checkbox">
13724
+ <label for="toc-toggle" class="toc-toggle-label">
13725
+ <span class="toc-icon">≡</span>
13726
+ <span class="toc-text">目录</span>
13727
+ </label>
13728
+ <nav class="toc-nav">
13729
+ {% for section in ctx.data %}
13730
+ <section class="toc-section">
13731
+ {% if section.link %}
13732
+ <h3 class="toc-heading">
13733
+ <a href="{{ section.link }}" class="toc-link">{{ section.text }}</a>
13734
+ </h3>
13735
+ {% else%}
13736
+ <h3 class="toc-heading">{{ section.text }}</h3>
13737
+ {% endif %}
13738
+ <ul class="toc-list">
13739
+ {% for item in section.items %}
13740
+ <li class="toc-item">
13741
+ <a href="{{ item.link }}" class="toc-link" data-level="{{ loop.depth }}">
13742
+ {% if loop.depth > 1 %}•{% endif %}
13743
+ {{ item.text }}
13744
+ </a>
13745
+ </li>
13746
+ {% endfor %}
13747
+ </ul>
13748
+ </section>
13749
+ {% endfor %}
13750
+ </nav>
13751
+ </div>
13752
+ {% endmacro %}
13753
+ <!-- /TOC.njk -->
13754
+ <!-- Divider.njk -->
13755
+ {% macro use_divider(ctx) %}
13756
+ <hr class="divider-base">
13757
+ {% endmacro %}
13758
+ <!-- /Divider.njk -->
13759
+ <!-- Tag.njk -->
13760
+ {% macro use_tag(ctx) %}
13761
+ {% set tagClass = "smart-tag" %}
13762
+ {% set defaultColor = "#4CAF50" %}
13763
+ {% set defaultSize = "medium" %}
13764
+ {% set finalColor = defaultColor %}
13765
+ {% set finalSize = defaultSize %}
13766
+ <span class="{{ tagClass }} {{ finalSize }}" style="background-color: {{ finalColor }};">
13767
+ {{ ctx.text }}
13768
+ </span>
13769
+ <style>
13770
+ .smart-tag {
13771
+ display: inline-flex;
13772
+ align-items: center;
13773
+ padding: 4px 12px;
13774
+ border-radius: 4px;
13775
+ font-family: Arial, sans-serif;
13776
+ color: white;
13777
+ white-space: nowrap;
13778
+ transition: all 0.3s ease;
13779
+ }
13780
+ /* 尺寸控制 */
13781
+ .smart-tag.small {
13782
+ font-size: 12px;
13783
+ padding: 2px 8px;
13784
+ }
13785
+ .smart-tag.medium {
13786
+ font-size: 14px;
13787
+ padding: 4px 12px;
13788
+ }
13789
+ .smart-tag.large {
13790
+ font-size: 16px;
13791
+ padding: 6px 16px;
13792
+ }
13793
+ /* 颜色扩展支持 */
13794
+ .smart-tag.blue { background-color: #2196F3 !important; }
13795
+ .smart-tag.red { background-color: #f44336 !important; }
13796
+ .smart-tag.green { background-color: #4CAF50 !important; }
13797
+ </style>
13798
+ {% endmacro %}
13799
+ <!-- /Tag.njk -->
13800
+ <!-- Title.njk -->
13801
+ {% macro title_default(ctx) %}
13802
+ <h1 style="text-align: center">{{ ctx.text }}</h1>
13803
+ {% endmacro %}
13804
+ {% macro title_h1(ctx) %}
13805
+ <h1 id="{{ ctx.text }}" style="{{ ctx.style }}">
13806
+ {{ ctx.text }}
13807
+ </h1>
13808
+ {% endmacro %}
13809
+ {% macro title_h2(ctx) %}
13810
+ <h2 id="{{ ctx.text }}" class="" style="{{ ctx.style }}">
13811
+ {{ ctx.text }}
13812
+ </h2>
13813
+ {% endmacro %}
13814
+ {% macro title_h3(ctx) %}
13815
+ <h3 id="{{ ctx.text }}" class="" style="{{ ctx.style }}">
13816
+ {{ ctx.text }}
13817
+ </h3>
13818
+ {% endmacro %}
13819
+ {% macro title_table_default(ctx) %}
13820
+ <h3 id="{{ ctx.text }}" class="title_table_default" style="{{ ctx.style }}">
13821
+ {{ ctx.text }}
13822
+ </h3>
13823
+ {% endmacro %}
13824
+ {% macro use_title(ctx) %}
13825
+ {% if ctx.type == "h1" %}
13826
+ {{ title_h1(ctx) }}
13827
+ {% elif ctx.type == "h2" %}
13828
+ {{ title_h2(ctx) }}
13829
+ {% elif ctx.type == "h3" %}
13830
+ {{ title_h3(ctx) }}
13831
+ {% else %}
13832
+ {{ title_default(ctx) }}
13833
+ {% endif %}
13834
+ {% endmacro %}
13835
+ <!-- /Title.njk -->
13836
+ <!-- Notice.njk -->
13837
+ {% macro use_notice(ctx) %}
13838
+ {% if ctx.type %}
13839
+ {% set type = ctx.type %}
13840
+ {% else %}
13841
+ {% set type = "info" %}
13842
+ {% endif %}
13843
+ <div class="notice notice-{{ type }}">
13844
+ <div class="notice-title">{{ type|capitalize }}:</div>
13845
+ <pre class="notice-content">{{ ctx.text }}</pre>
13846
+ </div>
13847
+ {% endmacro %}
13848
+ <!-- /Notice.njk -->
13849
+ <!-- Block.njk -->
13850
+ {% macro use_block(ctx) %}
13851
+ <div class="code-block">
13852
+ <pre><code>{{ ctx.text }}</code></pre>
13853
+ </div>
13854
+ {% endmacro %}
13855
+ <!-- /Block.njk -->
13856
+ <!-- Date.njk -->
13857
+ {% macro use_date(ctx) %}
13858
+ <div class="center-info-box"><span style="font-weight:bolder;color:#606266;">Date:</span>{{ ctx.text}}</div>
13859
+ {% endmacro %}
13860
+ {% macro use_checker(ctx) %}
13861
+ <div class="center-info-box"><span style="font-weight:bolder;color:#606266;">Checker:</span>{{ ctx.text}}</div>
13862
+ {% endmacro %}
13863
+ <!-- /Date.njk -->
13864
+ <!-- Table.njk -->
13865
+ {% macro td_default(ctx) %}
13866
+ {% if ctx.text %}
13867
+ {% set text = ctx.text %}
13868
+ {% else %}
13869
+ {% set text = ctx %}
13870
+ {% endif %}
13871
+ <td class="default-cell">{{ text | replace("false", "") | replace("true", "✔️") }}</td>
13872
+ {% endmacro %}
13873
+ {% macro table_default(ctx) %}
13874
+ {% if ctx.columns %}
13875
+ {% set columns = ctx.columns %}
13876
+ {% elif ctx.th %}
13877
+ {% set columns = ctx.th %}
13878
+ {% else %}
13879
+ {% set columns = [] %}
13880
+ {% endif %}
13881
+ {% if ctx.data %}
13882
+ {% set data = ctx.data %}
13883
+ {% elif ctx.tbody %}
13884
+ {% set data = ctx.tbody %}
13885
+ {% endif %}
13886
+ {% if ctx.title %}
13887
+ {% set title = {text:ctx.title} %}
13888
+ {{ title_h2(title) }}
13889
+ {% endif %}
13890
+ <table class="default-table">
13891
+ <thead class="thead-light">
13892
+ <tr>
13893
+ {% for column in columns %}
13894
+ <th>{{ column }}</th>
13895
+ {% endfor %}
13896
+ </tr>
13897
+ </thead>
13898
+ <tbody>
13899
+ {% for row in data %}
13900
+ <tr class="default-row">
13901
+ {% if ctx.data %}
13902
+ {% for column in columns %}
13903
+ {{ td_default(row[column]) }}
13904
+ {% endfor %}
13905
+ {% else %}
13906
+ {% for value in row %}
13907
+ {{ td_default(value) }}
13908
+ {% endfor %}
13909
+ {% endif %}
13910
+ </tr>
13911
+ {% endfor %}
13912
+ </tbody>
13913
+ </table>
13914
+ {% endmacro %}
13915
+ {% macro use_table(ctx) %}
13916
+ {% if ctx.type == "h1" %}
13917
+ {{ title_h1(ctx) }}
13918
+ {% else %}
13919
+ {{ table_default(ctx) }}
13920
+ {% endif %}
13921
+ {% endmacro %}
13922
+ <!-- /Table.njk -->
13923
+ <!-- Tab.njk -->
13924
+ {% macro useTab(tabs) %}
13925
+ <style>
13926
+ /* 显示选中的 Tab 内容 */
13927
+ {% for tab in tabs %}
13928
+ #{{tab.id}}:checked~#{{tab.content_id}} {
13929
+ display: block;
13930
+ }
13931
+ {% endfor %}
13932
+ </style>
13933
+ <div class="tab-container">
13934
+ {% for tab in tabs %}
13935
+ <!-- Radio 按钮(隐藏) -->
13936
+ <input {% if loop.first %} checked {% endif %} type="radio" name="tabs" id="{{ tab.id }}" class="tab-radio">
13937
+ {% endfor %}
13938
+ <!-- Tab 按钮(用 label 包裹) -->
13939
+ <div class="tab-labels">
13940
+ {% for tab in tabs %}
13941
+ <label for="{{ tab.id }}" class="tab-label">{{ tab.title }}
13942
+ </label>
13943
+ {% endfor %}
13944
+ </div>
13945
+ <!-- Tab 内容 -->
13946
+ {% for tab in tabs %}
13947
+ <div id="{{ tab.content_id }}" class="tab-content">
13948
+ {{ tab.content }}
13949
+ </div>
13950
+ {% endfor %}
13951
+ </div>
13952
+ {% endmacro %}
13953
+ <!-- /Tab.njk -->
13954
+ <!-- ContentTitle.njk -->
13955
+ {% macro h3_handler(ctx) %}
13956
+ <div class="title-tag-titile-container">
13957
+ {% if ctx.h3 %}
13958
+ <h3 style="margin: 0;" class="content-title">{{ ctx.title }}</h3>
13959
+ {% else %}
13960
+ <h2 style="margin: 0;" class="content-title">{{ ctx.title }}</h3>
13961
+ {% endif %}
13962
+ <span class="title-tag-small">注释</span>
13963
+ </div>
13964
+ {% endmacro %}
13965
+ {% macro content_title_click(ctx) %}
13966
+ <div class="collapsible-container">
13967
+ <input type="checkbox" id="{{ ctx.title }}" class="collapsible-input" hidden>
13968
+ <label for="{{ ctx.title }}" class="collapsible-label">
13969
+ {{ h3_handler(ctx) }}
13970
+ </label>
13971
+ <div class="collapsible-content">
13972
+ {{ use_block(ctx) }}
13973
+ </div>
13974
+ </div>
13975
+ {% endmacro %}
13976
+ {% macro content_title_hover(ctx) %}
13977
+ <div class="collapsible-container">
13978
+ <div class="collapsible-label">
13979
+ {{ h3_handler(ctx) }}
13980
+ </div>
13981
+ <div class="collapsible-hover-content">
13982
+ {{ use_block(ctx) }}
13983
+ </div>
13984
+ </div>
13985
+ {% endmacro %}
13986
+ {% macro content_title_remain(ctx) %}
13987
+ <div class="collapsible-container">
13988
+ {{ h3_handler(ctx) }}
13989
+ <div>
13990
+ {{ use_block(ctx) }}
13991
+ </div>
13992
+ </div>
13993
+ {% endmacro %}
13994
+ {% macro pick_content_title(ctx) %}
13995
+ {% if ctx.hover %}
13996
+ {{ content_title_hover(ctx) }}
13997
+ {% elif ctx.remain %}
13998
+ {{ content_title_remain(ctx) }}
13999
+ {% else %}
14000
+ {{ content_title_click(ctx) }}
14001
+ {% endif %}
14002
+ {% endmacro %}
14003
+ {% macro use_content_title(ctx) %}
14004
+ {% if ctx.type == "h3" or ctx.type == "hover_h3" or ctx.type == "remain_h3" %}
14005
+ {% set h3 = true %}
14006
+ {% endif %}
14007
+ {% if ctx.type == "hover_h3" or ctx.type == "hover" %}
14008
+ {% set hover = true %}
14009
+ {% endif %}
14010
+ {% if ctx.type == "remain_h3" or ctx.type == "remain" %}
14011
+ {% set remain = true %}
14012
+ {% endif %}
14013
+ {% set param = {title:ctx.title, text:ctx.text, h3:h3, hover:hover, remain:remain} %}
14014
+ {{ pick_content_title(param) }}
14015
+ {% endmacro %}
14016
+ <!-- /ContentTitle.njk -->
14017
+ <!-- Component.njk -->
14018
+ {% macro pick_component(ctx) %}
14019
+ {% if ctx.tag == "head" %}
14020
+ {{ use_head(ctx) }}
14021
+ {% elif ctx.tag == "text" %}
14022
+ {{ use_text(ctx) }}
14023
+ {% elif ctx.tag == "title" %}
14024
+ {{ use_title(ctx) }}
14025
+ {% elif ctx.tag == "table" %}
14026
+ {{ use_table(ctx) }}
14027
+ {% elif ctx.tag == "toc" %}
14028
+ {{ use_toc(ctx) }}
14029
+ {% elif ctx.tag == "notice" %}
14030
+ {{ use_notice(ctx) }}
14031
+ {% elif ctx.tag == "block" %}
14032
+ {{ use_block(ctx) }}
14033
+ {% elif ctx.tag == "date" %}
14034
+ {{ use_date(ctx) }}
14035
+ {% elif ctx.tag == "checker" %}
14036
+ {{ use_checker(ctx) }}
14037
+ {% elif ctx.tag == "divider" %}
14038
+ {{ use_divider(ctx) }}
14039
+ {% elif ctx.tag == "tag" %}
14040
+ {{ use_tag(ctx) }}
14041
+ {% elif ctx.tag == "title_content" %}
14042
+ {{ use_content_title(ctx) }}
14043
+ {% else %}
14044
+ {{ title_default(ctx) }}
14045
+ {% endif %}
14046
+ {% endmacro %}
14047
+ {% macro use_component(ctx) %}
14048
+ {% if ctx.tag %}
14049
+ {{ pick_component(ctx) }}
14050
+ {% else %}
14051
+ {% for i in ctx %}
14052
+ {{ pick_component(i) }}
14053
+ {% endfor %}
14054
+ {% endif %}
14055
+ {% endmacro %}
14056
+ <body style="margin: 0; padding: 0;">
14057
+ <div class="email-main-container" style="margin: 0 auto; padding: 0 3rem; border: solid 1px silver;box-sizing: border-box; max-width: 1000px;">
14058
+ {{ use_component(ctx) }}
14059
+ </div>
14060
+ </body>
14061
+ <!-- /Component.njk -->
14062
+ <!-- Text.njk -->
14063
+ {% macro text_default(ctx) %}
14064
+ {{ ctx.text | replace("false", "❌") | replace("true", "✔️") }}
14065
+ {% endmacro %}
14066
+ {% macro bool_text(ctx) %}
14067
+ {{ ctx.text | replace("false", "❌") | replace("true", "✔️") }}
14068
+ {% endmacro %}
14069
+ {% macro use_text(ctx) %}
14070
+ {% if ctx.type == "h1" %}
14071
+ {{ title_h1(ctx) }}
14072
+ {% else %}
14073
+ {{ text_default(ctx) }}
14074
+ {% endif %}
14075
+ {% endmacro %}
14076
+ <!-- /Text.njk -->
13917
14077
  `;
13918
14078
 
13919
14079
  const externalTemplatesDir = node_url.fileURLToPath(new URL("../bundle/src", `${(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('app.min.cjs', document.baseURI).href))}`));
@@ -13921,8 +14081,6 @@ nunjucks.configure(externalTemplatesDir, {
13921
14081
  autoescape: true,
13922
14082
  noCache: true
13923
14083
  });
13924
- node_path.join(externalTemplatesDir, "base.style");
13925
- const TEMPLATES_DIR = node_path.join(externalTemplatesDir, "index.html");
13926
14084
  // 样式注入逻辑优化
13927
14085
  const processConfig = (config, cssUrls) => {
13928
14086
  const headConf = {
@@ -13933,33 +14091,8 @@ const processConfig = (config, cssUrls) => {
13933
14091
  ? [headConf, ...config]
13934
14092
  : [headConf, config];
13935
14093
  };
13936
- // 主渲染函数
13937
- // export const njkRender = async (
13938
- // config: ConfItem | ConfItem[],
13939
- // options: Options = {}
13940
- // ): Promise<string> => {
13941
- // const { cssUrl, templateDir = TEMPLATES_DIR } = options;
13942
- // // 配置验证
13943
- // validateConfig(config);
13944
- // // 处理配置
13945
- // const processedConfig = Array.isArray(config)
13946
- // ? processConfig(config, cssUrl as string[])
13947
- // : processConfig([config], cssUrl as string[]);
13948
- // // 动态配置nunjucks
13949
- // nunjucks.configure(templateDir, {
13950
- // autoescape: true,
13951
- // noCache: process.env.NODE_ENV !== "production" // 生产环境启用缓存
13952
- // });
13953
- // // 异步加载样式
13954
- // const styleContent = await getStyleContent();
13955
- // return nunjucks.render("index.html", {
13956
- // ctx: processedConfig,
13957
- // style: styleContent || ""
13958
- // });
13959
- // };
13960
- // 同步版本(保留备用)
13961
14094
  const njkRenderSync = (config, options = {}) => {
13962
- const { cssUrl, templateDir = TEMPLATES_DIR } = options;
14095
+ const { cssUrl } = options;
13963
14096
  const processedConfig = Array.isArray(config)
13964
14097
  ? processConfig(config, cssUrl)
13965
14098
  : processConfig([config], cssUrl);