diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index b787c6d9..3bc3c7a6 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -25,6 +25,11 @@ jobs: bundler-cache: true cache-version: 2 + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: 16 + - name: Build & Validate run: rake validate diff --git a/Dockerfile b/Dockerfile index f0176c9d..b759d68f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,8 @@ RUN git config --global --add safe.directory /usr/src/docs && git config --globa RUN gem install 'bundler:~>1' rake +RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs + COPY . ./ RUN rake dependencies diff --git a/Rakefile b/Rakefile index a0626950..51a5e95f 100644 --- a/Rakefile +++ b/Rakefile @@ -17,6 +17,8 @@ task :dependencies do sh('bundle install --path gems') end + sh('npm install') + # Fix pathutil on Ruby 3; works around https://github.com/envygeeks/pathutil/pull/5 # as suggested by https://stackoverflow.com/a/73909894/67873 pathutil_path = `bundle exec gem which pathutil`.strip() @@ -24,10 +26,6 @@ task :dependencies do File.write(pathutil_path, content) end -task :spelling_dependencies do - sh('npm install') -end - file '_sass/brand/.git' do sh('git submodule update --init') end @@ -42,8 +40,6 @@ task :build => [:dependencies, :submodules] do sh('bundle exec jekyll build --config _config.yml') end -task :build_spellings => [:build, :spelling_dependencies] - task :validate_kit_versions do data = YAML.load_file('_data/kit_versions.yml') data.each do |entry| @@ -161,7 +157,7 @@ task :validate_sidebar_tree => [:build] do puts "Sidebar links validated successfully" end -task :validate_spellings => [:build_spellings] do +task :validate_spellings => [:build] do sh('npm run spell-check') end diff --git a/_includes/head.html b/_includes/head.html index 3e66f9c8..da93f3ca 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -7,6 +7,7 @@ + {% if page.extra_css %} diff --git a/_includes/script.html b/_includes/script.html index 31e54719..7a0356d6 100644 --- a/_includes/script.html +++ b/_includes/script.html @@ -14,3 +14,5 @@ + + diff --git a/_layouts/page.html b/_layouts/page.html index affb1f85..a2517351 100644 --- a/_layouts/page.html +++ b/_layouts/page.html @@ -3,18 +3,21 @@ ---
-

Documentation

+

Documentation

{% include sidebar.html %}
+
+ +
{% include sidebar.html %}
-
+
{{ content }}
diff --git a/_sass/base.scss b/_sass/base.scss index fdfaf119..cb2485ca 100644 --- a/_sass/base.scss +++ b/_sass/base.scss @@ -8,7 +8,6 @@ } html, body { - background: $sr-black; font-family: $main-font-family; font-size: 16px; height: 100%; diff --git a/_sass/search.scss b/_sass/search.scss new file mode 100644 index 00000000..1bb64740 --- /dev/null +++ b/_sass/search.scss @@ -0,0 +1,17 @@ +:root { + --pagefind-ui-scale: 0.8; + --pagefind-ui-primary: #{$sr-blue}; + --pagefind-ui-text: #{$sr-black}; + --pagefind-ui-border: #{$sr-medium-grey}; + --pagefind-ui-tag: #{$sr-medium-grey}; + --pagefind-ui-border-radius: 0px; + --pagefind-ui-border-width: 1px; +} + +.pagefind-ui__search-clear { + border: none; +} + +#search { + margin-top: $spacing; +} diff --git a/css/main.scss b/css/main.scss index 110b682a..262f87e8 100644 --- a/css/main.scss +++ b/css/main.scss @@ -12,5 +12,6 @@ "docs", "messages", "footer", - "syntax-highlighting" + "syntax-highlighting", + "search" ; diff --git a/js/search.js b/js/search.js new file mode 100644 index 00000000..c4009da8 --- /dev/null +++ b/js/search.js @@ -0,0 +1,17 @@ +window.addEventListener('DOMContentLoaded', (event) => { + if (!window.PagefindUI) { + console.warn("Unable to initialize search - perhaps we're running locally"); + return; + } + + new PagefindUI({ + element: "#search", + resetStyles: false, + processResult: function (result) { + // Remove the `.html` suffix + // `index.html` is already handled for us. + result.url = result.url.replace(".html", "") + return result; + } + }); +}); diff --git a/package-lock.json b/package-lock.json index 639a7a2a..3f06ad7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,7 +5,8 @@ "packages": { "": { "dependencies": { - "cspell": "5.18.5" + "cspell": "5.18.5", + "pagefind": "^0.12.0" } }, "node_modules/@babel/code-frame": { @@ -361,6 +362,17 @@ "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, "node_modules/ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -645,6 +657,22 @@ "node": ">=12.13.0" } }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, "node_modules/dot-prop": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", @@ -836,6 +864,18 @@ "node": ">=8" } }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -1019,6 +1059,11 @@ "node": "*" } }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -1055,6 +1100,19 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/pagefind": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/pagefind/-/pagefind-0.12.0.tgz", + "integrity": "sha512-LHUmlYYweBM6/rK1G+7z2q2WjYeycrB7g5Kuw0w6yMkYztzsEdO2Qj2pJ3z8gsWV8eJsYQyAGOAdqE3SZWlCqA==", + "hasInstallScript": true, + "dependencies": { + "https-proxy-agent": "^5.0.0", + "proxy-from-env": "^1.1.0" + }, + "bin": { + "pagefind": "lib/index.js" + } + }, "node_modules/parent-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-2.0.0.tgz", @@ -1118,6 +1176,11 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", @@ -1618,6 +1681,14 @@ "resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz", "integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA==" }, + "agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "requires": { + "debug": "4" + } + }, "ansi-regex": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", @@ -1830,6 +1901,14 @@ "gensequence": "^3.1.1" } }, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, "dot-prop": { "version": "5.3.0", "resolved": "https://registry.npmjs.org/dot-prop/-/dot-prop-5.3.0.tgz", @@ -1966,6 +2045,15 @@ "resolved": "https://registry.npmjs.org/has-own-prop/-/has-own-prop-2.0.0.tgz", "integrity": "sha512-Pq0h+hvsVm6dDEa8x82GnLSYHOzNDt7f0ddFa3FqcQlgzEiptPqL+XrOJNavjOzSYiYWIrgeVYYgGlLmnxwilQ==" }, + "https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "requires": { + "agent-base": "6", + "debug": "4" + } + }, "import-fresh": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", @@ -2106,6 +2194,11 @@ "brace-expansion": "^1.1.7" } }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -2130,6 +2223,15 @@ "p-limit": "^3.0.2" } }, + "pagefind": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/pagefind/-/pagefind-0.12.0.tgz", + "integrity": "sha512-LHUmlYYweBM6/rK1G+7z2q2WjYeycrB7g5Kuw0w6yMkYztzsEdO2Qj2pJ3z8gsWV8eJsYQyAGOAdqE3SZWlCqA==", + "requires": { + "https-proxy-agent": "^5.0.0", + "proxy-from-env": "^1.1.0" + } + }, "parent-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-2.0.0.tgz", @@ -2169,6 +2271,11 @@ "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==" }, + "proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", diff --git a/package.json b/package.json index 7d698997..21a202e4 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,11 @@ { "scripts": { "test": "npm run spell-check", - "spell-check": "cspell" + "spell-check": "cspell", + "build-search-index": "pagefind" }, - "@comments": [ - "These dependencies are only for testing the site.", - "The site is built with Jekyll so site dependencies should be in the Gemfile." - ], "dependencies": { - "cspell": "5.18.5" + "cspell": "5.18.5", + "pagefind": "^0.12.0" } } diff --git a/pagefind.yml b/pagefind.yml new file mode 100644 index 00000000..84b80df5 --- /dev/null +++ b/pagefind.yml @@ -0,0 +1 @@ +source: ./_site