Skip to content

Commit e7e9749

Browse files
DEV - Add Fontawesome scripts to build assets (#1982)
I seem to have forgotten to add the FA scripts to the `pyproject.toml` so I am adding it here (which should fix the FA rendering issue in the dev version of the docs). --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c67c745 commit e7e9749

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ theme-name = "pydata_sphinx_theme"
1010
additional-compiled-static-assets = [
1111
"webpack-macros.html",
1212
"vendor/",
13-
"styles/bootstrap.css",
1413
"scripts/bootstrap.js",
14+
"scripts/fontawesome.js",
1515
"locale/",
1616
]
1717

@@ -53,7 +53,7 @@ classifiers = [
5353
[project.optional-dependencies]
5454
doc = [
5555
"numpydoc",
56-
"linkify-it-py", # for link shortening
56+
"linkify-it-py", # for link shortening
5757
"rich",
5858
"sphinxext-rediraffe",
5959
"sphinx-sitemap",
@@ -105,6 +105,7 @@ fix = true
105105
ignore = [
106106
"E501", # line too long | Black take care of it
107107
"D107", # Missing docstring in `__init__` | set the docstring in the class
108+
108109
]
109110
ignore-init-module-imports = true
110111
select = ["E", "F", "W", "I", "D", "RUF"]
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// TODO: @trallard might end up moving this to the main JS file
22
// Define the custom behavior of the page
3-
import { documentReady } from "./mixin";
43

54
import "@fortawesome/fontawesome-free/js/all.min.js";

src/pydata_sphinx_theme/assets/styles/extensions/_sphinx_design.scss

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ $all-colors: map.merge($pst-semantic-colors, $extra-semantic-colors);
6666

6767
@mixin create-sd-colors($value, $name) {
6868
// define the pst variables, so that downstream user overrides will work
69-
@debug "Creating color variables for semantic color: #{$name}";
70-
7169
--pst-color-#{$name}: #{$value};
7270

7371
// we are now using a11y-combination to calculate the text color - this is based

webpack.config.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ const { Compilation } = require("webpack");
2323

2424
const scriptPath = resolve(__dirname, "src/pydata_sphinx_theme/assets/scripts");
2525
const staticPath = resolve(__dirname, "src/pydata_sphinx_theme/theme/pydata_sphinx_theme/static");
26-
const vendorPath = resolve(staticPath, "vendor");
2726

2827
/*******************************************************************************
2928
* functions to load the assets in the html head
@@ -32,8 +31,10 @@ const vendorPath = resolve(staticPath, "vendor");
3231
*/
3332

3433
function stylesheet(css) { return `<link href="{{ pathto('_static/${css}', 1) }}?digest=${this.hash}" rel="stylesheet" />`; }
35-
function preload(js) { return `<link rel="preload" as="script" href="{{ pathto('_static/${js}', 1) }}?digest=${this.hash}" />`; }
36-
function script(js) { return `<script defer src="{{ pathto('_static/${js}', 1) }}?digest=${this.hash}"></script>`; }
34+
function preloadScript(js) { return `<link rel="preload" as="script" href="{{ pathto('_static/${js}', 1) }}?digest=${this.hash}" />`; }
35+
function deferScript(js) { return `<script defer src="{{ pathto('_static/${js}', 1) }}?digest=${this.hash}"></script>`; }
36+
// Adding FA without preloading
37+
function script(js) { return `<script src="{{ pathto('_static/${js}', 1) }}?digest=${this.hash}"></script>`; }
3738

3839
/*******************************************************************************
3940
* the assets to load in the macro
@@ -70,14 +71,15 @@ function macroTemplate({ compilation }) {
7071
{% endmacro %}
7172
7273
{% macro head_js_preload() %}
74+
<!-- So that users can add custom icons -->
75+
${fa_scripts.map(script.bind(compilation)).join("\n")}
7376
<!-- Pre-loaded scripts that we'll load fully later -->
74-
${theme_scripts.map(preload.bind(compilation)).join("\n")}
77+
${theme_scripts.map(preloadScript.bind(compilation)).join("\n")}
7578
{% endmacro %}
7679
7780
{% macro body_post() %}
7881
<!-- Scripts loaded after <body> so the DOM is not blocked -->
79-
${fa_scripts.map(script.bind(compilation)).join("\n")}
80-
${theme_scripts.map(script.bind(compilation)).join("\n")}
82+
${theme_scripts.map(deferScript.bind(compilation)).join("\n")}
8183
{% endmacro %}
8284
`);
8385
}

0 commit comments

Comments
 (0)