Get the post file service fleshed out
This commit is contained in:
parent
87fd7b129b
commit
db484c0bb1
@ -44,23 +44,27 @@ export class PostFileService {
|
||||
return new PostFileService(posts);
|
||||
}
|
||||
|
||||
public getPostHtml(slug: string): string {
|
||||
const html = this.posts.get(slug)?.html;
|
||||
public getPost(slug: string): Post {
|
||||
const post = this.posts.get(slug);
|
||||
|
||||
if (!html?.length) {
|
||||
throw new Error("Post does not exist.");
|
||||
if (!post) {
|
||||
throw Error("Post does not exist.");
|
||||
}
|
||||
|
||||
return post;
|
||||
}
|
||||
|
||||
public getPostHtml(slug: string): string {
|
||||
const html = this.getPost(slug).html;
|
||||
|
||||
if (!html) {
|
||||
throw Error("No HTML for this post yet.");
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
public getPostRawContent(slug: string): string {
|
||||
const content = this.posts.get(slug)?.content;
|
||||
|
||||
if (!content?.length) {
|
||||
throw new Error("Post does not exist.");
|
||||
}
|
||||
|
||||
return content;
|
||||
return this.getPost(slug).content;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user