Skip to content

Commit 0f954b2

Browse files
authored
Merge pull request #140 from nikomatsakis/progress-bars
small fixes to hopefully make it work
2 parents a04f2d6 + ae758d3 commit 0f954b2

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

mdbook-goals/src/json.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,8 +157,6 @@ fn checkboxes(issue: &ExistingGithubIssue) -> anyhow::Result<Progress> {
157157
}
158158
}
159159

160-
eprintln!("#{}: {checkboxes:?}, {issues:?}", issue.number);
161-
162160
match (checkboxes, issues) {
163161
(Some((completed, total)), None) | (None, Some((completed, total))) => {
164162
Ok(Progress::Tracked { completed, total })

src/update-progress-bars.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,8 @@
4141
}
4242

4343
if (!(milestone in this.#dataMap)) {
44-
// Construct the URL using the dirName
45-
const url = `/api/${milestone}.json`;
46-
4744
try {
48-
const response = await fetch(url);
45+
const response = await fetch(getApiUrl(milestone));
4946
if (!response.ok) {
5047
throw new Error(`HTTP error! status: ${response.status}`);
5148
}
@@ -144,4 +141,15 @@
144141
}
145142
return element;
146143
}
144+
145+
function getApiUrl(milestone) {
146+
// When you are doing mdbook serve, you don't want /rust-project/goals.
147+
// But on github pages, you do.
148+
// There is probably a more elegant way to do this.
149+
const currentPath = document.location.pathname;
150+
const basePath = currentPath.startsWith('/rust-project-goals/')
151+
? '/rust-project-goals/'
152+
: '/';
153+
return `${basePath}api/${milestone}.json`;
154+
}
147155
})();

0 commit comments

Comments
 (0)