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);
|
return new PostFileService(posts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPostHtml(slug: string): string {
|
public getPost(slug: string): Post {
|
||||||
const html = this.posts.get(slug)?.html;
|
const post = this.posts.get(slug);
|
||||||
|
|
||||||
if (!html?.length) {
|
if (!post) {
|
||||||
throw new Error("Post does not exist.");
|
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;
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
public getPostRawContent(slug: string): string {
|
public getPostRawContent(slug: string): string {
|
||||||
const content = this.posts.get(slug)?.content;
|
return this.getPost(slug).content;
|
||||||
|
|
||||||
if (!content?.length) {
|
|
||||||
throw new Error("Post does not exist.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return content;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user