-
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.
feat: Support
srcset
and sizes
for homepage image
- Loading branch information
Showing
11 changed files
with
129 additions
and
5 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,6 @@ | ||
--- | ||
"@rspress/theme-default": patch | ||
"@rspress/shared": patch | ||
--- | ||
|
||
Support `srcset` and `sizes` for homepage image |
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,25 @@ | ||
--- | ||
pageType: home | ||
hero: | ||
name: E2E case title | ||
text: E2E case subTitle | ||
tagline: E2E case tagline | ||
actions: | ||
- text: Action 1 | ||
link: /action-1 | ||
- text: Action 2 | ||
link: /action-2 | ||
theme: brand | ||
- text: External | ||
link: https://example.com/ | ||
theme: alt | ||
image: | ||
src: /brand.png | ||
alt: E2E case brand image | ||
srcset: | ||
- /brand.png | ||
- /[email protected] 2x | ||
sizes: | ||
- '((min-width: 50em) and (max-width: 60em)) 50em' | ||
- "(max-width: 30em) 20em" | ||
--- |
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,16 @@ | ||
{ | ||
"name": "@rspress-fixture/page-type-home", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"dev": "rspress dev", | ||
"build": "rspress build", | ||
"preview": "rspress preview" | ||
}, | ||
"dependencies": { | ||
"rspress": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "^14" | ||
} | ||
} |
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,6 @@ | ||
import * as path from 'path'; | ||
import { defineConfig } from 'rspress/config'; | ||
|
||
export default defineConfig({ | ||
root: path.join(__dirname, 'doc'), | ||
}); |
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 @@ | ||
{} |
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,45 @@ | ||
import path from 'path'; | ||
import { expect, test } from '@playwright/test'; | ||
import { getPort, killProcess, runDevCommand } from '../utils/runCommands'; | ||
|
||
const appDir = path.resolve(__dirname, '../fixtures/page-type-home'); | ||
|
||
test.describe('home pageType', async () => { | ||
let appPort: number; | ||
let app: unknown; | ||
test.beforeAll(async () => { | ||
appPort = await getPort(); | ||
app = await runDevCommand(appDir, appPort); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
if (app) { | ||
await killProcess(app); | ||
} | ||
}); | ||
|
||
test('Hero', async ({ page }) => { | ||
await page.goto(`http://localhost:${appPort}`); | ||
await expect(page.locator('h1').textContent()).resolves.toBe( | ||
'E2E case title', | ||
); | ||
await expect( | ||
page.locator('.rspress-home-hero-text').textContent(), | ||
).resolves.toBe('E2E case subTitle'); | ||
await expect( | ||
page.locator('.rspress-home-hero-tagline').textContent(), | ||
).resolves.toBe('E2E case tagline'); | ||
|
||
const img = page.locator('.rspress-home-hero-image img'); | ||
await expect(img.getAttribute('src')).resolves.toBe('/brand.png'); | ||
await expect(img.getAttribute('alt')).resolves.toBe('E2E case brand image'); | ||
await expect(img.getAttribute('srcset')).resolves.toBe( | ||
'/brand.png, /[email protected] 2x', | ||
); | ||
await expect(img.getAttribute('sizes')).resolves.toBe( | ||
'((min-width: 50em) and (max-width: 60em)) 50em, (max-width: 30em) 20em', | ||
); | ||
|
||
// todo: add tests for hero actions | ||
}); | ||
}); |
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
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
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
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.