Skip to content

Commit

Permalink
Merge branch 'main' of github.com:adobe/aem-boilerplate
Browse files Browse the repository at this point in the history
  • Loading branch information
herzog31 committed Apr 17, 2024
2 parents 84e2449 + 1043b03 commit 1dfe176
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
7 changes: 3 additions & 4 deletions blocks/footer/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ import { loadFragment } from '../fragment/fragment.js';
* @param {Element} block The footer block element
*/
export default async function decorate(block) {
// load footer as fragment
const footerMeta = getMetadata('footer');
block.textContent = '';

// load footer fragment
const footerPath = footerMeta.footer || '/footer';
const footerPath = footerMeta ? new URL(footerMeta, window.location).pathname : '/footer';
const fragment = await loadFragment(footerPath);

// decorate footer DOM
block.textContent = '';
const footer = document.createElement('div');
while (fragment.firstElementChild) footer.append(fragment.firstElementChild);

Expand Down
5 changes: 3 additions & 2 deletions blocks/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,17 @@ function toggleMenu(nav, navSections, forceExpanded = null) {
}

/**
* decorates the header, mainly the nav
* loads and decorates the header, mainly the nav
* @param {Element} block The header block element
*/
export default async function decorate(block) {
// load nav as fragment
const navMeta = getMetadata('nav');
const navPath = navMeta ? new URL(navMeta).pathname : '/nav';
const navPath = navMeta ? new URL(navMeta, window.location).pathname : '/nav';
const fragment = await loadFragment(navPath);

// decorate nav DOM
block.textContent = '';
const nav = document.createElement('nav');
nav.id = 'nav';
while (fragment.firstElementChild) nav.append(fragment.firstElementChild);
Expand Down

0 comments on commit 1dfe176

Please sign in to comment.