Skip to content

Commit

Permalink
feat: 이미지 확대
Browse files Browse the repository at this point in the history
  • Loading branch information
hhko committed Feb 7, 2025
1 parent 924a8f5 commit 26f5966
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 12 deletions.
18 changes: 11 additions & 7 deletions .vitepress/theme/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
import { h } from 'vue'
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import mediumZoom from 'medium-zoom';
import 'viewerjs/dist/viewer.min.css';
import imageViewer from 'vitepress-plugin-image-viewer';
import vImageViewer from 'vitepress-plugin-image-viewer/lib/vImageViewer.vue';
import { useRoute } from 'vitepress';
import './style.css'

export default {
Expand All @@ -14,11 +17,12 @@ export default {
},
enhanceApp({ app, router, siteData }) {
// ...
router.onAfterRouteChanged = () => {
mediumZoom('.main img', {
margin: 100, // 이미지와 화면의 여백 설정
background: '#000', // 확대 시 배경색
});
};
app.component('vImageViewer', vImageViewer);
},
setup() {
// Get route
const route = useRoute();
// Using
imageViewer(route);
}
} satisfies Theme
41 changes: 39 additions & 2 deletions 01-architecture/part1-overview/ch01-prerequisite/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,8 @@ npm install medium-zoom
npm list
```

- .vitepress\theme\index.ts
- `.vitepress\theme\index.ts`

```ts
import mediumZoom from 'medium-zoom';

Expand All @@ -482,7 +483,8 @@ export default {
} satisfies Theme
```

- .vitepress\theme\style.css
- `.vitepress\theme\style.css`

```css
.medium-zoom-overlay {
z-index: 1000;
Expand All @@ -493,6 +495,41 @@ export default {
}
```

```shell
# https://github.com/T-miracle/vitepress-plugin-image-viewer
npm i vitepress-plugin-image-viewer

# - `.vitepress\theme\index.ts`
// https://vitepress.dev/guide/custom-theme
import { h } from 'vue'
import type { Theme } from 'vitepress'
import DefaultTheme from 'vitepress/theme'
import 'viewerjs/dist/viewer.min.css';
import imageViewer from 'vitepress-plugin-image-viewer';
import vImageViewer from 'vitepress-plugin-image-viewer/lib/vImageViewer.vue';
import { useRoute } from 'vitepress';
import './style.css'

export default {
extends: DefaultTheme,
Layout: () => {
return h(DefaultTheme.Layout, null, {
// https://vitepress.dev/guide/extending-default-theme#layout-slots
})
},
enhanceApp({ app, router, siteData }) {
// ...
app.component('vImageViewer', vImageViewer);
},
setup() {
// Get route
const route = useRoute();
// Using
imageViewer(route);
}
} satisfies Theme
```
## Chocolately 주요 명령
```shell
#
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

## 도메인 불변 조건

![](./.images/Invariants.png)
![](./.images/Invariants.png){medium-zoom}
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"docs:preview": "vitepress preview"
},
"dependencies": {
"medium-zoom": "^1.1.0"
"vitepress-plugin-image-viewer": "^1.1.6"
}
}

0 comments on commit 26f5966

Please # to comment.