Skip to content

Commit 041f29f

Browse files
committed
book: fix the repository link at the bottom of the sidebar
The repository link worked for the front page of each translation of the book, but not for any other page. Now that the URL is stored in the site-wide data, we can fix this. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent a0bd949 commit 041f29f

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

layouts/partials/sidebar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
</ul>
5252
{{ if (eq .Params.Sidebar "book") }}
5353
<hr class="sidebar">
54-
{{ partial "translations.html" }}
54+
{{ partial "translations.html" . }}
5555
{{ else if (and (ne $section "documentation") (ne $section "site")) }}
5656
<hr class="sidebar">
5757
{{ partial "book.html" }}

layouts/partials/translations.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@
4848
</p>
4949
<hr class="sidebar"/>
5050
<p>
51-
The source of this book is <a href="{{ .Page.book.repository_url }}">hosted on GitHub.</a></br>
51+
The source of this book is <a href="{{ (index (index .Site.Data.book .Page.Params.book.language_code) "repository_url") }}">hosted on GitHub.</a></br>
5252
Patches, suggestions and comments are welcome.
5353
</p>

tests/git-scm.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,18 @@ test('manual pages', async ({ page }) => {
201201
test('book', async ({ page }) => {
202202
await page.goto(`${url}book`)
203203

204+
// the repository URL is correct
205+
await expect(page.getByRole('link', { name: 'hosted on GitHub' }))
206+
.toHaveAttribute('href', 'https://github.com/progit/progit2')
207+
204208
// Navigate to the first section
205209
await page.getByRole('link', { name: 'Getting Started' }).click()
206210
await expect(page).toHaveURL(/Getting-Started-About-Version-Control/)
207211

212+
// the repository URL is still correct
213+
await expect(page.getByRole('link', { name: 'hosted on GitHub' }))
214+
.toHaveAttribute('href', 'https://github.com/progit/progit2')
215+
208216
// Verify that the drop-down is shown when clicked
209217
const chaptersDropdown = page.locator('#chapters-dropdown')
210218
await expect(chaptersDropdown).toBeHidden()
@@ -220,6 +228,10 @@ test('book', async ({ page }) => {
220228
await expect(page).toHaveURL(/book\/fr/)
221229
await expect(page.getByRole('link', { name: 'Démarrage rapide' })).toBeVisible()
222230

231+
// the repository URL now points to the French translation
232+
await expect(page.getByRole('link', { name: 'hosted on GitHub' }))
233+
.toHaveAttribute('href', 'https://github.com/progit/progit2-fr')
234+
223235
// Navigate to a page whose URL contains a question mark
224236
await page.goto(`${url}book/az/v2/Başlanğıc-Git-Nədir?`)
225237
if (isRailsApp) {
@@ -229,4 +241,8 @@ test('book', async ({ page }) => {
229241
await expect(page).toHaveURL(/Ba%C5%9Flan%C4%9F%C4%B1c-Git-N%C9%99dir%3F/)
230242
}
231243
await expect(page.getByRole('document')).toHaveText(/Snapshotlar, Fərqlər Yox/)
244+
245+
// the repository URL now points to the Azerbaijani translation
246+
await expect(page.getByRole('link', { name: 'hosted on GitHub' }))
247+
.toHaveAttribute('href', 'https://github.com/progit2-aze/progit2')
232248
})

0 commit comments

Comments
 (0)