Skip to content

Commit

Permalink
Add routing to mp mfe (SAP#2625)
Browse files Browse the repository at this point in the history
  • Loading branch information
hardl authored Mar 28, 2022
1 parent 319a7c1 commit c7590bc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docs/navigation-advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Luigi.setConfig({
hideAutomatically: true,
enabled: true
},
viewUrl: '/#route1/examples/microfrontends/multipurpose.html#/route2',
viewUrl: '/examples/microfrontends/multipurpose.html#/route2',
},
]
}
Expand Down
23 changes: 23 additions & 0 deletions website/fiddle/public/examples/microfrontends/multipurpose.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,34 @@
</head>

<body style="-webkit-font-smoothing: antialiased; color: #515559;">
<div id="routeCnt"></div>
<div id="imgCnt"></div>
<div id="textCnt">
<h1 id="title">Multi purpose demo page</h1>
<p id="content">Some content</p>
</div>

<script>
function navigate(route) {
if (route === '#/preload') {
document.body.style.display = 'none';
} else {
document.body.style.display = 'block';
document.getElementById('title').innerHTML = route
? `<h2>${route.replace('#/', '')}</h2>`
: '';
}
}

const navChangeLst = () => {
navigate(window.location.hash);
};
window.addEventListener('hashchange', navChangeLst);
window.addEventListener('popstate', navChangeLst);

navigate(window.location.hash);
</script>

<script>
function updateFn(context) {
if (context.title) {
Expand Down

0 comments on commit c7590bc

Please sign in to comment.