Skip to content

Commit 5e9b279

Browse files
committed
Refactor image handling in documentation and components. Updated paths for co-located images in posts, enhanced ImageCompare component to resolve paths with base URL, and added new static assets directory for Vue components.
1 parent 23afedc commit 5e9b279

4 files changed

Lines changed: 30 additions & 8 deletions

File tree

.claude/settings.local.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"Bash(mkdir:*)",
66
"Bash(for d in advanced-postprocessing anti-aliasing bindless c computeshader denoiser-and-accumulation depthoffield favoritesblog fidelityfx fluid-and-volumetric globalillumination graphicsapi lighting ltc meshlet-and-meshshader misc performance physicallybasedrendering postprocessingeffect rendergraph rtx screenspaceraytracing shadow ssao tonemapping--and--colorgrading vrs workgraphs)",
77
"Bash(do mv \"$d\" Topic/)",
8-
"Bash(done)"
8+
"Bash(done)",
9+
"WebFetch(domain:vitepress.dev)"
910
]
1011
}
1112
}

CLAUDE.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,20 @@ packages/
2929
│ └── sync-content.js # Auto-generates sidebar from posts
3030
└── content/ # Markdown content and assets
3131
├── index.md # Homepage
32+
├── public/ # Static assets (copied as-is)
33+
│ └── images/ # Images for Vue components
3234
└── posts/
3335
└── my-post/ # Each post is a folder
3436
├── index.md # Post content
35-
└── image.png # Co-located images
37+
└── image.png # Co-located images (markdown only)
3638
```
3739

3840
## Architecture Notes
3941

4042
- **Monorepo with npm workspaces**: `@blog/core` (VitePress) and `@blog/content` (markdown/images)
4143
- **srcDir**: Core's VitePress config points to `../content` as source directory
4244
- **Content sync**: `npm run sync` scans posts and updates sidebar config automatically
43-
- **Co-located images**: Each post folder contains its own images
45+
- **Co-located images**: Each post folder contains its own images for markdown use
4446
- Static site only, no SSR
4547

4648
## Adding Content
@@ -51,9 +53,23 @@ packages/
5153
4. Run `npm run sync` to update sidebar
5254
5. Optionally use frontmatter `order: N` to control sort order
5355

56+
## Image Handling
57+
58+
**Markdown images** (co-located, relative paths):
59+
```md
60+
![screenshot](./image.png)
61+
```
62+
63+
**Vue component images** (public folder, absolute paths):
64+
- Place images in `packages/content/public/images/<post-name>/`
65+
- Reference with absolute path (base URL added automatically):
66+
```md
67+
<ImageCompare before="/images/my-post/before.png" after="/images/my-post/after.png" />
68+
```
69+
5470
## Custom Components
5571

5672
Use in markdown:
5773
```md
58-
<ImageCompare before="./noisy.png" after="./denoised.png" />
74+
<ImageCompare before="/images/my-post/noisy.png" after="/images/my-post/denoised.png" />
5975
```

packages/content/posts/image-denoising/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ Image denoising removes noise from images while preserving important details.
55
## Comparison
66

77
<ImageCompare
8-
before="./noisy.png"
9-
after="./denoised.png"
8+
before="/images/image-denoising/noisy.png"
9+
after="/images/image-denoising/denoised.png"
1010
beforeLabel="Noisy"
1111
afterLabel="Denoised"
1212
/>

packages/core/.vitepress/theme/components/ImageCompare.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<script setup>
22
import { ref, computed } from 'vue'
3+
import { withBase } from 'vitepress'
34
45
const props = defineProps({
56
before: { type: String, required: true },
@@ -14,6 +15,10 @@ const container = ref(null)
1415
1516
const clipPath = computed(() => `inset(0 ${100 - position.value}% 0 0)`)
1617
18+
// Resolve paths with base URL
19+
const beforeSrc = computed(() => withBase(props.before))
20+
const afterSrc = computed(() => withBase(props.after))
21+
1722
function updatePosition(e) {
1823
if (!container.value) return
1924
const rect = container.value.getBoundingClientRect()
@@ -48,12 +53,12 @@ function stopDrag() {
4853
@touchend="stopDrag"
4954
>
5055
<!-- After image (bottom layer) -->
51-
<img class="compare-image" :src="after" :alt="afterLabel" />
56+
<img class="compare-image" :src="afterSrc" :alt="afterLabel" />
5257

5358
<!-- Before image (top layer, clipped) -->
5459
<img
5560
class="compare-image before-image"
56-
:src="before"
61+
:src="beforeSrc"
5762
:alt="beforeLabel"
5863
:style="{ clipPath }"
5964
/>

0 commit comments

Comments
 (0)