-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(image): throw if alt text is missing (#4511)
* feat(image): throw if no `alt` is provided * chore: add changeset * docs(image): update README * updated alt text stuff throughout * fixing with-mdx test suite * warn for missing alt text, will throw an error in a future release * final README tweaks Co-authored-by: Tony Sullivan <tony.f.sullivan@outlook.com> Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
- Loading branch information
1 parent
df402dd
commit 72c760e
Showing
25 changed files
with
391 additions
and
50 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 @@ | ||
--- | ||
'@astrojs/image': minor | ||
--- | ||
|
||
feat: throw if alt text is missing |
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
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
8 changes: 8 additions & 0 deletions
8
packages/integrations/image/test/fixtures/no-alt-text-image/astro.config.mjs
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,8 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import image from '@astrojs/image'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
site: 'http://localhost:3000', | ||
integrations: [image({ logLevel: 'silent' })] | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/integrations/image/test/fixtures/no-alt-text-image/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@test/no-alt-text-image", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/image": "workspace:*", | ||
"@astrojs/node": "workspace:*", | ||
"astro": "workspace:*" | ||
} | ||
} |
Binary file added
BIN
+4.19 KB
packages/integrations/image/test/fixtures/no-alt-text-image/public/favicon.ico
Binary file not shown.
44 changes: 44 additions & 0 deletions
44
packages/integrations/image/test/fixtures/no-alt-text-image/server/server.mjs
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,44 @@ | ||
import { createServer } from 'http'; | ||
import fs from 'fs'; | ||
import mime from 'mime'; | ||
import { handler as ssrHandler } from '../dist/server/entry.mjs'; | ||
|
||
const clientRoot = new URL('../dist/client/', import.meta.url); | ||
|
||
async function handle(req, res) { | ||
ssrHandler(req, res, async (err) => { | ||
if (err) { | ||
res.writeHead(500); | ||
res.end(err.stack); | ||
return; | ||
} | ||
|
||
let local = new URL('.' + req.url, clientRoot); | ||
try { | ||
const data = await fs.promises.readFile(local); | ||
res.writeHead(200, { | ||
'Content-Type': mime.getType(req.url), | ||
}); | ||
res.end(data); | ||
} catch { | ||
res.writeHead(404); | ||
res.end(); | ||
} | ||
}); | ||
} | ||
|
||
const server = createServer((req, res) => { | ||
handle(req, res).catch((err) => { | ||
console.error(err); | ||
res.writeHead(500, { | ||
'Content-Type': 'text/plain', | ||
}); | ||
res.end(err.toString()); | ||
}); | ||
}); | ||
|
||
server.listen(8085); | ||
console.log('Serving at http://localhost:8085'); | ||
|
||
// Silence weird <time> warning | ||
console.error = () => {}; |
Binary file added
BIN
+24.7 KB
packages/integrations/image/test/fixtures/no-alt-text-image/src/assets/social.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions
13
packages/integrations/image/test/fixtures/no-alt-text-image/src/pages/index.astro
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,13 @@ | ||
--- | ||
import socialJpg from '../assets/social.jpg'; | ||
import { Image } from '@astrojs/image/components'; | ||
--- | ||
|
||
<html> | ||
<head> | ||
<!-- Head Stuff --> | ||
</head> | ||
<body> | ||
<Image id="social-jpg" src={socialJpg} width={506} height={253} /> | ||
</body> | ||
</html> |
8 changes: 8 additions & 0 deletions
8
packages/integrations/image/test/fixtures/no-alt-text-picture/astro.config.mjs
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,8 @@ | ||
import { defineConfig } from 'astro/config'; | ||
import image from '@astrojs/image'; | ||
|
||
// https://astro.build/config | ||
export default defineConfig({ | ||
site: 'http://localhost:3000', | ||
integrations: [image({ logLevel: 'silent' })] | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/integrations/image/test/fixtures/no-alt-text-picture/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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "@test/no-alt-text-picture", | ||
"version": "0.0.0", | ||
"private": true, | ||
"dependencies": { | ||
"@astrojs/image": "workspace:*", | ||
"@astrojs/node": "workspace:*", | ||
"astro": "workspace:*" | ||
} | ||
} |
Binary file added
BIN
+4.19 KB
packages/integrations/image/test/fixtures/no-alt-text-picture/public/favicon.ico
Binary file not shown.
Oops, something went wrong.