diff --git a/src/Microsoft.Content.Build.Code2Yaml.Steps/GenerateServiceMappingFile.cs b/src/Microsoft.Content.Build.Code2Yaml.Steps/GenerateServiceMappingFile.cs index c99e326..c062863 100644 --- a/src/Microsoft.Content.Build.Code2Yaml.Steps/GenerateServiceMappingFile.cs +++ b/src/Microsoft.Content.Build.Code2Yaml.Steps/GenerateServiceMappingFile.cs @@ -14,6 +14,8 @@ public class GenerateServiceMappingFile : IStep { + private const string LandingPageTypeService = "Service"; + public string StepName { get @@ -46,6 +48,7 @@ select g ).ToDictionary(g => g.Key, g => g.ToList()); List others = new List(); + Dictionary serviceHrefMapping = new Dictionary(); if (File.Exists(outputPath)) { using (var reader = new StreamReader(outputPath)) @@ -61,6 +64,7 @@ select g { others.Add(other); } + serviceHrefMapping = oldMapping[0].items.ToDictionary(i => i.name, i => i.href); } } @@ -87,17 +91,20 @@ group v.Value by v.Key.Category into g0 landingPageType = "Root", items = new ServiceMapping((from pair in services let service = pair.Key + let hrefAndType = GetServiceHrefAndType(serviceHrefMapping, service) select new ServiceMappingItem() { name = service, - href = "~/docs-ref-services/overview/azure/" + service + ".md", + href = hrefAndType.Item1, + landingPageType = hrefAndType.Item2, + uid = "landingpage.services." + service, items = new ServiceMapping(from item in pair.Value let category = item.Category select new ServiceMappingItem() { name = item.Category, uid = "landingpage.services." + service + "." + category, - landingPageType = "Service", + landingPageType = LandingPageTypeService, children = item.Uids.ToList() }) }).OrderBy(s => s.name)) @@ -145,8 +152,22 @@ private static void Merge(Dictionary> a, Dictionar { a[pair.Key] = new List(); } + // to-do: when product repo's mapping file is ready, should change the behavior to overwrite. a[pair.Key].AddRange(pair.Value); } } + + private static Tuple GetServiceHrefAndType(Dictionary mapping, string service) + { + string href; + if (mapping.TryGetValue(service, out href)) + { + return Tuple.Create(href, null); + } + else + { + return Tuple.Create(null, LandingPageTypeService); + } + } } }