index.html 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Lee Morgan</title>
  6. <link rel="stylesheet" href="/travel/style">
  7. </head>
  8. <body>
  9. <h1 id="title"></h1>
  10. <div id="images"></div>
  11. <script>
  12. let path = window.location.pathname
  13. .split("/")
  14. .slice(2)
  15. .join("/");
  16. fetch(`/travel/images/${path}`)
  17. .then(response => response.json())
  18. .then((response)=>{
  19. let container = document.getElementById("images");
  20. for(let i = 0; i < response.length; i++){
  21. let img = document.createElement("img");
  22. img.src = response[i];
  23. img.alt = "A picture";
  24. container.appendChild(img);
  25. }
  26. })
  27. .catch(err => {});
  28. let newPath = path.split("/");
  29. console.log(newPath);
  30. let title = "";
  31. for(let i = newPath.length - 1; i >= 0; i--){
  32. title += `${newPath[i].replaceAll("-", " ")}, `;
  33. }
  34. document.getElementById("title").innerText = title.substring(0, title.length-2);
  35. </script>
  36. </body>
  37. </html>