mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-04-08 20:34:10 +02:00
Compare commits
14 commits
55f99e9134
...
e89365f324
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e89365f324 | ||
|
|
754e9c82b8 | ||
|
|
86675ad4a4 | ||
|
|
49fec082f5 | ||
|
|
0cc8ee38d5 | ||
|
|
af1e9382ca | ||
|
|
84b5e98f25 | ||
|
|
0cf8fca4da | ||
|
|
bccbff878d | ||
|
|
308bcfd20e | ||
|
|
1f5d598754 | ||
|
|
59c7282ddb | ||
|
|
f49668d722 | ||
|
|
1c2e58d66f |
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
|
@ -238,7 +238,7 @@ jobs:
|
|||
|
||||
- name: "🔍 pagefind indexing"
|
||||
run: |
|
||||
npx -y pagefind --site "spec${baseURL}"
|
||||
npm run pagefind -- --site "spec${baseURL}"
|
||||
|
||||
- name: "📦 Tarball creation"
|
||||
run: |
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ The spec uses [Pagefind](https://pagefind.app/) to provide a page search widget.
|
|||
search index _after_ building the static site.
|
||||
|
||||
```
|
||||
hugo build && npx -y pagefind --site public && hugo serve
|
||||
hugo build && npm run pagefind -- --site public && hugo serve
|
||||
```
|
||||
|
||||
Note that while `hugo serve` supports hot reloading, changes made to the site content won't reflect in the search index without
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
/*
|
||||
Adapted from [1] to combine Docsy"s built-in search UI with the Pagefind
|
||||
Adapted from [1] to combine Docsy's built-in search UI with the Pagefind
|
||||
search backend.
|
||||
|
||||
[1]: https://github.com/matrix-org/docsy/blob/71d103ebb20ace3d528178c4b6d92b6cc4f7fd53/assets/js/offline-search.js
|
||||
|
|
@ -25,7 +25,9 @@ search backend.
|
|||
"use strict";
|
||||
|
||||
$(document).ready(async function () {
|
||||
const pagefind = await import("/pagefind/pagefind.js");
|
||||
// This is going to be loaded from ${deployment}/js/main.js so to use a relative path
|
||||
// to the Pagefind script we need to navigate one level up.
|
||||
const pagefind = await import("../pagefind/pagefind.js");
|
||||
const $searchInput = $(".td-search input");
|
||||
|
||||
//
|
||||
|
|
@ -40,8 +42,13 @@ search backend.
|
|||
// Set up search input handler.
|
||||
//
|
||||
|
||||
$searchInput.on("change", (event) => {
|
||||
render($(event.target));
|
||||
$searchInput.on("keypress", (event) => {
|
||||
// Start searching only upon Enter.
|
||||
if (event.which === 13) {
|
||||
event.preventDefault();
|
||||
render($(event.target));
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent reloading page by enter key on sidebar search.
|
||||
|
|
@ -85,7 +92,7 @@ search backend.
|
|||
.text("Loading...")))
|
||||
.append($("<p>")
|
||||
.text("Loading..."));
|
||||
const popover = new bootstrap.Popover($targetSearchInput, {
|
||||
const popover = new bootstrap.Popover($targetSearchInput[0], {
|
||||
content: $spinner[0],
|
||||
html: true,
|
||||
customClass: "td-offline-search-results",
|
||||
|
|
@ -119,9 +126,12 @@ search backend.
|
|||
.append($("<span>")
|
||||
.text("Search results")
|
||||
.css({ fontWeight: "bold" }))
|
||||
.append($("<span>")
|
||||
.append($("<button>")
|
||||
.addClass("td-offline-search-results__close-button")
|
||||
.attr("role", "button")
|
||||
.addClass("btn")
|
||||
.addClass("btn-sm")
|
||||
.addClass("btn-link")
|
||||
.attr("type", "button")
|
||||
.attr("aria-label", "Close")
|
||||
.on("click", () => {
|
||||
$targetSearchInput.val("");
|
||||
|
|
@ -165,15 +175,18 @@ search backend.
|
|||
r.sub_results.forEach((s, index_s) => {
|
||||
if (index_s === LIMIT) {
|
||||
const num_hidden_results = r.sub_results.length - index_s;
|
||||
const wrapper_id = `collapssible-subresults-${index_r}`;
|
||||
const wrapper_id = `collapsible-subresults-${index_r}`;
|
||||
const $action = $("<span>").text("▶ Show");
|
||||
const $expander = $("<a>")
|
||||
const $expander = $("<button>")
|
||||
.attr("data-bs-toggle", "collapse")
|
||||
.attr("data-bs-target", `#${wrapper_id}`)
|
||||
.attr("href", "#")
|
||||
.attr("role", "button")
|
||||
.attr("aria-expanded", "false")
|
||||
.attr("aria-controls", wrapper_id)
|
||||
.attr("type", "button")
|
||||
.addClass("td-offline-search-results__expander-button")
|
||||
.addClass("btn")
|
||||
.addClass("btn-sm")
|
||||
.addClass("btn-link")
|
||||
.append($action)
|
||||
.append($("<span>").text(` ${num_hidden_results} more ${resultsString(num_hidden_results)} from ${r.meta.title}`));
|
||||
|
||||
|
|
@ -215,7 +228,7 @@ search backend.
|
|||
// content manually.
|
||||
//
|
||||
// [1]: https://github.com/twbs/bootstrap/issues/37206#issuecomment-1259541205
|
||||
$(popover.tip.querySelector('.popover-body')).html($html[0]);
|
||||
$(popover.tip.querySelector('.popover-body')).empty().append($html);
|
||||
popover.update();
|
||||
};
|
||||
});
|
||||
|
|
@ -226,5 +239,5 @@ search backend.
|
|||
//
|
||||
|
||||
const resultsString = (n) => {
|
||||
return n > 1 ? "results" : "result";
|
||||
return n === 1 ? "result" : "results";
|
||||
};
|
||||
|
|
|
|||
|
|
@ -677,3 +677,16 @@ dd {
|
|||
.td-offline-search-results .spinner-container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.td-offline-search-results__close-button {
|
||||
// Prevent the label from rendering white on white.
|
||||
--bs-btn-color: unset;
|
||||
}
|
||||
|
||||
.td-offline-search-results__expander-button {
|
||||
// Prevent the label from rendering white on white.
|
||||
--bs-btn-color: unset;
|
||||
// Avoid any extra inset.
|
||||
--bs-btn-padding-x: 0;
|
||||
--bs-btn-padding-y: 0;
|
||||
}
|
||||
|
|
@ -152,7 +152,8 @@ sidebar_menu_compact = true
|
|||
[server.headers.values]
|
||||
# `style-src 'unsafe-inline'` is needed to correctly render the maths in the Olm spec:
|
||||
# https://github.com/KaTeX/KaTeX/issues/4096
|
||||
# `script-src 'unsafe-eval'` is needed because Pagefind relies on it to load its Wasm:
|
||||
# `script-src 'unsafe-eval'` is needed because Pagefind relies on it to load its Wasm.
|
||||
# In future, we should switch to `wasm-unsafe-eval` but this doesn't yet work in Safari:
|
||||
# https://github.com/Pagefind/pagefind/blob/main/docs/content/docs/hosting.md
|
||||
Content-Security-Policy = "default-src 'self'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-eval'; img-src 'self' data:; connect-src 'self'; font-src 'self' data:; media-src 'self'; child-src 'self'; form-action 'self'; object-src 'self'"
|
||||
X-XSS-Protection = "1; mode=block"
|
||||
|
|
|
|||
159
package-lock.json
generated
159
package-lock.json
generated
|
|
@ -12,6 +12,7 @@
|
|||
"@fullhuman/postcss-purgecss": "^6.0.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"node-fetch": "^2.6.7",
|
||||
"pagefind": "^1.4.0",
|
||||
"postcss": "^8.4.49",
|
||||
"postcss-cli": "^11.0.0"
|
||||
}
|
||||
|
|
@ -170,6 +171,90 @@
|
|||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/@pagefind/darwin-arm64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/darwin-arm64/-/darwin-arm64-1.4.0.tgz",
|
||||
"integrity": "sha512-2vMqkbv3lbx1Awea90gTaBsvpzgRs7MuSgKDxW0m9oV1GPZCZbZBJg/qL83GIUEN2BFlY46dtUZi54pwH+/pTQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@pagefind/darwin-x64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/darwin-x64/-/darwin-x64-1.4.0.tgz",
|
||||
"integrity": "sha512-e7JPIS6L9/cJfow+/IAqknsGqEPjJnVXGjpGm25bnq+NPdoD3c/7fAwr1OXkG4Ocjx6ZGSCijXEV4ryMcH2E3A==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
]
|
||||
},
|
||||
"node_modules/@pagefind/freebsd-x64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/freebsd-x64/-/freebsd-x64-1.4.0.tgz",
|
||||
"integrity": "sha512-WcJVypXSZ+9HpiqZjFXMUobfFfZZ6NzIYtkhQ9eOhZrQpeY5uQFqNWLCk7w9RkMUwBv1HAMDW3YJQl/8OqsV0Q==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
]
|
||||
},
|
||||
"node_modules/@pagefind/linux-arm64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/linux-arm64/-/linux-arm64-1.4.0.tgz",
|
||||
"integrity": "sha512-PIt8dkqt4W06KGmQjONw7EZbhDF+uXI7i0XtRLN1vjCUxM9vGPdtJc2mUyVPevjomrGz5M86M8bqTr6cgDp1Uw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@pagefind/linux-x64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/linux-x64/-/linux-x64-1.4.0.tgz",
|
||||
"integrity": "sha512-z4oddcWwQ0UHrTHR8psLnVlz6USGJ/eOlDPTDYZ4cI8TK8PgwRUPQZp9D2iJPNIPcS6Qx/E4TebjuGJOyK8Mmg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
]
|
||||
},
|
||||
"node_modules/@pagefind/windows-x64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/windows-x64/-/windows-x64-1.4.0.tgz",
|
||||
"integrity": "sha512-NkT+YAdgS2FPCn8mIA9bQhiBs+xmniMGq1LFPDhcFn0+2yIUEiIG06t7bsZlhdjknEQRTSdT7YitP6fC5qwP0g==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
]
|
||||
},
|
||||
"node_modules/@pkgjs/parseargs": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
||||
|
|
@ -914,6 +999,24 @@
|
|||
"dev": true,
|
||||
"license": "BlueOak-1.0.0"
|
||||
},
|
||||
"node_modules/pagefind": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/pagefind/-/pagefind-1.4.0.tgz",
|
||||
"integrity": "sha512-z2kY1mQlL4J8q5EIsQkLzQjilovKzfNVhX8De6oyE6uHpfFtyBaqUpcl/XzJC/4fjD8vBDyh1zolimIcVrCn9g==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"pagefind": "lib/runner/bin.cjs"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@pagefind/darwin-arm64": "1.4.0",
|
||||
"@pagefind/darwin-x64": "1.4.0",
|
||||
"@pagefind/freebsd-x64": "1.4.0",
|
||||
"@pagefind/linux-arm64": "1.4.0",
|
||||
"@pagefind/linux-x64": "1.4.0",
|
||||
"@pagefind/windows-x64": "1.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/path-key": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||
|
|
@ -1652,6 +1755,48 @@
|
|||
"fastq": "^1.6.0"
|
||||
}
|
||||
},
|
||||
"@pagefind/darwin-arm64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/darwin-arm64/-/darwin-arm64-1.4.0.tgz",
|
||||
"integrity": "sha512-2vMqkbv3lbx1Awea90gTaBsvpzgRs7MuSgKDxW0m9oV1GPZCZbZBJg/qL83GIUEN2BFlY46dtUZi54pwH+/pTQ==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@pagefind/darwin-x64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/darwin-x64/-/darwin-x64-1.4.0.tgz",
|
||||
"integrity": "sha512-e7JPIS6L9/cJfow+/IAqknsGqEPjJnVXGjpGm25bnq+NPdoD3c/7fAwr1OXkG4Ocjx6ZGSCijXEV4ryMcH2E3A==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@pagefind/freebsd-x64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/freebsd-x64/-/freebsd-x64-1.4.0.tgz",
|
||||
"integrity": "sha512-WcJVypXSZ+9HpiqZjFXMUobfFfZZ6NzIYtkhQ9eOhZrQpeY5uQFqNWLCk7w9RkMUwBv1HAMDW3YJQl/8OqsV0Q==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@pagefind/linux-arm64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/linux-arm64/-/linux-arm64-1.4.0.tgz",
|
||||
"integrity": "sha512-PIt8dkqt4W06KGmQjONw7EZbhDF+uXI7i0XtRLN1vjCUxM9vGPdtJc2mUyVPevjomrGz5M86M8bqTr6cgDp1Uw==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@pagefind/linux-x64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/linux-x64/-/linux-x64-1.4.0.tgz",
|
||||
"integrity": "sha512-z4oddcWwQ0UHrTHR8psLnVlz6USGJ/eOlDPTDYZ4cI8TK8PgwRUPQZp9D2iJPNIPcS6Qx/E4TebjuGJOyK8Mmg==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@pagefind/windows-x64": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@pagefind/windows-x64/-/windows-x64-1.4.0.tgz",
|
||||
"integrity": "sha512-NkT+YAdgS2FPCn8mIA9bQhiBs+xmniMGq1LFPDhcFn0+2yIUEiIG06t7bsZlhdjknEQRTSdT7YitP6fC5qwP0g==",
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"@pkgjs/parseargs": {
|
||||
"version": "0.11.0",
|
||||
"resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz",
|
||||
|
|
@ -2117,6 +2262,20 @@
|
|||
"integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==",
|
||||
"dev": true
|
||||
},
|
||||
"pagefind": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/pagefind/-/pagefind-1.4.0.tgz",
|
||||
"integrity": "sha512-z2kY1mQlL4J8q5EIsQkLzQjilovKzfNVhX8De6oyE6uHpfFtyBaqUpcl/XzJC/4fjD8vBDyh1zolimIcVrCn9g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@pagefind/darwin-arm64": "1.4.0",
|
||||
"@pagefind/darwin-x64": "1.4.0",
|
||||
"@pagefind/freebsd-x64": "1.4.0",
|
||||
"@pagefind/linux-arm64": "1.4.0",
|
||||
"@pagefind/linux-x64": "1.4.0",
|
||||
"@pagefind/windows-x64": "1.4.0"
|
||||
}
|
||||
},
|
||||
"path-key": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
|
||||
|
|
|
|||
|
|
@ -5,7 +5,8 @@
|
|||
"main": "none.js",
|
||||
"scripts": {
|
||||
"get-proposals": "node ./scripts/proposals.js",
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"test": "echo \"Error: no test specified\" && exit 1",
|
||||
"pagefind": "pagefind $@"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
|
@ -22,6 +23,7 @@
|
|||
"@fullhuman/postcss-purgecss": "^6.0.0",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"node-fetch": "^2.6.7",
|
||||
"pagefind": "^1.4.0",
|
||||
"postcss": "^8.4.49",
|
||||
"postcss-cli": "^11.0.0"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue