Skip to content

Commit 4505d29

Browse files
committed
docs(README): enhance README.md with examples for new string paths and alias support
1 parent 6a8a120 commit 4505d29

File tree

1 file changed

+41
-2
lines changed

1 file changed

+41
-2
lines changed

README.md

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Native extended Astro components for generating low quality image placeholders (
1313
- 🖼️ Supports both `<Image>` and `<Picture>` components.
1414
- 🎨 Multiple LQIP techniques: base64, solid color, CSS via gradients and SVG.
1515
- 🚀 Easy to use, just replace the native Astro components with the ones from [astro-lqip](https://astro-lqip.web.app/).
16+
- ⚡️ Support images as static imports or using string paths.
1617
- 🔧 Fully compatible with [Astro's image optimization features](https://docs.astro.build/en/guides/images/).
1718
- 🌍 Supports both local and remote images.
1819
- ⚙️ Supports SSR mode with [Node Adapter](https://docs.astro.build/en/guides/integrations-guide/node/).
@@ -66,9 +67,47 @@ import otherImage from './path/to/other-image.png';
6667
---
6768
6869
<Image src={image} alt="Cover Image" width={220} height={220} />
69-
<Picture src={otherImage} alt="Other cover Image" width={220} height={220} />
70+
<Picture src={otherImage} alt="Other Image" width={220} height={220} />
7071
```
7172

73+
> [!TIP]
74+
> Since version `1.6.0`, you can also put the image path as string directly in the `src` prop. Support absolute paths in `src`, relative paths and alias.
75+
76+
Example with absolute path:
77+
78+
```astro
79+
---
80+
import { Image, Picture } from 'astro-lqip/components';
81+
---
82+
83+
<Image src="/src/path/to/image.png" alt="Cover Image" width={220} height={220} />
84+
<Picture src="/src/path/to/other-image.png" alt="Other Image" width={220} height={220} />
85+
```
86+
87+
Example with relative path:
88+
89+
```astro
90+
---
91+
import { Image, Picture } from 'astro-lqip/components';
92+
---
93+
94+
<Image src="../path/to/image.png" alt="Cover Image" width={220} height={220} />
95+
<Picture src="../path/to/other-image.png" alt="Other Image" width={220} height={220} />
96+
```
97+
98+
Example with alias:
99+
100+
```astro
101+
---
102+
import { Image, Picture } from 'astro-lqip/components';
103+
---
104+
105+
<Image src="@/assets/image.png" alt="Cover Image" width={220} height={220} />
106+
<Picture src="@/assets/other-image.png" alt="Other Image" width={220} height={220} />
107+
```
108+
109+
Learn how to configure path aliasing in the [Astro documentation](https://docs.astro.build/en/guides/typescript/#import-aliases).
110+
72111
## ⚙️ Props
73112

74113
Both `<Image>` and `<Picture>` components support all the props of the [native Astro components](https://docs.astro.build/en/reference/modules/astro-assets/), but adds a couple of props for LQIP management:
@@ -94,7 +133,7 @@ import otherImage from './path/to/other-image.png';
94133
---
95134
96135
<Image src={image} alt="Cover Image" width={220} height={220} lqip="svg" lqipSize={10} />
97-
<Picture src={otherImage} alt="Other cover Image" width={220} height={220} lqip="css" lqipSize={7} />
136+
<Picture src={otherImage} alt="Other Image" width={220} height={220} lqip="css" lqipSize={7} />
98137
```
99138

100139
> [!TIP]

0 commit comments

Comments
 (0)