Skip to content

Commit

Permalink
Fixed override of directories
Browse files Browse the repository at this point in the history
  • Loading branch information
mtirionMSFT committed Nov 13, 2024
1 parent 8ebdbd1 commit 585ff32
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ public async Task Run_WithOverrideOnly()
current.Folders[0].Name.Should().Be("germany");
current.Folders[0].DisplayName.Should().Be("Germany");
current.Folders[1].Name.Should().Be("netherlands");
current.Folders[1].DisplayName.Should().Be("Netherlands");
// here is a folder title from .override
current.Folders[1].DisplayName.Should().Be("The Netherlands");
current.FileCount.Should().Be(1);
current.Files[0].Name.Should().Be("README.md");
current.Files[0].DisplayName.Should().Be($"Europe");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ public void FillDemoSet()
AddFile(folder, "README.md", string.Empty
.AddHeading("Europe", 1)
.AddParagraphs(1));
AddFile(folder, ".override",
@"netherlands;The Netherlands");

folder = AddFolder("continents/europe/germany");
AddFile(folder, "README.md", string.Empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,8 @@ public async Task GetTocItems_GetTocFolderReferenceFirst()
toc.IsFolder.Should().BeTrue();
toc.Depth.Should().Be(5);
toc.Base.Should().Be(current);
toc.Name.Should().Be("Netherlands");
// override name
toc.Name.Should().Be("The Netherlands");
toc.Sequence.Should().Be(current!.Sequence);
toc.Href.Should().BeNull();

Expand Down Expand Up @@ -412,7 +413,7 @@ public async Task SerializeTocItem_Hierarchy()
href: continents/europe/germany/berlin.md
- name: München
href: continents/europe/germany/munchen.md
- name: Netherlands
- name: The Netherlands
items:
- name: Noord holland
items:
Expand Down Expand Up @@ -531,7 +532,7 @@ public async Task SerializeTocItem_Hierarchy_CamelCase()
href: continents/europe/germany/berlin.md
- name: münchen
href: continents/europe/germany/munchen.md
- name: netherlands
- name: The Netherlands
items:
- name: noord holland
items:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,15 @@ public Task<ReturnCode> RunAsync()
Parent = parent,
};

if (parent != null)
{
// see if we have an override for the folder name
if (parent.OverrideList.TryGetValue(folder.Name, out string? name))
{
folder.DisplayName = name;
}
}

// read config files
if (_useOrder)
{
Expand Down

0 comments on commit 585ff32

Please sign in to comment.