-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- add theme file for syntax highlighting - start building better app structure
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,4 +37,5 @@ jspm_packages | |
.node_repl_history | ||
|
||
|
||
/dist | ||
/dist | ||
.idea |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,56 @@ | ||
// https://code-maven.com/list-content-of-directory-with-nodejs | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var jsonfile = require('jsonfile'); | ||
var postsjson = 'src/assets/_posts/posts.json'; | ||
var dir = 'src/assets/_posts'; | ||
// https://github.com/jxson/front-matter <- consider for yaml front matter parsing | ||
const fs = require('fs'); | ||
const fm = require('front-matter'); | ||
const path = require('path'); | ||
const jsonfile = require('jsonfile'); | ||
const postsjson = 'src/assets/_posts/posts.json'; | ||
const dir = 'src/assets/_posts'; | ||
|
||
// if (process.argv.length <= 2) { | ||
// console.log("Usage: " + __filename + " path/to/directory"); | ||
// process.exit(-1); | ||
// } | ||
var extFilter = 'md'; | ||
// var pathSupplied = process.argv[2]; | ||
var pathSupplied = dir; | ||
const extFilter = 'md'; | ||
const pathSupplied = dir; | ||
|
||
function extension(element) { | ||
var extName = path.extname(element); | ||
const extName = path.extname(element); | ||
return extName === '.' + extFilter; | ||
}; | ||
} | ||
|
||
fs.readdir(pathSupplied, function(err, items) { | ||
var opener = '{ "posts": '; | ||
var closer = ' }'; | ||
var posts = items.filter(extension).map((item) => { | ||
var file = pathSupplied + '/' + item; | ||
var obj = { title: file }; | ||
return obj; | ||
}) | ||
/** | ||
* cycle through directory for files | ||
*/ | ||
fs.readdir(pathSupplied, function (err, items) { | ||
let opener = '{ "posts": '; | ||
let closer = ' }'; | ||
let posts = []; | ||
let file = ''; | ||
let fileContent = ''; | ||
let content = ''; | ||
let body = ''; | ||
let attributes = {}; | ||
let title = ''; | ||
let description = ''; | ||
/** | ||
* cycle over items, filtering for files matching extension | ||
* @type {Array} | ||
*/ | ||
posts = items.filter(extension).map((item) => { | ||
file = pathSupplied + '/' + item; | ||
fileContent = fs.readFileSync(file, 'utf8'); | ||
content = fm(fileContent); | ||
console.log('*** content ***\n', content); | ||
body = content.body; | ||
attributes = content.attributes; | ||
title = attributes.title; | ||
description = attributes.description; | ||
|
||
return { | ||
file: file, | ||
title: title, | ||
description: description | ||
}; | ||
}); | ||
|
||
opener += JSON.stringify(posts); | ||
opener += closer; | ||
console.log("Posts: ", JSON.stringify(posts)); | ||
fs.writeFile(postsjson, opener); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,24 @@ | ||
import { PostsService } from '../services/posts.service'; | ||
import { HomeComponent } from '../home/home.component'; | ||
import { AppRoutingModule } from './app-routing.module'; | ||
import { NgModule } from '@angular/core'; | ||
import { BrowserModule } from '@angular/platform-browser'; | ||
import { HttpModule } from '@angular/http'; | ||
import { MarkdownToHtmlModule } from 'ng2-markdown-to-html'; | ||
|
||
import { AppComponent } from './app.component'; | ||
import { NgxBlogModule } from './ngx-blog/ngx-blog.module'; | ||
import { CommonModule } from '@angular/common'; | ||
|
||
@NgModule({ | ||
imports: [ | ||
BrowserModule, | ||
CommonModule, | ||
HttpModule, | ||
AppRoutingModule, | ||
NgxBlogModule, | ||
MarkdownToHtmlModule.forRoot() | ||
], | ||
declarations: [ | ||
AppComponent, | ||
HomeComponent | ||
], | ||
providers: [ | ||
PostsService | ||
], | ||
declarations: [AppComponent], | ||
providers: [ ], | ||
bootstrap: [AppComponent], | ||
}) | ||
export class AppModule { } |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<section> | ||
<ng-container *ngFor='let post of posts'> | ||
<article markdown-to-html [src]="post.file" class="posts-card" > | ||
<h2>{{posts.title}}</h2> | ||
<span>{{posts.description}}</span> | ||
</article> | ||
</ng-container> | ||
</section> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.