-
Notifications
You must be signed in to change notification settings - Fork 0
/
mag-pages.html
57 lines (42 loc) · 1006 Bytes
/
mag-pages.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<script>
const RUN_ON_HOSTED_DEMO = true;
var URL = '';
if (RUN_ON_HOSTED_DEMO){
URL = "https://demopublic.magnolia-cms.com/.rest/delivery/pagesWithComponents/v1/about/"
}else{
//Run on local demo - you must install and start a local Magnolia server.
URL = "http://localhost:8080/magnoliaPublic/.rest/delivery/pagesDemo/v1/about"
}
function listPageAreas(){
fetch(URL)
.then(function(response) {
return response.json();
})
.then(function(myJson) {
//console.log(myJson);
var html = "";
var nodes = myJson['@nodes'];
for (let node_ref of nodes){
var subnode = myJson[node_ref];
html += subnode['@path'] + '<br>';
console.log(subnode['@path']);
}
var element = document.getElementById("page-list");
element.innerHTML = html;
});
}
</script>
</head>
<body>
<h1>Page List</h1>
<div id="page-list">
</div>
<script>
listPageAreas();
</script>
</body>
</html>