From 4ad1e893497e8e713c15edc0b2cf28eee75ff167 Mon Sep 17 00:00:00 2001 From: Nick Vella Date: Sun, 14 Jul 2019 22:19:45 +1000 Subject: [PATCH] ssg: StaticSiteClient, StaticSitePost: move EnsureId call to StaticSiteClient from StaticSitePost SaveToDisk, return postId from NewPost --- .../Clients/StaticSite/StaticSiteClient.cs | 7 +++++-- .../Clients/StaticSite/StaticSitePost.cs | 3 --- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSiteClient.cs b/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSiteClient.cs index 083eb03f..d6f1e73c 100644 --- a/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSiteClient.cs +++ b/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSiteClient.cs @@ -83,8 +83,11 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite // Set Date if not provided if (post.DatePublished == new DateTime(1, 1, 1)) post.DatePublished = DateTime.Now; - // Write to file + // Create a StaticSitePost on the provided post var ssgPost = new StaticSitePost(Config, post); + // Ensure the post has an ID + var newPostId = ssgPost.EnsureId(); + // Save the post to disk ssgPost.SaveToDisk(); try @@ -95,7 +98,7 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite // Publish the site DoSitePublish(); - return ""; + return newPostId; } catch (Exception ex) { // Clean up our output file diff --git a/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSitePost.cs b/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSitePost.cs index 6aad3bae..0ae0a087 100644 --- a/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSitePost.cs +++ b/src/managed/OpenLiveWriter.BlogClient/Clients/StaticSite/StaticSitePost.cs @@ -181,9 +181,6 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite /// public void SaveToDisk() { - // Generate an ID if one isn't already generated - EnsureId(); - // Generate a safe slug if one isn't already generated // This ensures we don't overwrite an existing post EnsureSafeSlug();