Skip to content

Commit

Permalink
Update Markdown.Meta.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
mythz committed Aug 14, 2023
1 parent e7743e3 commit 9e0f66b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions MyApp/Markdown.Meta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ public async Task RenderToAsync(string metaDir, string baseUrl)
var index = new Dictionary<string, object>();
foreach (var feature in Features.Safe())
{
var allDocs = feature.GetAll();
var allDocs = feature.GetAll()
.OrderByDescending(x => x.Date!.Value)
.ThenBy(x => x.Order)
.ThenBy(x => x.FileName)
.ToList();
allDocs.ForEach(x => {
if (x.Url?.StartsWith("/") == true)
x.Url = baseUrl.CombineWith(x.Url);
Expand All @@ -30,7 +34,9 @@ public async Task RenderToAsync(string metaDir, string baseUrl)
index[feature.Id] = featureYears.Map(x => baseUrl.CombineWith($"/meta/{x}/{feature.Id}.json"));
foreach (var year in featureYears)
{
var yearDocs = allDocs.Where(x => x.Date!.Value.Year == year).OrderBy(x => x.Date!.Value).ToList();
var yearDocs = allDocs
.Where(x => x.Date!.Value.Year == year)
.ToList();
var yearDir = metaDir.CombineWith(year).AssertDir();
var metaPath = yearDir.CombineWith($"{feature.Id}.json");
await File.WriteAllTextAsync(metaPath, yearDocs.ToJson());
Expand All @@ -44,7 +50,9 @@ public async Task RenderToAsync(string metaDir, string baseUrl)
var yearDocs = new Dictionary<string, List<MarkdownFileBase>>();
foreach (var entry in featureDocs)
{
yearDocs[entry.Key] = entry.Value.Where(x => x.Date!.Value.Year == year).OrderBy(x => x.Date!.Value).ToList();
yearDocs[entry.Key] = entry.Value
.Where(x => x.Date!.Value.Year == year)
.ToList();
}
await File.WriteAllTextAsync(metaDir.CombineWith($"{year}/all.json"), JSON.stringify(yearDocs));
}
Expand Down

0 comments on commit 9e0f66b

Please sign in to comment.