Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RFC "A core story for images" #6344

Merged
merged 113 commits into from
Mar 7, 2023
Merged
Changes from 1 commit
Commits
Show all changes
113 commits
Select commit Hold shift + click to select a range
d714a7a
feat(assets): Add Vite plugin
Princesseuh Jan 31, 2023
1f7c4a9
feat(images): Set up Image component
Princesseuh Feb 3, 2023
21416d0
Merge branch 'main' into feat/images
Princesseuh Feb 3, 2023
af1bc13
Merge branch 'main' into feat/images
Princesseuh Feb 3, 2023
063aa27
fix(types): Attempt to fix type generation
Princesseuh Feb 3, 2023
25fc671
Revert "fix(types): Attempt to fix type generation"
Princesseuh Feb 3, 2023
bf0dfff
fix(image): Fix image types causing build to fail
Princesseuh Feb 6, 2023
f2a69bd
feat(image): Implement client side part
Princesseuh Feb 10, 2023
e5ca26e
feat(services): Allow arbitrary transforms parameters
Princesseuh Feb 13, 2023
1a9d939
fix(image): Fix paths and types
Princesseuh Feb 13, 2023
848d326
config(types): Update config types to provide completions for availab…
Princesseuh Feb 13, 2023
02295be
feat(image): Add serving in dev
Princesseuh Feb 14, 2023
bca6ebe
feat(image): Improve type error messages
Princesseuh Feb 14, 2023
b0f4dd0
refactor(image): Move sharp's parseParams to baseService
Princesseuh Feb 14, 2023
7e95c5b
refactor(image): Skip work in dev for remote servies
Princesseuh Feb 14, 2023
633a4d8
feat(image): Add support for remote images
Princesseuh Feb 15, 2023
110c56a
feat(image): Add squoosh service
Princesseuh Feb 16, 2023
cf0bc4e
chore: update export map
Princesseuh Feb 16, 2023
07f2b2e
refactor(image): Abstract attributes handling by services
Princesseuh Feb 16, 2023
092c348
config(vercel): Remove test image service
Princesseuh Feb 16, 2023
3b0d49c
feat(image): Support for relative images in Markdown (WIP)
Princesseuh Feb 16, 2023
1a0ea86
feat(images): Add support for relative images in Markdown
Princesseuh Feb 17, 2023
308a850
feat(image): Update with RFC feedback
Princesseuh Feb 23, 2023
23ac7a4
fix(image): Fix alt error on getImage
Princesseuh Feb 23, 2023
3f85ccd
feat(image): Add support for assets validation through content collec…
Princesseuh Feb 23, 2023
aac6bfc
feat(image): Remove validateTransform
Princesseuh Feb 23, 2023
ef92cca
feat(image): Move to assets folder
Princesseuh Feb 23, 2023
2614cfa
fix(image): Fix package exports
Princesseuh Feb 23, 2023
6e8c795
feat(image): Add static imports references to virtual moduel
Princesseuh Feb 23, 2023
b75cd2f
fix(image): Fix images from content collections not working when embe…
Princesseuh Feb 23, 2023
e872d8d
Merge branch 'main' into feat/images
Princesseuh Feb 23, 2023
3753445
chore: lockfile
Princesseuh Feb 23, 2023
544d6ce
fix(markdown): Fix type
Princesseuh Feb 23, 2023
b7d6f68
fix(images): Flag enhanced images behing an experimental flag
Princesseuh Feb 23, 2023
b15b666
Merge branch 'main' into feat/images
Princesseuh Feb 23, 2023
4f0cf02
config(example): Update images example conifg
Princesseuh Feb 23, 2023
08c4240
Merge branch 'main' into feat/images
Princesseuh Feb 24, 2023
52a4388
fix(image): Fix types
Princesseuh Feb 24, 2023
cf2da10
fix(image): Fix asset type for strict, allow arbritary input and outp…
Princesseuh Feb 27, 2023
87fbfc7
chore: fix example check
Princesseuh Feb 27, 2023
5f0463b
feat(image): Emit assets for ESM imported images
Princesseuh Feb 27, 2023
33238d4
Merge branch 'main' into feat/images
Princesseuh Feb 28, 2023
406eff6
Add initial core image tests (#6381)
matthewp Feb 28, 2023
4c92818
feat(images): Make frontmatter extraction more generic than images fo…
Princesseuh Feb 28, 2023
7eb51b4
feat(image): Add support for building
Princesseuh Feb 28, 2023
d1da8e2
fix(image): Fix types
Princesseuh Feb 28, 2023
0cdf5d7
fix(images): Fix compatibility with image integration
Princesseuh Feb 28, 2023
9dc6a56
feat(images): Cuter generation stats
Princesseuh Feb 28, 2023
6bb2e34
fix(images): Globals are unsafe, it turns out
Princesseuh Feb 28, 2023
e908862
fix(images): Only generate images if flag is enabled
Princesseuh Feb 28, 2023
57ae057
fix(images): Only create `addStaticImage` in build
Princesseuh Feb 28, 2023
dc87411
feat(images): Add SSR endpoint
Princesseuh Feb 28, 2023
3932c73
fix(images): Only inject route in SSR
Princesseuh Feb 28, 2023
2aec7ef
Add tests for SSR
matthewp Feb 28, 2023
baa44ae
Remove console.log
matthewp Feb 28, 2023
9526d1c
Updated lockfile
matthewp Feb 28, 2023
57a8e0e
rename to satisfy the link gods
matthewp Feb 28, 2023
8446fb3
skip build tests for now
matthewp Feb 28, 2023
4256bb5
fix(images): Fix WASM files not being copied in dev
Princesseuh Mar 1, 2023
6108458
Merge branch 'main' into feat/images
Princesseuh Mar 1, 2023
46e319b
feat(images): Add quality presets
Princesseuh Mar 1, 2023
acd56b1
fix build tests running
matthewp Mar 1, 2023
49da47c
Remove console.log
matthewp Mar 1, 2023
fab176b
Add tests for getImage
matthewp Mar 1, 2023
46d5ae2
Test local services
matthewp Mar 1, 2023
051798e
Test the content collections API
matthewp Mar 1, 2023
cdc77e2
Add tests for quality
matthewp Mar 1, 2023
caa2900
Skipping content collections test
matthewp Mar 1, 2023
b86c995
feat(image): Add support for `~/assets` alias
Princesseuh Mar 2, 2023
f29be13
test(image): Add tests for aliases in dev
Princesseuh Mar 2, 2023
f919012
Fix windows + content collections
matthewp Mar 2, 2023
15538fe
test(image): Add tests for aliased images and images in Markdown
Princesseuh Mar 2, 2023
eb20571
Fix markdown images being built
matthewp Mar 2, 2023
7ef6b27
Should be posix join
matthewp Mar 2, 2023
1ed8652
Use the optimized image
matthewp Mar 2, 2023
abb72a0
fix test
matthewp Mar 2, 2023
309dcee
Fixes windows smoke
matthewp Mar 2, 2023
87a0d6a
fix(image): Nits
Princesseuh Mar 3, 2023
4db291a
Merge branch 'main' into feat/images
Princesseuh Mar 3, 2023
edc007d
feat(images): Add automatic update for `env.d.ts` when experimental i…
Princesseuh Mar 3, 2023
f67e6c4
fix(images): Revert env.d.ts change if the user opted-out of the expe…
Princesseuh Mar 3, 2023
6bc4ce9
chore: remove bad image example project
Princesseuh Mar 3, 2023
b620671
feat(image): Rename `experimental.images` to `experimental.assets`
Princesseuh Mar 3, 2023
c88a998
fix(images): Remove unused code in MDX integration
Princesseuh Mar 3, 2023
e606a5f
chore: Remove unrelated change
Princesseuh Mar 3, 2023
3ba14ab
fix(images): Remove export from astro/components
Princesseuh Mar 3, 2023
e0fa179
Fix, esm import on Win
matthewp Mar 3, 2023
252cea8
test(images): Add test for format
Princesseuh Mar 3, 2023
d5560e2
Merge branch 'main' into feat/images
Princesseuh Mar 3, 2023
ad701ad
fix(images): Add `client-image.d.ts` to export map
Princesseuh Mar 3, 2023
aacfe61
chore: changeset
Princesseuh Mar 3, 2023
a87c7a7
fix(images): Adjust with feedback, no more automatic refine, asset() …
Princesseuh Mar 6, 2023
13a9974
fix(images): Fix types
Princesseuh Mar 6, 2023
c57a47d
fix(images): Remove unnecessary spread
Princesseuh Mar 6, 2023
0414d49
fix(images): Better types for parseUrl and transform
Princesseuh Mar 6, 2023
be5d6e5
fix(images): Fix types
Princesseuh Mar 6, 2023
7fd3eda
Merge branch 'main' into feat/images
Princesseuh Mar 6, 2023
2d54346
fix(images): Adjust from feedback
Princesseuh Mar 7, 2023
ad7a15e
fix(images): Pass width and height through getHTMLAttributes even if …
Princesseuh Mar 7, 2023
2f38e34
Merge branch 'main' into feat/images
Princesseuh Mar 7, 2023
a124a71
fix(images): Recusirsively extract frontmatter assets
Princesseuh Mar 7, 2023
84c4997
fix(images): Use a reduce instead
Princesseuh Mar 7, 2023
c1299d3
feat(images): Add support for data: URIs
Princesseuh Mar 7, 2023
8c13a6b
chore: changeset
Princesseuh Mar 7, 2023
1f7d910
docs(images): Misc docs fixes
Princesseuh Mar 7, 2023
9b53c92
Update .changeset/gold-rocks-cry.md
Princesseuh Mar 7, 2023
97f0cdd
Update .changeset/gold-rocks-cry.md
Princesseuh Mar 7, 2023
93acb22
Update packages/astro/src/@types/astro.ts
Princesseuh Mar 7, 2023
516493b
Update packages/astro/src/assets/services/service.ts
Princesseuh Mar 7, 2023
7404291
Update packages/astro/src/assets/services/service.ts
Princesseuh Mar 7, 2023
b7f9f9c
Update packages/astro/src/assets/services/service.ts
Princesseuh Mar 7, 2023
5f5a06c
Update packages/astro/src/assets/types.ts
Princesseuh Mar 7, 2023
c912ffb
Update packages/astro/src/assets/types.ts
Princesseuh Mar 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions packages/astro/src/content/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
import { ErrorPayload as ViteErrorPayload, normalizePath, ViteDevServer } from 'vite';
import { z } from 'zod';
import { AstroConfig, AstroSettings } from '../@types/astro.js';
import type { ImageMetadata } from '../assets/types.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { contentFileExts, CONTENT_TYPES_FILE } from './consts.js';

Expand Down Expand Up @@ -50,11 +51,19 @@ export const msg = {
};

export function extractFrontmatterAssets(data: Record<string, any>): string[] {
const assets = Object.values(data).filter(
(value) => typeof value === 'object' && value['__astro_asset'] == true
);
function findAssets(potentialAssets: Record<string, any>): ImageMetadata[] {
return Object.values(potentialAssets).map((entry: any) => {
if (typeof entry === 'object') {
if (entry.__astro === true) {
return entry;
} else {
return findAssets(entry);
}
}
Princesseuh marked this conversation as resolved.
Show resolved Hide resolved
});
}

return assets.map((asset) => asset.src);
return findAssets(data).map((asset) => asset.src);
}

export function getEntrySlug({
Expand Down