Bezier-rs: Add hash URLs for individual API examples (#968)

* Handle displaying single demos

* Address comments

* Update eslintrc

* Add hash links

* Use hash instead of pathname

* Address small nits

* Change url format

* CSS improvements

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Hannah Li
2023-02-08 20:32:28 -08:00
committed by GitHub
co-authored by Keavon Chambers
parent d3787eb5f6
commit 369adec369
10 changed files with 209 additions and 87 deletions
@@ -42,9 +42,16 @@ export function renderDemoPane(demoPane: DemoPane): void {
const container = document.createElement("div");
container.className = "demo-pane-container";
const headerAnchorLink = document.createElement("a");
headerAnchorLink.innerText = "#";
const currentHash = window.location.hash.split("/");
// Add href anchor if not on a solo example page
if (currentHash.length !== 3 && currentHash[2] !== "solo") headerAnchorLink.href = `#${demoPane.id}`;
const header = document.createElement("h3");
header.innerText = demoPane.name;
header.className = "demo-pane-header";
header.append(headerAnchorLink);
const computeTypeContainer = document.createElement("div");
computeTypeContainer.className = "compute-type-choice";