Skip to content

Commit

Permalink
fix: overflows, article img srcs, img dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
maxakuru committed Oct 9, 2023
1 parent e968743 commit 54082d2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
32 changes: 18 additions & 14 deletions blocks/article/article.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,21 +414,25 @@ async function renderContent(block, res, rerender = false) {
}

// Fixup images src
for (const image of article.querySelectorAll('img')) {
const imageURL = new URL(image.src);

if (store.branch) {
setBranch(imageURL, store.branch);
image.src = imageURL.toString();
} else {
image.src = `${store.docsOrigin}${imageURL.pathname}`;
}
if (!isGdoc) {
for (const image of article.querySelectorAll('img')) {
const imageURL = new URL(image.src);

if (store.branch) {
setBranch(imageURL, store.branch);
image.src = imageURL.toString();
} else {
// add /docs/ prefix if missing
const path = imageURL.pathname.startsWith('/docs/') ? imageURL.pathname : `/docs/${imageURL.pathname}`;
image.src = `${store.docsOrigin}${path}${imageURL.search}`;
}

const picture = image.parentElement;
if (picture.tagName === 'PICTURE') {
for (const source of picture.querySelectorAll('source')) {
const search = source.srcset.split('?')[1];
source.srcset = `${image.src}?${search}`;
const picture = image.parentElement;
if (picture.tagName === 'PICTURE') {
for (const source of picture.querySelectorAll('source')) {
const search = source.srcset.split('?')[1];
source.srcset = `${image.src}?${search}`;
}
}
}
}
Expand Down
7 changes: 6 additions & 1 deletion blocks/card-carousel/card-carousel.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
margin: 0 auto;
max-width: calc(1032px + var(--padding--mobile) + var(--padding--mobile));
padding: var(--padding--mobile);
overflow: hidden;
}

.card-carousel .splide__track {
Expand Down Expand Up @@ -154,3 +153,9 @@
display: none;
}
}

@media (max-width: 1100px) {
.card-carousel {
overflow: hidden;
}
}
2 changes: 1 addition & 1 deletion styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ main blockquote p::after {
main picture,
main img {
max-width: 100%;
width: auto;
/* width: auto; */
height: auto;
}

Expand Down

0 comments on commit 54082d2

Please sign in to comment.