Skip to content

Commit

Permalink
Merge pull request #130 from hlxsites/feature/categories
Browse files Browse the repository at this point in the history
Added the category configuration
pardeepgera23 authored Nov 16, 2023
2 parents c5bd392 + 7392ec0 commit 427cb23
Showing 15 changed files with 47 additions and 8 deletions.
1 change: 0 additions & 1 deletion blocks/separator/separator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export default function decorate(block) {
block.innerText = '';
const separator = document.createElement('hr');
separator.className = 'outer';
block.appendChild(separator);
}
1 change: 0 additions & 1 deletion blocks/tabs/tabs.js
Original file line number Diff line number Diff line change
@@ -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');
4 changes: 4 additions & 0 deletions category/Gene/Gene.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Gene */
:root {
--primary-color: #76797f!important;
}
1 change: 1 addition & 0 deletions category/Gene/Gene.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// gene js
4 changes: 4 additions & 0 deletions category/Mrna/Mrna.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* mRNA */
:root {
--primary-color: #6f2a8e!important;
}
File renamed without changes.
4 changes: 4 additions & 0 deletions category/Plasmids/Plasmids.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Plasmids */
:root {
--primary-color: #d1222b!important;
}
File renamed without changes.
4 changes: 4 additions & 0 deletions category/Proteins/Proteins.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* Proteins */
:root {
--primary-color: #78a12e!important;
}
File renamed without changes.
31 changes: 29 additions & 2 deletions scripts/scripts.js
Original file line number Diff line number Diff line change
@@ -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);
}
2 changes: 1 addition & 1 deletion styles/Typo.css
Original file line number Diff line number Diff line change
@@ -247,7 +247,7 @@ body {

a {
background: transparent;
color: var(--primary-color);
color: #ec8f2d;
text-decoration: none;
}

1 change: 0 additions & 1 deletion templates/Plasmids/Plasmids.css

This file was deleted.

1 change: 0 additions & 1 deletion templates/Proteins/Proteins.css

This file was deleted.

1 change: 0 additions & 1 deletion templates/mRNA/mRNA.css

This file was deleted.

0 comments on commit 427cb23

Please sign in to comment.