Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const config = {
contextualSearch: true,
}
: undefined,
zoomSelector: ".markdown img",
zoomSelector: ".markdown :not(em) > img:not(.no-zoom)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's em?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am emphasis (<em>) tag. This selector is a little tricky, as it is designed to handle two separate cases in which we don't want zoom.

  1. The first is the :not(em) bit, which is a standard approach to preventing image zoom documented in some of the zoom plugins. It enables one to wrap the Markdown image syntax in underscores (_) to trigger an emphasis (<em>) wrapper, which thus makes this selector fail.
  2. The second adds an explicit .no-zoom class that we can add to images where we aren't specifying them in Markdown. I could have just added an <em> wrapper in React, but the classname seemed cleaner in that context.

The selector here essentially says, select an image for which neither of the above are true. That is, if it's wrapped in emphasis or has the .no-zoom class, the selector won't apply.

posthog: enablePosthog
? {
apiKey: posthogConfig.apiKey,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Course.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Course: React.FunctionComponent<CourseProps> = ({
<Card title={title} icon={icon} href={href}>
<p>{description}</p>
<p className={styles.author}>
<img src={authorImg} />
<img src={authorImg} className="no-zoom" />
<span>{author}</span>
</p>
<p>
Expand Down
4 changes: 2 additions & 2 deletions src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ main {

/* IMAGES & CAPTIONS */

p > img {
p > img:not(.no-zoom) {
display: block;
margin: auto;
}

p > img + em {
p > img:not(.no-zoom) + em {
color: gray;
font-size: 0.9rem;
display: block;
Expand Down