-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: should generate unique aside link id when using different syntax (…
- Loading branch information
1 parent
0e693f9
commit b713841
Showing
10 changed files
with
125 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@rspress/core': patch | ||
--- | ||
|
||
release |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Guide | ||
|
||
## title 1 {#custom-id} | ||
|
||
## title 2 | ||
|
||
## title 2 | ||
|
||
## `title` 2 | ||
|
||
## Title 2 | ||
|
||
## **title** 2 | ||
|
||
## *title* 2 |
2 changes: 1 addition & 1 deletion
2
e2e/fixtures/custom-id/package.json → e2e/fixtures/toc-id/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { expect, test } from '@playwright/test'; | ||
import path from 'node:path'; | ||
import { getPort, killProcess, runDevCommand } from '../utils/runCommands'; | ||
|
||
const fixtureDir = path.resolve(__dirname, '../fixtures'); | ||
|
||
test.describe('custom-id test', async () => { | ||
let appPort; | ||
let app; | ||
test.beforeAll(async () => { | ||
const appDir = path.join(fixtureDir, 'toc-id'); | ||
appPort = await getPort(); | ||
app = await runDevCommand(appDir, appPort); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
if (app) { | ||
await killProcess(app); | ||
} | ||
}); | ||
|
||
test('should generate correct toc id and header anchor', async ({ page }) => { | ||
await page.goto(`http://localhost:${appPort}/`, { | ||
waitUntil: 'networkidle', | ||
}); | ||
|
||
const anchors = await page.$$('.header-anchor'); | ||
const anchorsHref = await Promise.all( | ||
anchors.map(anchor => anchor.getAttribute('href')), | ||
); | ||
expect(anchorsHref).toEqual([ | ||
'#guide', | ||
'#custom-id', | ||
'#title-2', | ||
'#title-2-1', | ||
'#title-2-2', | ||
'#title-2-3', | ||
'#title-2-4', | ||
'#title-2-5', | ||
]); | ||
|
||
const asides = await page.$$('.aside-link'); | ||
const asidesHref = await Promise.all( | ||
asides.map(aside => aside.getAttribute('href')), | ||
); | ||
expect(asidesHref).toEqual([ | ||
'#custom-id', | ||
'#title-2', | ||
'#title-2-1', | ||
'#title-2-2', | ||
'#title-2-3', | ||
'#title-2-4', | ||
'#title-2-5', | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.