Skip to content

Commit 1dfe176

Browse files
committed
Merge branch 'main' of github.com:adobe/aem-boilerplate
2 parents 84e2449 + 1043b03 commit 1dfe176

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

blocks/footer/footer.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import { loadFragment } from '../fragment/fragment.js';
66
* @param {Element} block The footer block element
77
*/
88
export default async function decorate(block) {
9+
// load footer as fragment
910
const footerMeta = getMetadata('footer');
10-
block.textContent = '';
11-
12-
// load footer fragment
13-
const footerPath = footerMeta.footer || '/footer';
11+
const footerPath = footerMeta ? new URL(footerMeta, window.location).pathname : '/footer';
1412
const fragment = await loadFragment(footerPath);
1513

1614
// decorate footer DOM
15+
block.textContent = '';
1716
const footer = document.createElement('div');
1817
while (fragment.firstElementChild) footer.append(fragment.firstElementChild);
1918

blocks/header/header.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,17 @@ function toggleMenu(nav, navSections, forceExpanded = null) {
8888
}
8989

9090
/**
91-
* decorates the header, mainly the nav
91+
* loads and decorates the header, mainly the nav
9292
* @param {Element} block The header block element
9393
*/
9494
export default async function decorate(block) {
9595
// load nav as fragment
9696
const navMeta = getMetadata('nav');
97-
const navPath = navMeta ? new URL(navMeta).pathname : '/nav';
97+
const navPath = navMeta ? new URL(navMeta, window.location).pathname : '/nav';
9898
const fragment = await loadFragment(navPath);
9999

100100
// decorate nav DOM
101+
block.textContent = '';
101102
const nav = document.createElement('nav');
102103
nav.id = 'nav';
103104
while (fragment.firstElementChild) nav.append(fragment.firstElementChild);

0 commit comments

Comments
 (0)