From 54082d201f00d264b78ec38f035b6bfc312dd45a Mon Sep 17 00:00:00 2001 From: Max Edell Date: Mon, 9 Oct 2023 14:48:09 -0700 Subject: [PATCH] fix: overflows, article img srcs, img dimensions --- blocks/article/article.js | 32 +++++++++++++++----------- blocks/card-carousel/card-carousel.css | 7 +++++- styles/styles.css | 2 +- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/blocks/article/article.js b/blocks/article/article.js index 20b6a52..d0ca075 100644 --- a/blocks/article/article.js +++ b/blocks/article/article.js @@ -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}`; + } } } } diff --git a/blocks/card-carousel/card-carousel.css b/blocks/card-carousel/card-carousel.css index 14870de..0f2efbf 100644 --- a/blocks/card-carousel/card-carousel.css +++ b/blocks/card-carousel/card-carousel.css @@ -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 { @@ -154,3 +153,9 @@ display: none; } } + +@media (max-width: 1100px) { + .card-carousel { + overflow: hidden; + } +} diff --git a/styles/styles.css b/styles/styles.css index 757b853..410d18e 100644 --- a/styles/styles.css +++ b/styles/styles.css @@ -703,7 +703,7 @@ main blockquote p::after { main picture, main img { max-width: 100%; - width: auto; + /* width: auto; */ height: auto; }