Skip to content

Commit

Permalink
🔍 medium-zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
EveSunMaple committed Aug 20, 2024
1 parent 25ff1bd commit de3d071
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"astro-pagefind": "^1.6.0",
"dayjs": "^1.11.12",
"katex": "^0.16.11",
"medium-zoom": "^1.1.0",
"pagefind": "^1.1.0",
"prismjs": "^1.29.0",
"react": "^18.3.1",
Expand Down
8 changes: 8 additions & 0 deletions pnpm-lock.yaml

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

9 changes: 9 additions & 0 deletions src/pages/blog/[...slug].astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
import BaseLayout from "../../layouts/BaseLayout.astro";
import BaseCard from "../../components/BaseCard.astro";
import "medium-zoom/dist/style.css";
import { type CollectionEntry, getCollection } from "astro:content";
export async function getStaticPaths() {
Expand Down Expand Up @@ -29,3 +30,11 @@ const { Content } = await post.render();
<Content />
</BaseCard>
</BaseLayout>
<script>
import mediumZoom from "medium-zoom/dist/pure";
mediumZoom(".main-card img", { margin: 24, background: "#00000080" });

document.addEventListener("swup:page:view", () => {
mediumZoom(".main-card img", { margin: 24, background: "#00000080" });
});
</script>
4 changes: 4 additions & 0 deletions src/styles/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ a {
@apply relative no-underline;
}

.medium-zoom-image--opened {
@apply rounded-xl;
}

.main-card img {
@apply rounded-xl;
}
Expand Down

0 comments on commit de3d071

Please sign in to comment.