Skip to content

Commit

Permalink
Fix GitHub Buld actions warnings take 2.
Browse files Browse the repository at this point in the history
  • Loading branch information
codecodeio committed May 10, 2024
1 parent a6f252e commit cc57c79
Showing 1 changed file with 35 additions and 35 deletions.
70 changes: 35 additions & 35 deletions best-cigars-guide/blocks/article-list/article-list.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { createOptimizedPicture } from './../scripts/aem.js';
import { createOptimizedPicture } from "../../scripts/aem.js";

Check failure on line 1 in best-cigars-guide/blocks/article-list/article-list.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote

export default function decorate(block) {
//Add nav
//@todo sytle the nav
const mainTag = document.querySelector('.article-list-container');
const navDiv = document.createElement('div');
navDiv.className = 'nav-row';
// Add nav
// @todo sytle the nav
const mainTag = document.querySelector(".article-list-container");

Check failure on line 6 in best-cigars-guide/blocks/article-list/article-list.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
const navDiv = document.createElement("div");

Check failure on line 7 in best-cigars-guide/blocks/article-list/article-list.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
navDiv.className = "nav-row";

Check failure on line 8 in best-cigars-guide/blocks/article-list/article-list.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
mainTag.prepend(navDiv);

//Add breadcrumbs
//@todo style breadcrumbs
const h1 = document.querySelector('h1');
// Add breadcrumbs
// @todo style breadcrumbs
const h1 = document.querySelector("h1");

Check failure on line 13 in best-cigars-guide/blocks/article-list/article-list.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
const h1Text = h1.textContent.trim();

const breadcrumbDiv = document.createElement('div');
breadcrumbDiv.className = 'breadcrumb';
const breadcrumbDiv = document.createElement("div");

Check failure on line 16 in best-cigars-guide/blocks/article-list/article-list.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
breadcrumbDiv.className = "breadcrumb";

Check failure on line 17 in best-cigars-guide/blocks/article-list/article-list.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
breadcrumbDiv.innerHTML += `
<p id="breadcrumbs">
<span><a href="https://www.famous-smoke.com/best-cigars-guide/">Home</a></span> » <span class="breadcrumb_last" aria-current="page">${h1Text}</span>
</p>
`;
navDiv.append(breadcrumbDiv);

//Add dropdown list (copied from existing site)
//@todo build list dynamically and style it
//Add dropdown list (copied from existing site)

Check failure on line 25 in best-cigars-guide/blocks/article-list/article-list.js

View workflow job for this annotation

GitHub Actions / build

Expected exception block, space or tab after '//' in comment
//@todo build list dynamically and style it

Check failure on line 26 in best-cigars-guide/blocks/article-list/article-list.js

View workflow job for this annotation

GitHub Actions / build

Expected exception block, space or tab after '//' in comment
const dropdownListDiv = document.createElement("div");

Check failure on line 27 in best-cigars-guide/blocks/article-list/article-list.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
breadcrumbDiv.className = 'category-dropdown';
breadcrumbDiv.className = "category-dropdown";
dropdownListDiv.innerHTML += `
<form action="https://www.famous-smoke.com/best-cigars-guide/" method="get" class="dropcats">
<select name="cat" id="cat" class="postform" onchange="return this.form.submit()">
Expand All @@ -42,27 +42,27 @@ export default function decorate(block) {
`;
navDiv.append(dropdownListDiv);

//Add Article list
// Add Article list
/* change to ul, li */
const ul = document.createElement("ul");
//loop over each row of import file
// loop over each row of import file
[...block.children].forEach((row) => {
const li = document.createElement("li");
//For each row child, a new <li> is created.
// For each row child, a new <li> is created.
while (row.firstElementChild) li.append(row.firstElementChild);

// Find the last div and extract the href from its link
// Find the last div and extract the href from its link
const lastDiv = li.querySelector("div:last-child");
const link = lastDiv ? lastDiv.querySelector("a") : null;
const href = link ? link.href : "#"; // Default to '#' if no link is found
const href = link ? link.href : "#"; // Default to '#' if no link is found

// The second div contains the title for links and buttons
const secondDiv = li.children[1]; // direct access to the second child assuming it's a div
const title = secondDiv ? secondDiv.textContent.trim() : ""; // Get the text content as title
// The second div contains the title for links and buttons
const secondDiv = li.children[1]; // direct access to the second child assuming it's a div
const title = secondDiv ? secondDiv.textContent.trim() : ""; // Get the text content as title

//loop over each li
// loop over each li
[...li.children].forEach((div) => {
//first div is for the article image
// first div is for the article image
if (div.querySelector("picture")) {
div.className = "article-list-card-image";
const picture = div.querySelector("picture");
Expand All @@ -74,36 +74,36 @@ export default function decorate(block) {
anchor.appendChild(picture);
}
}
//second div is for the article body
// second div is for the article body
else if (
!div.querySelector("picture") &&
li.querySelector(".article-list-card-body") === null
) {
div.className = "article-list-card-body";
}
//remaining divs are appended to prior article body div
}
// remaining divs are appended to prior article body div
else {
div.previousSibling.append(div.firstElementChild);
// Set class names for the first and second paragraphs within the article-list-card-body
// Set class names for the first and second paragraphs within the article-list-card-body
const paragraphs = div.previousSibling.querySelectorAll("p");
// First paragraph as article-title
// First paragraph as article-title
if (paragraphs.length > 0) {
//change article title to an h3
//change article title to an h3
const h3 = document.createElement("h3");
h3.className = "article-title";
h3.textContent = paragraphs[0].textContent;
div.previousSibling.replaceChild(h3, paragraphs[0]);
}
// Second paragraph as article-description
// Second paragraph as article-description
if (paragraphs.length > 1) {
paragraphs[1].className = "article-description";
paragraphs[1].className = "article-description";
}
}

// Create and append a new div with a button
// Create and append a new div with a button
if (!li.querySelector("a.button")) {
const newDiv = document.createElement("div");
newDiv.className = 'article-button-container';
newDiv.className = "article-button-container";
const newLink = document.createElement("a");
newLink.href = href;
newLink.className = "button";
Expand All @@ -123,7 +123,7 @@ export default function decorate(block) {
}
});

//optimize images
// optimize images
ul.querySelectorAll("img").forEach((img) =>
img
.closest("picture")
Expand Down

0 comments on commit cc57c79

Please sign in to comment.