Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServiceCollectionExtensions.cs
More file actions
Latest commit
48 lines (41 loc) · 2.07 KB
/
Copy pathServiceCollectionExtensions.cs
File metadata and controls
48 lines (41 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
usingMicrosoft.Extensions.DependencyInjection;
usingShellDocs.Components.Chrome;
usingShellDocs.Components.Content;
usingShellDocs.Core;
usingShellDocs.Markdown;
namespaceShellDocs.Components;
publicstaticclassServiceCollectionExtensions
{
publicstaticIServiceCollectionAddShellDocs(thisIServiceCollectionservices,Action<ShellDocsOptions>?configure=null)
{
varoptions=newShellDocsOptions();
configure?.Invoke(options);
services.AddSingleton(options);
services.AddScoped<MobileNavState>();
services.AddScoped<ThemeState>();
services.AddScoped<SearchState>();
services.AddScoped<SidebarCollapseState>();
services.AddScoped<CodeGroupSyncState>();
services.AddScoped<DocsPageState>();
/* Auto-register the shipped content primitives so `razor:preview` blocks
in markdown can reference <Callout>, <Card>, <Steps>, <FileTree> etc.
without the consumer calling RegisterComponent<T>() themselves.
Dogfoods RegisterComponentsFromAssembly against our own Content
namespace — new primitives added under Content/ auto-appear here
without a maintainer edit to this file. Internal render machinery
(MarkdownContent, PreviewFrame) opts out via [ShellDocsIgnore]. */
options.RegisterComponentsFromAssembly<Callout>(t =>t.Namespace=="ShellDocs.Components.Content");
services.AddSingleton<TypeRegistry>(_ =>options.BuildTypeRegistry());
services.AddSingleton<MarkdownRenderer>(sp =>newMarkdownRenderer(sp.GetRequiredService<TypeRegistry>()));
services.AddSingleton<NavigationGraph>(_ =>
{
if(!Directory.Exists(options.ContentRoot))
{
returnnewNavigationGraph(newNavigationNode{Url="/",Kind=NodeKind.Section});
}
returnNavigationGraphBuilder.Build(options.ContentRoot);
});
services.AddSingleton<SearchIndex>(sp =>SearchIndex.FromGraph(sp.GetRequiredService<NavigationGraph>()));
returnservices;
}
}