fix(blog): fix reading of url due to schema change
This commit is contained in:
parent
0a9c2e82d5
commit
67d89c1831
@ -1,4 +1,4 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OliverBooth", "OliverBooth\OliverBooth.csproj", "{A58A6FA3-480C-400B-822A-3786741BF39C}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OliverBooth", "OliverBooth\OliverBooth.csproj", "{A58A6FA3-480C-400B-822A-3786741BF39C}"
|
||||||
EndProject
|
EndProject
|
||||||
@ -32,6 +32,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ts", "ts", "{BB9F76AC-292A-
|
|||||||
src\ts\TimeUtility.ts = src\ts\TimeUtility.ts
|
src\ts\TimeUtility.ts = src\ts\TimeUtility.ts
|
||||||
src\ts\UI.ts = src\ts\UI.ts
|
src\ts\UI.ts = src\ts\UI.ts
|
||||||
src\ts\Input.ts = src\ts\Input.ts
|
src\ts\Input.ts = src\ts\Input.ts
|
||||||
|
src\ts\BlogUrl.ts = src\ts\BlogUrl.ts
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
import BlogUrl from "./BlogUrl";
|
||||||
|
|
||||||
class BlogPost {
|
class BlogPost {
|
||||||
private readonly _id: string;
|
private readonly _id: string;
|
||||||
private readonly _commentsEnabled: boolean;
|
private readonly _commentsEnabled: boolean;
|
||||||
@ -7,7 +9,7 @@ class BlogPost {
|
|||||||
private readonly _authorId: string;
|
private readonly _authorId: string;
|
||||||
private readonly _published: Date;
|
private readonly _published: Date;
|
||||||
private readonly _updated?: Date;
|
private readonly _updated?: Date;
|
||||||
private readonly _url: string;
|
private readonly _url: BlogUrl;
|
||||||
private readonly _trimmed: boolean;
|
private readonly _trimmed: boolean;
|
||||||
private readonly _identifier: string;
|
private readonly _identifier: string;
|
||||||
private readonly _humanizedTimestamp: string;
|
private readonly _humanizedTimestamp: string;
|
||||||
@ -22,7 +24,7 @@ class BlogPost {
|
|||||||
this._authorId = json.author;
|
this._authorId = json.author;
|
||||||
this._published = new Date(json.published * 1000);
|
this._published = new Date(json.published * 1000);
|
||||||
this._updated = (json.updated && new Date(json.updated * 1000)) || null;
|
this._updated = (json.updated && new Date(json.updated * 1000)) || null;
|
||||||
this._url = json.url;
|
this._url = new BlogUrl(json.url);
|
||||||
this._trimmed = json.trimmed;
|
this._trimmed = json.trimmed;
|
||||||
this._identifier = json.identifier;
|
this._identifier = json.identifier;
|
||||||
this._humanizedTimestamp = json.humanizedTimestamp;
|
this._humanizedTimestamp = json.humanizedTimestamp;
|
||||||
@ -61,7 +63,7 @@ class BlogPost {
|
|||||||
return this._updated;
|
return this._updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
get url(): string {
|
get url(): BlogUrl {
|
||||||
return this._url;
|
return this._url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
32
src/ts/BlogUrl.ts
Normal file
32
src/ts/BlogUrl.ts
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
class BlogUrl {
|
||||||
|
private readonly _year: string;
|
||||||
|
private readonly _month: string;
|
||||||
|
private readonly _day: string;
|
||||||
|
private readonly _slug: string;
|
||||||
|
|
||||||
|
constructor(json: any) {
|
||||||
|
this._year = json.year;
|
||||||
|
this._month = json.month;
|
||||||
|
this._day = json.day;
|
||||||
|
this._slug = json.slug;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
get year(): string {
|
||||||
|
return this._year;
|
||||||
|
}
|
||||||
|
|
||||||
|
get month(): string {
|
||||||
|
return this._month;
|
||||||
|
}
|
||||||
|
|
||||||
|
get day(): string {
|
||||||
|
return this._day;
|
||||||
|
}
|
||||||
|
|
||||||
|
get slug(): string {
|
||||||
|
return this._slug;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default BlogUrl;
|
@ -48,7 +48,7 @@ class UI {
|
|||||||
post: {
|
post: {
|
||||||
title: post.title,
|
title: post.title,
|
||||||
excerpt: post.excerpt,
|
excerpt: post.excerpt,
|
||||||
url: post.url,
|
url: `${post.url.year}/${post.url.month}/${post.url.day}/${post.url.slug}`,
|
||||||
date: TimeUtility.formatRelativeTimestamp(post.published),
|
date: TimeUtility.formatRelativeTimestamp(post.published),
|
||||||
formattedDate: post.formattedDate,
|
formattedDate: post.formattedDate,
|
||||||
date_humanized: `${post.updated ? "Updated" : "Published"} ${post.humanizedTimestamp}`,
|
date_humanized: `${post.updated ? "Updated" : "Published"} ${post.humanizedTimestamp}`,
|
||||||
|
Loading…
Reference in New Issue
Block a user