ssg: StaticSitePost: ensure Id and safe slug when saving to disk

This commit is contained in:
Nick Vella 2019-07-14 19:08:17 +10:00
parent e614030d46
commit 689fee79e5
1 changed files with 12 additions and 1 deletions

View File

@ -178,6 +178,17 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
/// <summary>
/// Save the post to the correct directory
/// </summary>
public void SaveToDisk() => File.WriteAllText(FilePath, ToString());
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();
// Save the post to disk
File.WriteAllText(FilePath, ToString());
}
}
}