ssg: StaticSitePost, StaticSiteClient: impl EnsureDate, use in StaticSiteClient NewPost
This commit is contained in:
parent
21e987b52e
commit
76f7ec83b9
|
@ -80,13 +80,12 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
|
||||||
remotePost = null;
|
remotePost = null;
|
||||||
etag = "";
|
etag = "";
|
||||||
|
|
||||||
// Set Date if not provided
|
|
||||||
if (post.DatePublished == new DateTime(1, 1, 1)) post.DatePublished = DateTime.Now;
|
|
||||||
|
|
||||||
// Create a StaticSitePost on the provided post
|
// Create a StaticSitePost on the provided post
|
||||||
var ssgPost = new StaticSitePost(Config, post);
|
var ssgPost = new StaticSitePost(Config, post);
|
||||||
// Ensure the post has an ID
|
// Ensure the post has an ID
|
||||||
var newPostId = ssgPost.EnsureId();
|
var newPostId = ssgPost.EnsureId();
|
||||||
|
// Ensure the post has a date
|
||||||
|
ssgPost.EnsureDatePublished();
|
||||||
// Save the post to disk
|
// Save the post to disk
|
||||||
ssgPost.SaveToDisk();
|
ssgPost.SaveToDisk();
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,12 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
|
||||||
set => BlogPost.Slug = _safeSlug = value;
|
set => BlogPost.Slug = _safeSlug = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DateTime DatePublished
|
||||||
|
{
|
||||||
|
get => BlogPost.DatePublished;
|
||||||
|
set => BlogPost.DatePublished = value;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Confirmed safe slug; does not conflict with any existing post on disk or points to this post on disk.
|
/// Confirmed safe slug; does not conflict with any existing post on disk or points to this post on disk.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -121,6 +127,16 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
|
||||||
return Id;
|
return Id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set post published DateTime to current DateTime if one isn't already set, or current one is default.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current or new DatePublished.</returns>
|
||||||
|
public DateTime EnsureDatePublished()
|
||||||
|
{
|
||||||
|
if (DatePublished == null || DatePublished == new DateTime(1, 1, 1)) DatePublished = DateTime.Now;
|
||||||
|
return DatePublished;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a slug for this post based on it's title or a preferred slug
|
/// Generate a slug for this post based on it's title or a preferred slug
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue