Fixed lint errors :D

Signed-off-by: Avior <florian.bouillon@delta-wings.net>
This commit is contained in:
2020-01-05 00:56:27 +01:00
parent e255554262
commit 42b7ef1b2c
16 changed files with 230 additions and 229 deletions

View File

@ -1,6 +1,5 @@
import matter from 'gray-matter'
interface PostInterface {
slug: string
title: string
@ -15,13 +14,22 @@ export interface PostHeader {
imageAlt?: string
date: Date
url?: string
tags?: string[]
tags?: Array<string>
modifiedDate?: Date
short?: string
}
export default class Post implements PostInterface {
public static async fetchAll(): Promise<Array<Post>> {
const files: Array<string> = ((require as any).context('../posts', true, /\.md$/)).keys()
const posts: Array<Post> = []
for (const file of files) {
posts.push(new Post(file.replace('./', '')))
}
return posts
}
public slug: string
public title: string
public content: string
@ -34,7 +42,10 @@ export default class Post implements PostInterface {
}
public async fetch() {
if (!this.slug.endsWith(".md")) this.slug = "portfolio/" + this.slug + ".md"
if (!this.slug.endsWith('.md')) {
this.slug = `portfolio/${this.slug}.md`
}
const content = await import(`../posts/${this.slug}`)
const md = matter(content.default)
this.title = md.data.title
@ -43,24 +54,14 @@ export default class Post implements PostInterface {
}
public fetchSync() {
if (!this.slug.endsWith(".md")) this.slug = "portfolio/" + this.slug + ".md"
if (!this.slug.endsWith('.md')) {
this.slug = `portfolio/${this.slug}.md`
}
const content = require(`../posts/${this.slug}`)
const md = matter(content.default)
this.title = md.data.title
this.header = (md.data as PostHeader)
this.content = md.content
}
public static async fetchAll(): Promise<Post[]> {
const files: string[] = ((require as any).context('../posts', true, /\.md$/)).keys()
const posts: Post[] = []
for (const file of files) {
posts.push(
new Post(
file.replace("./", '')
)
)
}
return posts
}
}