Browse Source

index files being generated]

master
Sean Clarke 1 month ago
parent
commit
419c3b0cd5
9 changed files with 80 additions and 25 deletions
  1. +3
    -4
      app.js
  2. +11
    -1
      model/Listing.js
  3. +14
    -1
      model/Post.js
  4. +13
    -0
      partials/footer.html
  5. +19
    -0
      partials/header.html
  6. +2
    -1
      posts/01-15-2018-split-word-sample.md
  7. +6
    -6
      posts/10-15-2019-split-word-sample.md
  8. +6
    -6
      posts/10-19-2019-sample.md
  9. +6
    -6
      posts/12-25-2019-christmas-sample.md

+ 3
- 4
app.js View File

@@ -20,7 +20,6 @@ var posts = fs.readdirSync(postsDirectory, function(err, posts){
if(err) throw err;
// sorting posts by data aka name of file.
posts.sort();
posts.reverse();
});

posts.forEach(function(post){
@@ -33,6 +32,6 @@ posts.forEach(function(post){

var posts = new Listing();

posts = allPosts.forYearAndMonth(2018, 01);
console.log(posts.posts[0].build());
posts = allPosts.forYear(2019);
posts.buildIndex();
console.log(posts.posts[0].generateListing());

+ 11
- 1
model/Listing.js View File

@@ -8,7 +8,7 @@ var Listing = function(){
};

Listing.prototype.addPost = function(post){
this.posts.push(post);
this.posts.unshift(post);
};

Listing.prototype.forYear = function(year){
@@ -31,4 +31,14 @@ Listing.prototype.forYearAndMonth = function(year, month){
return filterPosts;
};

Listing.prototype.buildIndex = function(){
var html = fs.readFileSync(process.cwd() + '/partials/header.html', 'utf8');
html += '<h1>Index Name</h1>\n';
this.posts.forEach(function(post){
html+= post.generateListing();
});
html += fs.readFileSync(process.cwd() + '/partials/footer.html', 'utf8');
fs.writeFileSync(process.cwd() + '/_site/index.html', html, 'utf8');
}

module.exports = Listing;

+ 14
- 1
model/Post.js View File

@@ -14,6 +14,7 @@ var Post = function(data){

// html url
var html = this.name.split('.')[0] + '.html';
this.url = 'posts/' + this.year + '/' + this.month + '/'+ html;
this.html = process.cwd() + '/_site/posts/' + this.year + '/' + this.month + '/'+ html;
};

@@ -42,8 +43,20 @@ Post.prototype.getPost = function(){
}

Post.prototype.build = function(){
fs.writeFileSync(this.html, convert.makeHtml(this.getPost()), 'utf8');
var html = fs.readFileSync(process.cwd() + '/partials/header.html', 'utf8');
html += convert.makeHtml(this.getPost())
html += fs.readFileSync(process.cwd() + '/partials/footer.html', 'utf8');

fs.writeFileSync(this.html, html, 'utf8');
// return this.getPost();
}

Post.prototype.generateListing = function(){
var dets = this.getDetails();
var html = '<h2 class="title"><a href="' + this.url + '">' + dets.title + '</a></h2>\n';
html += '<p class="published">Published: ' + this.month + '-' + this.day + '-' + this.year + '</p>\n';
html += '<p class="description">' + dets.desc + '</p>\n';
return html;
}

module.exports = Post;

+ 13
- 0
partials/footer.html View File

@@ -0,0 +1,13 @@
<div id="footer">
<p>
Copyright: <a href="#">©️ Sean Clarke</a><!-- | Support Me: <a href="https://www.buymeacoffee.com/seanland">Buy me a ☕ or ☕☕</a> -->
</p>
<p>
<style>.bmc-button img{width: 27px !important;margin-bottom: 1px !important;box-shadow: none !important;border: none !important;vertical-align: middle !important;}.bmc-button{line-height: 36px !important;height:37px !important;text-decoration: none !important;display:inline-flex !important;color:#ffffff !important;background-color:#000000 !important;border-radius: 3px !important;border: 1px solid transparent !important;padding: 1px 9px !important;font-size: 23px !important;letter-spacing: 0.6px !important;box-shadow: 0px 1px 2px rgba(190, 190, 190, 0.5) !important;-webkit-box-shadow: 0px 1px 2px 2px rgba(190, 190, 190, 0.5) !important;margin: 0 auto !important;font-family:'Cookie', cursive !important;-webkit-box-sizing: border-box !important;box-sizing: border-box !important;-o-transition: 0.3s all linear !important;-webkit-transition: 0.3s all linear !important;-moz-transition: 0.3s all linear !important;-ms-transition: 0.3s all linear !important;transition: 0.3s all linear !important;}.bmc-button:hover, .bmc-button:active, .bmc-button:focus {-webkit-box-shadow: 0px 1px 2px 2px rgba(190, 190, 190, 0.5) !important;text-decoration: none !important;box-shadow: 0px 1px 2px 2px rgba(190, 190, 190, 0.5) !important;opacity: 0.85 !important;color:#ffffff !important;}</style><link href="https://fonts.googleapis.com/css?family=Cookie" rel="stylesheet"><a class="bmc-button" target="_blank" href="https://www.buymeacoffee.com/seanland"><img src="https://www.buymeacoffee.com/assets/img/BMC-btn-logo.svg" alt="Buy me a coffee"><span style="margin-left:5px">Buy me a coffee</span></a>
</p>
</div>
</body>

<!-- Javascript Declaration -->
<script src="js/main.js"></script>
</html>

+ 19
- 0
partials/header.html View File

@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Seanland</title>
<!-- Meta Data -->
<meta name="description" content="Seanland: The work of Sean Clarke">
<meta name="author" content="Sean Clarke">
<!-- Favicon -->
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<!-- Stylesheets -->
<link href="css/main.css" rel="stylesheet">
</head>

<body>
<div id="header">
<img class="profile" src="img/profile.PNG" />
<img class="logo" src="img/logo.PNG" />
</div>

+ 2
- 1
posts/01-15-2018-split-word-sample.md View File

@@ -1,7 +1,8 @@
<--
title: Sean's First Post
title: Sean's Second Post
desc: This is the description of Sean's first post. If you keep writing it will give you a lot more information. I will just keep typing.
tags: tech computers travel
update: 02-16-2018
-->
# Post Title!


+ 6
- 6
posts/10-15-2019-split-word-sample.md View File

@@ -1,9 +1,9 @@
<--
title: Sean's Third Post
desc: This is the description of Sean's first post. If you keep writing it will give you a lot more information. I will just keep typing.
tags: tech computers travel
update: 02-16-2018
-->
# Post Title!

This is some text. I am happy to write this text. This will show how it works.

+ 6
- 6
posts/10-19-2019-sample.md View File

@@ -1,9 +1,9 @@
<--
title: Sean's First Post
desc: This is the description of Sean's first post. If you keep writing it will give you a lot more information. I will just keep typing.
tags: tech computers travel
update: 02-16-2018
-->
# Post Title!

This is some text. I am happy to write this text. This will show how it works.

+ 6
- 6
posts/12-25-2019-christmas-sample.md View File

@@ -1,9 +1,9 @@
<--
title: Sean's Other Post
desc: This is the description of Sean's first post. If you keep writing it will give you a lot more information. I will just keep typing.
tags: tech computers travel
update: 02-16-2018
-->
# Post Title!

This is some text. I am happy to write this text. This will show how it works.

Loading…
Cancel
Save