Skip to content

Commit 508b305

Browse files
authored
feat(api): add RemoveHtmlExtensionApiRefSitemap project (#249)
* feat(api): add RemoveHtmlExtensionApiRefSitemap project * fix(api): Add RemoveHtmlExtensionFromApiRefSitemap project to .contentignore
1 parent b3cde57 commit 508b305

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

.contentignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/fonts/
1212
/_build/
1313
/_buildApi/
14+
/_tools/RemoveHtmlExtensionFromApiRefSitemap/
1415

1516
.dockerignore
1617
.editorconfig
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using System.IO;
3+
using System.Xml;
4+
5+
namespace RemoveHtmlExtensionFromApiRefSitemap
6+
{
7+
class Program
8+
{
9+
static void Main(string[] args)
10+
{
11+
if(args.Length < 2)
12+
{
13+
throw new ArgumentNullException("You must provide a path to the drop folder of the API reference so we can alter the sitemap.xml file in it.");
14+
}
15+
string pathToApiRefSitemap = Path.Combine(args[0], "sitemap.xml");
16+
if (!File.Exists(pathToApiRefSitemap))
17+
{
18+
throw new FileNotFoundException("API Ref sitemap file not found in the target folder");
19+
}
20+
string sitemapText = File.ReadAllText(pathToApiRefSitemap);
21+
sitemapText = sitemapText.Replace(".html</loc>", "</loc>");
22+
File.WriteAllText(pathToApiRefSitemap, sitemapText);
23+
}
24+
}
25+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net6.0</TargetFramework>
6+
</PropertyGroup>
7+
8+
</Project>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30413.136
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RemoveHtmlExtensionFromApiRefSitemap", "RemoveHtmlExtensionFromApiRefSitemap.csproj", "{E8F2C9B0-13FA-49FB-A62E-C8824FA8D41A}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E8F2C9B0-13FA-49FB-A62E-C8824FA8D41A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E8F2C9B0-13FA-49FB-A62E-C8824FA8D41A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E8F2C9B0-13FA-49FB-A62E-C8824FA8D41A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E8F2C9B0-13FA-49FB-A62E-C8824FA8D41A}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {24453D53-AFFF-450A-96DA-90C729B72F1C}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
To execute from the console:
2+
1. navigate your console to the folder with the .csproj file
3+
2. execute from "dotnet run"
4+
5+
dotnet run SitemapGenerator.csproj -- "C:\\TheCurrentWorkspace\\_site\\api\\"
6+
7+
The first argument is the project file name, the second is the path to the API reference folder so we can get to the sitemap.xml file inside and transform it. So, this must run after the api ref build - either before, or after combining it with the conceptual docs, but before uploading to staging/test/live.
8+
9+
10+
The "--" delimits bult-in dotnet run args from custom args.
11+
Note the double slashes, as they are required as an escaping sequence.
12+

0 commit comments

Comments
 (0)