categories-page #44
2
dist/blog/js/index.js
vendored
2
dist/blog/js/index.js
vendored
File diff suppressed because one or more lines are too long
@ -376,9 +376,33 @@ async function loadIndividualPost(title)
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadAllCategories()
|
/**
|
||||||
|
* Loads all the categories
|
||||||
|
*/
|
||||||
|
async function loadAllCategories()
|
||||||
{
|
{
|
||||||
|
document.title = 'Rohit Pai - Categories';
|
||||||
|
let categoriesList = await getCategories();
|
||||||
|
let main = document.querySelector('#main');
|
||||||
|
let categories = document.createElement('section');
|
||||||
|
categories.classList.add('categories');
|
||||||
|
categories.id = 'allCategories';
|
||||||
|
let h1 = document.createElement('h1');
|
||||||
|
h1.innerHTML = 'Categories';
|
||||||
|
main.appendChild(h1);
|
||||||
|
for (let category of categoriesList)
|
||||||
|
{
|
||||||
|
let btnContainer = document.createElement('div');
|
||||||
|
btnContainer.classList.add('btnContainer');
|
||||||
|
let btn = document.createElement('a');
|
||||||
|
btn.classList.add('btn');
|
||||||
|
btn.classList.add('btnPrimary');
|
||||||
|
btn.innerHTML = category;
|
||||||
|
btn.href = `/blog/category/${category}`;
|
||||||
|
btnContainer.appendChild(btn);
|
||||||
|
categories.appendChild(btnContainer);
|
||||||
|
}
|
||||||
|
main.appendChild(categories);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user