Skip to content

Commit e4bebac

Browse files
authored
refactor: use Astro image optimization (#34)
1 parent 03accc2 commit e4bebac

25 files changed

+98
-55
lines changed

docs/CONTRIBUTING-WIKI.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The various components available for use can be found in [`src/components/common
66

77
## Article Frontmatter
88

9-
All wiki articles can contain frontmatter at the top of the file.
9+
All wiki articles must contain some frontmatter at the top of the file.
1010

1111
| Property | Type | Required | Descripion |
1212
| :-------------: | :--------: | :------: | --------------------------------------------------------------------------------------------------------------------------- |
@@ -23,3 +23,40 @@ description: Wow, my own article, cool!
2323
incomplete: true
2424
---
2525
```
26+
27+
## Images
28+
29+
The way images are handled in Astro is slightly odd, but it does come with some nice benefits.
30+
31+
### Remote Images
32+
33+
Remote images can simply be linked to like standard markdown:
34+
35+
```md
36+
![Alt text is important!](https://avatars.githubusercontent.com/u/124349233)
37+
```
38+
39+
### Local Images
40+
41+
Unless there is a good reason for an image to be [permanently and publically linkable](#public-images), images should saved to `src/assets/images/` and loaded like so:
42+
43+
```astro
44+
![A cat walking](~/assets/images/cat.png)
45+
```
46+
47+
In some rare cases, they may have to be manually imported and loaded using the `<Image>` or other component:
48+
49+
```astro
50+
import { Image } from "astro:assets";
51+
import dog from "~/assets/images/dog.png";
52+
53+
<Image src={dog} alt="A dog sitting" />
54+
```
55+
56+
### Public Images
57+
Images that need to be publically available, say for serving to other software, or for linking to other websites, need to be saved to `public/images/`. They can then be used just like [local images](#local-images), but the file path is instead relative to the public directory:
58+
59+
```diff
60+
- ![A cat walking](~/assets/images/cat.png)
61+
+ ![A cat walking](/images/cat.png)
62+
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)