Transform dataview tables to add proper classes (#133)

This commit is contained in:
Utsob Roy 2023-04-25 23:53:19 +06:00 committed by GitHub
parent 4b93ad4e43
commit 66519a6ae1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -369,6 +369,21 @@ module.exports = function (eleventyConfig) {
t.classList.add("table-wrapper");
t.innerHTML = `<table>${inner}</table>`;
}
for (const t of parsed.querySelectorAll(
".cm-s-obsidian > .block-language-dataview > table"
)) {
t.classList.add("dataview");
t.classList.add("table-view-table");
t.querySelector("thead").classList.add("table-view-thead");
t.querySelector("tbody").classList.add("table-view-tbody");
t.querySelectorAll("thead > tr").forEach((tr) => {
tr.classList.add("table-view-tr-header");
});
t.querySelectorAll("thead > tr > th").forEach((th) => {
th.classList.add("table-view-th");
});
}
return str && parsed.innerHTML;
});