public override IEnumerable <FileModel> Prebuild(ImmutableList <FileModel> models, IHostService host) { host.LogInfo("Merging platform..."); var processedUid = new HashSet <string>(); var merged = models.RunAll(m => { if (m.Type != DocumentType.Article) { return(m); } if (m.Uids.Length == 0) { host.LogWarning("Unknown model without uid.", file: m.File); return(m); } var mainUid = m.Uids[0].Name; if (processedUid.Contains(mainUid)) { return(null); } var sameTopics = host.LookupByUid(mainUid); if (sameTopics.Count == 1) { return(m); } processedUid.Add(mainUid); var vm = (PageViewModel)m.Content; m.Content = MergeCore( mainUid, m, from topic in sameTopics where topic != m where topic.Type == DocumentType.Article select topic, host); return(m); }); host.LogInfo("Platform merged."); return(from p in merged where p != null select p); }
public override IEnumerable<FileModel> Prebuild(ImmutableList<FileModel> models, IHostService host) { host.LogInfo("Merging platform..."); var processedUid = new HashSet<string>(); var merged = models.RunAll(m => { if (m.Type != DocumentType.Article) { return m; } if (m.Uids.Length == 0) { host.LogWarning("Unknown model without uid.", file: m.File); return m; } var mainUid = m.Uids[0]; if (processedUid.Contains(mainUid)) { return null; } var sameTopics = host.LookupByUid(mainUid); if (sameTopics.Count == 1) { return m; } processedUid.Add(mainUid); var vm = (PageViewModel)m.Content; m.Content = MergeCore( mainUid, m, from topic in sameTopics where topic != m where topic.Type == DocumentType.Article select topic, host); return m; }); host.LogInfo("Platform merged."); return from p in merged where p != null select p; }