|
81 | 81 | "external_links_check_timeout", |
82 | 82 | "image_widths", |
83 | 83 | "stop_words", |
| 84 | + "third_party", |
84 | 85 | } |
85 | 86 | ) |
86 | 87 |
|
@@ -750,4 +751,56 @@ def parse_site_config_from_dict( |
750 | 751 | ) |
751 | 752 | kwargs["stop_words"] = [] |
752 | 753 |
|
| 754 | + # --- third_party --------------------------------------------------------- |
| 755 | + third_party_defaults = { |
| 756 | + "mermaid": { |
| 757 | + "script_url": "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs" |
| 758 | + }, |
| 759 | + "katex": { |
| 760 | + "css_url": "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.css", |
| 761 | + "js_url": "https://cdn.jsdelivr.net/npm/katex@0.16.9/dist/katex.min.js", |
| 762 | + }, |
| 763 | + "mathjax": { |
| 764 | + "js_url": "https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" |
| 765 | + }, |
| 766 | + "fontawesome": { |
| 767 | + "metadata_url": "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/6.7.2/metadata/icons.json", |
| 768 | + "webfonts_base": "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/webfonts", |
| 769 | + "css_url": "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/css/all.min.css", |
| 770 | + "woff2_url": "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.7.2/webfonts/fa-brands-400.woff2", |
| 771 | + }, |
| 772 | + "force_graph": {"js_url": "https://unpkg.com/force-graph"}, |
| 773 | + } |
| 774 | + |
| 775 | + raw_third_party = config.get("third_party") |
| 776 | + if raw_third_party is None: |
| 777 | + kwargs["third_party"] = third_party_defaults |
| 778 | + elif isinstance(raw_third_party, dict): |
| 779 | + merged = {} |
| 780 | + for section, default_keys in third_party_defaults.items(): |
| 781 | + merged[section] = dict(default_keys) |
| 782 | + user_section = raw_third_party.get(section) |
| 783 | + if isinstance(user_section, dict): |
| 784 | + for key in default_keys: |
| 785 | + user_val = user_section.get(key) |
| 786 | + if user_val is not None: |
| 787 | + if isinstance(user_val, str): |
| 788 | + merged[section][key] = user_val |
| 789 | + else: |
| 790 | + errors.append( |
| 791 | + f"third_party.{section}.{key} in the configuration file " |
| 792 | + "must be a string; ignoring value" |
| 793 | + ) |
| 794 | + elif user_section is not None: |
| 795 | + errors.append( |
| 796 | + f"third_party.{section} in the configuration file must be a mapping; " |
| 797 | + "ignoring value" |
| 798 | + ) |
| 799 | + kwargs["third_party"] = merged |
| 800 | + else: |
| 801 | + errors.append( |
| 802 | + "third_party in the configuration file must be a mapping; ignoring value" |
| 803 | + ) |
| 804 | + kwargs["third_party"] = third_party_defaults |
| 805 | + |
753 | 806 | return kwargs, errors |
0 commit comments