From d2ff8925692f3847936a8630b9b86b22300b1141 Mon Sep 17 00:00:00 2001 From: Simon Larsen Date: Sat, 2 Mar 2024 20:44:31 +0000 Subject: [PATCH] Update footer and BlogPostUtil*** --- App/FeatureSet/Home/Utils/BlogPost.ts | 22 ++- App/FeatureSet/Home/Views/Blog/Post.ejs | 185 ++++++++++++++-------- App/FeatureSet/Home/Views/footer.ejs | 2 +- App/FeatureSet/Home/Views/head-basic.ejs | 120 ++++++++++++++ App/FeatureSet/Home/Views/head-social.ejs | 32 ++++ App/FeatureSet/Home/Views/head.ejs | 154 +----------------- 6 files changed, 298 insertions(+), 217 deletions(-) create mode 100644 App/FeatureSet/Home/Views/head-basic.ejs create mode 100644 App/FeatureSet/Home/Views/head-social.ejs diff --git a/App/FeatureSet/Home/Utils/BlogPost.ts b/App/FeatureSet/Home/Utils/BlogPost.ts index 9a5ec2b458..e5df8db699 100644 --- a/App/FeatureSet/Home/Utils/BlogPost.ts +++ b/App/FeatureSet/Home/Utils/BlogPost.ts @@ -27,6 +27,9 @@ export interface BlogPost { fileName: string; tags: string[]; postDate: string; + formattedPostDate: string; + socialMediaImageUrl: string; + blogUrl: string; } const GitHubRawUrl = 'https://raw.githubusercontent.com/oneuptime/blog/master' @@ -146,6 +149,7 @@ export default class BlogPostUtil { ); const postDate = this.getPostDateFromFileName(fileName); + const formattedPostDate = this.getFormattedPostDateFromFileName(fileName); const fileData: | HTTPResponse< @@ -193,12 +197,28 @@ export default class BlogPostUtil { markdownBody: markdownContent, fileName, tags, - postDate: postDate, + postDate, + formattedPostDate, + socialMediaImageUrl: `${GitHubRawUrl}/posts/${fileName}/social-media.png`, + blogUrl: `https://oneuptime.com/blog/post/${fileName}`, }; return blogPost; } + static getPostDateFromFileName(fileName: string): string { + const year = fileName.split('-')[0]; + const month = fileName.split('-')[1]; + const day = fileName.split('-')[2]; + + if(!year || !month || !day) { + throw new BadDataException('Invalid file name'); + } + + return `${year}-${month}-${day}`; + } + + static getFormattedPostDateFromFileName(fileName: string): string { // file name is of the format YYYY-MM-DD-Title.md const year = fileName.split('-')[0]; const month = fileName.split('-')[1]; diff --git a/App/FeatureSet/Home/Views/Blog/Post.ejs b/App/FeatureSet/Home/Views/Blog/Post.ejs index 7d886f266d..78b72d30b3 100644 --- a/App/FeatureSet/Home/Views/Blog/Post.ejs +++ b/App/FeatureSet/Home/Views/Blog/Post.ejs @@ -8,11 +8,61 @@ <%= blogPost.title %> - <%- include('../head') -%> + <%- include('../head-basic') -%> + + + + + + + + + + + + + + + + + + + + + - @@ -28,7 +78,7 @@

<%= blogPost.title %>

-

+

<%= blogPost.description %>

@@ -38,69 +88,78 @@ <%- blogPost.htmlBody -%> - <% if(blogPost.tags.length > 0){ %> -
-
- - <% for(var i=0; i - -
-
- -
-
- <%- blogPost.tags[i] -%> -
-
-
- - <% } %> -
-
- <% } %> - -
-
- -
-
- -
Our commitment to open-source
-
- + <% } %> +
- + <% } %> + +
+
+ +
+
+ + +
Our Commitment to Open Source +
+
+ +
+ diff --git a/App/FeatureSet/Home/Views/footer.ejs b/App/FeatureSet/Home/Views/footer.ejs index 4af0afba5c..3ccf4f4989 100644 --- a/App/FeatureSet/Home/Views/footer.ejs +++ b/App/FeatureSet/Home/Views/footer.ejs @@ -6,7 +6,7 @@
OneUptime -

OneUptime is the complete open-source observability platform.

+

OneUptime is the complete observability platform. OneUptime is open-source and always will be.

diff --git a/App/FeatureSet/Home/Views/head-basic.ejs b/App/FeatureSet/Home/Views/head-basic.ejs new file mode 100644 index 0000000000..63926826e4 --- /dev/null +++ b/App/FeatureSet/Home/Views/head-basic.ejs @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/App/FeatureSet/Home/Views/head-social.ejs b/App/FeatureSet/Home/Views/head-social.ejs new file mode 100644 index 0000000000..a745f9b2cd --- /dev/null +++ b/App/FeatureSet/Home/Views/head-social.ejs @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/App/FeatureSet/Home/Views/head.ejs b/App/FeatureSet/Home/Views/head.ejs index 59c31de355..6a73a30eff 100644 --- a/App/FeatureSet/Home/Views/head.ejs +++ b/App/FeatureSet/Home/Views/head.ejs @@ -1,152 +1,2 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file +<%- include('./head-basic') -%> +<%- include('./head-social') -%>