Skip to content
This repository was archived by the owner on Apr 7, 2024. It is now read-only.

Commit 2ac8845

Browse files
committed
related to issue #78
1 parent 3d40695 commit 2ac8845

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Initialization/StaticWebInitialization.cs

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ public void Initialize(InitializationEngine context)
4545

4646
private void OnDeletingContent(object sender, DeleteContentEventArgs e)
4747
{
48-
var isPage = e.Content is PageData;
49-
if (isPage)
48+
if (e.Content is PageData page)
5049
{
5150
var staticWebService = ServiceLocator.Current.GetInstance<IStaticWebService>();
5251

53-
var oldUrl = staticWebService.GetPageUrl(new ContentReference(e.Content.ContentLink.ID));
52+
var oldUrl = staticWebService.GetPageUrl(new ContentReference(e.Content.ContentLink.ID), page.Language);
5453
e.Items.Add("StaticWeb-OldUrl", oldUrl);
5554
}
5655
}
@@ -86,12 +85,11 @@ private void OnContentSecuritySaved(object sender, ContentSecurityEventArg e)
8685

8786
private void OnPublishingContent(object sender, ContentEventArgs e)
8887
{
89-
var isPage = e.Content is PageData;
90-
if (isPage)
88+
if (e.Content is PageData page)
9189
{
9290
var staticWebService = ServiceLocator.Current.GetInstance<IStaticWebService>();
9391

94-
var oldUrl = staticWebService.GetPageUrl(new ContentReference(e.Content.ContentLink.ID));
92+
var oldUrl = staticWebService.GetPageUrl(new ContentReference(e.Content.ContentLink.ID), page.Language);
9593
e.Items.Add("StaticWeb-OldUrl", oldUrl);
9694
}
9795
}
@@ -171,9 +169,17 @@ private void OnMovedContent(object sender, ContentEventArgs e)
171169

172170
private void OnPublishedContent(object sender, ContentEventArgs e)
173171
{
174-
var isPage = e.Content is PageData;
175-
var isBlock = e.Content is BlockData;
176-
if (!isPage && !isBlock)
172+
var page = e.Content as PageData;
173+
bool isPage;
174+
if (isPage = page != null)
175+
{
176+
// Content is of type PageData
177+
}
178+
else if (e.Content is BlockData)
179+
{
180+
// Content is of type BlockData
181+
}
182+
else
177183
{
178184
// Content is not of type PageData or BlockData, ignore
179185
return;
@@ -196,7 +202,7 @@ private void OnPublishedContent(object sender, ContentEventArgs e)
196202
// Handle renaming of pages
197203
if (e.Items["StaticWeb-OldUrl"] is string oldUrl)
198204
{
199-
var url = staticWebService.GetPageUrl(e.ContentLink);
205+
var url = staticWebService.GetPageUrl(e.ContentLink, page.Language);
200206
if (url != oldUrl)
201207
{
202208
var removeSubFolders = true;

0 commit comments

Comments
 (0)