Skip to content

Commit 075b75d

Browse files
committed
chore : linting fixes
1 parent ed01f7a commit 075b75d

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

blocks/feed/feed.js

+8-7
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export async function renderFeed(block) {
5151
}
5252

5353
function isImgUrl(url) {
54-
return /\.(jpg|jpeg|png|webp|avif|gif|svg)$/.test(url)
54+
return /\.(jpg|jpeg|png|webp|avif|gif|svg)$/.test(url);
5555
}
5656

5757
// logic to render blog list home page
@@ -69,11 +69,13 @@ export async function fetchBlogContent(url) {
6969
});
7070
// render images as img tags rather than linka
7171
doc.querySelectorAll('a').forEach((link) => {
72-
const url = new URL(link.href);
73-
const pathname = url.pathname;
74-
if (isImgUrl(url)) {
75-
const imgName = pathname?.substring(pathname?.lastIndexOf("/")+1, pathname?.lastIndexOf("."));
76-
const img = createTag('img', { src: pathname, alt: imgName, width: '100%', loading: 'eager' });
72+
const linkSrc = new URL(link.href);
73+
const { pathname } = linkSrc;
74+
if (isImgUrl(pathname)) {
75+
const imgName = pathname.substring(pathname.lastIndexOf('/') + 1, pathname.lastIndexOf('.'));
76+
const img = createTag('img', {
77+
src: pathname, alt: imgName, width: '100%', loading: 'eager',
78+
});
7779
link.parentElement.classList.add('image-wrapper');
7880
link.replaceWith(img);
7981
}
@@ -107,7 +109,6 @@ export async function renderBlog(block) {
107109
// eslint-disable-next-line max-len
108110
const truncatedContent = latestBlogContent.substring(0, Math.floor(latestBlogContent.length * 0.75));
109111
latestBlogItem.innerHTML = truncatedContent;
110-
111112
}
112113

113114
const readMoreButton = createTag('a', { href: latestBlog.path, class: 'read-more button primary large' }, 'Read More');

0 commit comments

Comments
 (0)