post basic support
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
diff --git a/src/vite-plugin.js b/src/vite-plugin.js
|
||||
index c8ccb26b3f17cb69eb1e725bab1cde02c88c36cf..565ec235170b148017d191c62599c3968457e77e 100644
|
||||
--- a/src/vite-plugin.js
|
||||
+++ b/src/vite-plugin.js
|
||||
@@ -114,7 +114,7 @@ export function image_plugin(imagetools_plugin) {
|
||||
const image = await process_id(resolved_id, plugin_context, imagetools_plugin);
|
||||
s.update(node.start, node.end, img_to_picture(content, node, image));
|
||||
} else {
|
||||
- const metadata = await sharp(resolved_id).metadata();
|
||||
+ const metadata = await sharp(resolved_id, { animated: true }).metadata();
|
||||
// this must come after the await so that we don't hand off processing between getting
|
||||
// the imports.size and incrementing the imports.size
|
||||
const name = imports.get(original_url) || '__IMPORTED_ASSET_' + imports.size + '__';
|
||||
@@ -136,7 +136,7 @@ export function image_plugin(imagetools_plugin) {
|
||||
*/
|
||||
const pending_ast_updates = [];
|
||||
|
||||
- walk(/** @type {import('svelte/compiler').AST.TemplateNode} */ (ast), null, {
|
||||
+ walk(/** @type {import('svelte/compiler').AST.TemplateNode} */(ast), null, {
|
||||
RegularElement(node, { next }) {
|
||||
if ('name' in node && node.name === 'enhanced:img') {
|
||||
// Compare node tag match
|
||||
@@ -231,7 +231,7 @@ export function parse_object(str) {
|
||||
function get_attr_value(node, attr) {
|
||||
if (!('type' in node) || !('attributes' in node)) return;
|
||||
const attribute = node.attributes.find(
|
||||
- /** @param {any} v */ (v) => v.type === 'Attribute' && v.name === attr
|
||||
+ /** @param {any} v */(v) => v.type === 'Attribute' && v.name === attr
|
||||
);
|
||||
|
||||
if (!attribute || !('value' in attribute) || typeof attribute.value === 'boolean') return;
|
||||
@@ -376,8 +376,8 @@ function dynamic_img_to_picture(content, node, src_var_name) {
|
||||
{${src_var_name}} was not enhanced. Cannot determine dimensions.
|
||||
{:else}
|
||||
<img ${serialize_img_attributes(content, attributes, {
|
||||
- src: `{${src_var_name}}`
|
||||
- })} />
|
||||
+ src: `{${src_var_name}}`
|
||||
+ })} />
|
||||
{/if}
|
||||
{:else}
|
||||
<picture>
|
||||
@@ -385,10 +385,10 @@ function dynamic_img_to_picture(content, node, src_var_name) {
|
||||
<source {srcset}${sizes_string} type={'image/' + format} />
|
||||
{/each}
|
||||
<img ${serialize_img_attributes(content, attributes, {
|
||||
- src: `{${src_var_name}.img.src}`,
|
||||
- width: `{${src_var_name}.img.w}`,
|
||||
- height: `{${src_var_name}.img.h}`
|
||||
- })} />
|
||||
+ src: `{${src_var_name}.img.src}`,
|
||||
+ width: `{${src_var_name}.img.w}`,
|
||||
+ height: `{${src_var_name}.img.h}`
|
||||
+ })} />
|
||||
</picture>
|
||||
{/if}`;
|
||||
}
|
||||
Reference in New Issue
Block a user