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