Set up bundling and move blog JS to JS file.
This commit is contained in:
parent
1b13e22bce
commit
a375a4356a
6 changed files with 15 additions and 11 deletions
28
Website/wwwroot/js/blog.js
Normal file
28
Website/wwwroot/js/blog.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
documentReady(() => {
|
||||
function adornImage(image, append) {
|
||||
var parent = image.parentNode;
|
||||
parent.removeChild(image);
|
||||
image.className = "blog-post__image-container--image";
|
||||
|
||||
var tagLine = document.createElement("span");
|
||||
tagLine.className = "blog-post__image-container--tagline";
|
||||
tagLine.innerText = image.getAttribute("alt");
|
||||
|
||||
var container = document.createElement("div");
|
||||
container.className = "blog-post__image-container";
|
||||
container.appendChild(image);
|
||||
container.appendChild(tagLine);
|
||||
|
||||
var containerContainer = document.createElement("div");
|
||||
containerContainer.className = "blog-post__image-container--container";
|
||||
containerContainer.appendChild(container);
|
||||
|
||||
if (append)
|
||||
parent.appendChild(containerContainer);
|
||||
else
|
||||
parent.prepend(containerContainer);
|
||||
}
|
||||
|
||||
document.querySelectorAll("p>img:only-child,p>img:first-child").forEach(image => adornImage(image, false));
|
||||
document.querySelectorAll("p>img:last-child").forEach(image => adornImage(image, true));
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue