diff --git a/blocks/separator/separator.js b/blocks/separator/separator.js index e6878e8f..b48afa77 100644 --- a/blocks/separator/separator.js +++ b/blocks/separator/separator.js @@ -1,6 +1,5 @@ export default function decorate(block) { block.innerText = ''; const separator = document.createElement('hr'); - separator.className = 'outer'; block.appendChild(separator); } diff --git a/blocks/tabs/tabs.js b/blocks/tabs/tabs.js index 1261fc8f..d33c06ba 100644 --- a/blocks/tabs/tabs.js +++ b/blocks/tabs/tabs.js @@ -19,7 +19,6 @@ function activeFirstElements(content) { export default function decorate(block) { const tabComponent = document.createElement('div'); tabComponent.className = 'mmg-tabs'; - tabComponent.classList.add('outer'); const ul = document.createElement('div'); ul.className = 'tablist'; const tabContent = document.createElement('div'); diff --git a/category/Gene/Gene.css b/category/Gene/Gene.css new file mode 100644 index 00000000..d5c44939 --- /dev/null +++ b/category/Gene/Gene.css @@ -0,0 +1,4 @@ +/* Gene */ +:root { + --primary-color: #76797f!important; +} \ No newline at end of file diff --git a/category/Gene/Gene.js b/category/Gene/Gene.js new file mode 100644 index 00000000..7b761048 --- /dev/null +++ b/category/Gene/Gene.js @@ -0,0 +1 @@ +// gene js diff --git a/category/Mrna/Mrna.css b/category/Mrna/Mrna.css new file mode 100644 index 00000000..73bdfc38 --- /dev/null +++ b/category/Mrna/Mrna.css @@ -0,0 +1,4 @@ +/* mRNA */ +:root { + --primary-color: #6f2a8e!important; +} diff --git a/templates/mRNA/mRNA.js b/category/Mrna/Mrna.js similarity index 100% rename from templates/mRNA/mRNA.js rename to category/Mrna/Mrna.js diff --git a/category/Plasmids/Plasmids.css b/category/Plasmids/Plasmids.css new file mode 100644 index 00000000..23f8e1b5 --- /dev/null +++ b/category/Plasmids/Plasmids.css @@ -0,0 +1,4 @@ +/* Plasmids */ +:root { + --primary-color: #d1222b!important; +} diff --git a/templates/Plasmids/Plasmids.js b/category/Plasmids/Plasmids.js similarity index 100% rename from templates/Plasmids/Plasmids.js rename to category/Plasmids/Plasmids.js diff --git a/category/Proteins/Proteins.css b/category/Proteins/Proteins.css new file mode 100644 index 00000000..dc4d0353 --- /dev/null +++ b/category/Proteins/Proteins.css @@ -0,0 +1,4 @@ +/* Proteins */ +:root { + --primary-color: #78a12e!important; +} \ No newline at end of file diff --git a/templates/Proteins/Proteins.js b/category/Proteins/Proteins.js similarity index 100% rename from templates/Proteins/Proteins.js rename to category/Proteins/Proteins.js diff --git a/scripts/scripts.js b/scripts/scripts.js index f6576c59..cc1e6e65 100644 --- a/scripts/scripts.js +++ b/scripts/scripts.js @@ -33,11 +33,15 @@ async function loadFonts() { const TEMPLATE_LIST = [ 'default', + 'blog', + 'news', +]; + +const CATEGORY_LIST = [ 'plasmids', 'proteins', 'mrna', - 'blog', - 'news', + 'gene', ]; /** @@ -62,6 +66,28 @@ async function decorateTemplates(main) { } } +/** + * Run template specific decoration code. + * @param {Element} main The container element + */ +async function decorateCategory(main) { + try { + const category = toClassName(getMetadata('category')); + const categories = CATEGORY_LIST; + if (categories.includes(category)) { + const categoryName = capitalizeWords(category); + const mod = await import(`../category/${categoryName}/${categoryName}.js`); + loadCSS(`${window.hlx.codeBasePath}/category/${categoryName}/${categoryName}.css`); + if (mod.default) { + await mod.default(main); + } + } + } catch (error) { + // eslint-disable-next-line no-console + console.error('Auto Blocking failed', error); + } +} + /** * Builds embed block for inline links to known social platforms. * @param {Element} main The container element @@ -119,6 +145,7 @@ async function loadEager(doc) { if (main) { decorateMain(main); await decorateTemplates(main); + await decorateCategory(main); document.body.classList.add('appear'); await waitForLCP(LCP_BLOCKS); } diff --git a/styles/Typo.css b/styles/Typo.css index 43fd7ebb..2073f4f8 100644 --- a/styles/Typo.css +++ b/styles/Typo.css @@ -247,7 +247,7 @@ body { a { background: transparent; - color: var(--primary-color); + color: #ec8f2d; text-decoration: none; } diff --git a/templates/Plasmids/Plasmids.css b/templates/Plasmids/Plasmids.css deleted file mode 100644 index 300c7028..00000000 --- a/templates/Plasmids/Plasmids.css +++ /dev/null @@ -1 +0,0 @@ -/* Plasmids */ diff --git a/templates/Proteins/Proteins.css b/templates/Proteins/Proteins.css deleted file mode 100644 index 4d0c4551..00000000 --- a/templates/Proteins/Proteins.css +++ /dev/null @@ -1 +0,0 @@ -/* Proteins */ \ No newline at end of file diff --git a/templates/mRNA/mRNA.css b/templates/mRNA/mRNA.css deleted file mode 100644 index 8446fca4..00000000 --- a/templates/mRNA/mRNA.css +++ /dev/null @@ -1 +0,0 @@ -/* mRNA */