-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create news page and corresponding scripts
- Loading branch information
Showing
7 changed files
with
150 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[ | ||
{ | ||
"title": "New test", | ||
"date": "2024-03-15", | ||
"content": "Test, This is a very big test<br>A paragraph too small is a paragraph never lived.", | ||
"image": "", | ||
"link": "www.google.com", | ||
"tags": ["Release"] | ||
}, | ||
{ | ||
"title": "Test 2", | ||
"date": "2024-03-10", | ||
"content": "Test", | ||
"image": "", | ||
"link": "", | ||
"tags": ["Tour"] | ||
} | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
fetch('../assets/data/news.json') | ||
.then(response => response.json()) | ||
.then(newsItems => { | ||
const newsSection = document.getElementById('news-section'); | ||
|
||
// clears existing content in the news section | ||
newsSection.innerHTML = ''; | ||
|
||
newsItems.forEach(item => { | ||
const newsItem = document.createElement('div'); | ||
newsItem.className = 'news-item'; | ||
|
||
let newsContent = `<h3>${item.title}</h3>`; | ||
if (item.image) { | ||
newsContent += `<img src="${item.image}" alt="${item.title}" style="width:100%;max-width:600px;height:auto;">`; | ||
} | ||
newsContent += `<p>${item.date}</p><p>${item.content}</p>`; | ||
if (item.link) { | ||
newsContent += `<a href="${item.link}">Read More</a>`; | ||
} | ||
|
||
newsItem.innerHTML = newsContent; | ||
newsSection.appendChild(newsItem); | ||
}); | ||
}) | ||
.catch(error => { | ||
console.error('Error fetching news:', error); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>szch.me news</title> | ||
<link rel="icon" type="image/x-icon" href="../assets/images/favicon.png"> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Fragment+Mono:ital@0;1&family=Bricolage+Grotesque:opsz,[email protected],200..800&display=swap" rel="stylesheet"> | ||
<link rel="stylesheet" href="../assets/css/style.css"> | ||
</head> | ||
<body> | ||
<div id="pageOverlay" class="overlay" onclick="toggleMenu()"></div> | ||
<header> | ||
<div class="scrolling_text"> | ||
<div class="text"> | ||
<span>szch.me </span><span>szch.me </span><span>szch.me </span><span>szch.me </span><span>szch.me </span> | ||
</div> | ||
<div class="text"> | ||
<span>szch.me </span><span>szch.me </span><span>szch.me </span><span>szch.me </span><span>szch.me </span> | ||
</div> | ||
</div> | ||
<div class="menu-icon" onclick="toggleMenu()"> | ||
<img src="../assets/images/hamburger-menu-open.png" alt="Menu open" id="menuIcon"> | ||
</div> | ||
<div class="menu-content" id="menuContent"> | ||
<span class="close-menu" onclick="toggleMenu()"> | ||
<img src="../assets/images/hamburger-menu-close-D67DB3.png" alt="Menu close" style="display:none;" id="closeIcon"> | ||
</span> | ||
<ul> | ||
<li><a href="../index.html">take me home</a></li> | ||
<li><a href="./news.html">news</a></li> | ||
<li><a href="../music/music.html">music</a></li> | ||
<li><a href="../visuals/visuals.html">visuals</a></li> | ||
</ul> | ||
</div> | ||
</header> | ||
<main> | ||
<section id="news-section" class="news-container"> | ||
<h2 class="display-font">the news</h2> | ||
<!-- news items will be dynamically inserted here from the news.js script and json --> | ||
</section> | ||
</main> | ||
<footer> | ||
<p class="fragment-mono-regular">© 2024 SZCH. All rights reserved.</p> | ||
</footer> | ||
<script src="../assets/js/menu-toggle.js"></script> | ||
<script src="../assets/js/news-script.js"></script> | ||
</body> | ||
</html> |