-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat
Posts
: Add posts section rendered from a yaml file
- Loading branch information
Showing
11 changed files
with
82 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
configuration/Configuration.yml | ||
configuration/Configuration.yml | ||
configuration/Posts.yml |
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,5 @@ | ||
- Title: Introducing Gravity, a new way to write blogs. | ||
Description: Lorem ipsum or whatever | ||
|
||
- Title: Meet Nebula - Pterodactyl takes flight! | ||
Description: I create stuff! |
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,31 @@ | ||
function BlogListSection() { | ||
let Posts = "" | ||
window.Blogs.forEach(Post => { | ||
Posts = ` | ||
${Posts} | ||
<div class="col-12 mb-3"> | ||
<div class="border border-dark border-opacity-25 p-4 rounded-4"> | ||
<div class="row d-flex"> | ||
<div class="col-10 me-auto"> | ||
<span class="h5 fw-bold"> | ||
${Post.Title} | ||
</span> | ||
<span class="d-block"> | ||
${Post.Description} | ||
</span> | ||
</div> | ||
<div class="col-auto my-auto"> | ||
<button type="button" class="btn shadow-none text-danger-emphasis"><i class="bi bi-chevron-right"></i></button> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
` | ||
}); | ||
return ` | ||
<div class="row"> | ||
${Posts} | ||
</div> | ||
` | ||
} |
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,24 @@ | ||
let BlogsURL = "./configuration/Posts.yml" | ||
let ExampleBlogs = false | ||
|
||
async function FetchBlogs() { | ||
var xhr = new XMLHttpRequest() | ||
xhr.open("GET", BlogsURL, true) | ||
xhr.onreadystatechange = async function () { | ||
if (xhr.readyState == 4 && xhr.status == 200) { | ||
var res = jsyaml.load(xhr.responseText) | ||
window.Blogs = res | ||
return; | ||
} | ||
if (xhr.readyState == 4 && xhr.status == 404) { | ||
if(BlogsURL != "./configuration/Posts.example.yml") { | ||
ExampleBlogs = true | ||
BlogsURL = "./configuration/Posts.example.yml" | ||
FetchBlogs() | ||
} else { | ||
return console.error("Posts.yml could not be found!") | ||
} | ||
} | ||
} | ||
xhr.send() | ||
} |
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 |
---|---|---|
@@ -1,9 +1,5 @@ | ||
async function RenderConfiguration() { | ||
// Render values | ||
if(!window.Configuration) { | ||
AppTitle.innerHTML = "welcome to gravity" | ||
return; | ||
} | ||
AppTitle.innerHTML = window.Configuration.Application.Title || "gravity" | ||
return; | ||
} |
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
async function ImportConfigurations() { | ||
Import("./src/configuration/RenderConfiguration.js", "RenderConfiguration") | ||
Import("./src/configuration/FetchConfiguration.js", "FetchConfiguration", function() { FetchConfiguration() }) | ||
Import("./src/configuration/FetchBlogs.js", "FetchBlogs", function() { FetchBlogs() }) | ||
} |
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