Skip to content

Commit

Permalink
Style blog post pages and autoblocking
Browse files Browse the repository at this point in the history
  • Loading branch information
herzog31 committed Nov 23, 2023
1 parent cabd682 commit 5b25a3f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
helix-importer-ui

/scripts/alloy*.js
/tools/actions/
/tools/actions/
/tools/importer
27 changes: 26 additions & 1 deletion scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,38 @@ function buildHeroBlock(main) {
}
}

function buildBlockPostPage(main) {
// Below h1
const h1 = main.querySelector('h1');
const socialMediaButtons = document.createRange().createContextualFragment('<div class="sharing">Sharing Block Placeholder</div>');
if (h1) {
h1.parentElement.insertBefore(socialMediaButtons.cloneNode(true), h1.nextSibling);
}

// Below last content
const lastContentSection = main.querySelector('* > div:last-of-type');
if (lastContentSection) {
lastContentSection.appendChild(socialMediaButtons.cloneNode(true));

const lostPetTeaser = document.createRange().createContextualFragment('<div class="lost-pet-teaser">Lost Pet Teaser Block Placeholder</div>');
lastContentSection.appendChild(lostPetTeaser);

const similarBlogs = document.createRange().createContextualFragment('<div class="similar-blogs">Similar Blogs Block Placeholder</div>');
lastContentSection.appendChild(similarBlogs);
}
}

/**
* Builds all synthetic blocks in a container element.
* @param {Element} main The container element
*/
function buildAutoBlocks(main) {
try {
buildHeroBlock(main);
if (!document.body.classList.contains('blog-post')) {
buildHeroBlock(main);
} else {
buildBlockPostPage(main);
}
} catch (error) {
// eslint-disable-next-line no-console
console.error('Auto Blocking failed', error);
Expand Down
21 changes: 21 additions & 0 deletions styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,27 @@ main .section.highlight p {
margin-bottom: 0;
}

/* Blog post styles */
body.blog-post main h1, body.blog-post main h2, body.blog-post main h3 {
text-align: left;
}

body.blog-post main h1 {
font-size: 2.1875rem;
line-height: 2.813rem;
font-weight: 300;
}

body.blog-post main h2 {
font-size: 1.625rem;
line-height: 2.25rem;
}

body.blog-post .default-content-wrapper {
font-size: 1.125rem;
padding: 0 0.9375rem;
}

main .section.highlight p em {
display: block;
font-size: 2.5rem;
Expand Down

0 comments on commit 5b25a3f

Please sign in to comment.