66@using Microsoft .AspNetCore .Components .Sections
77@using MyLittleContentEngine .Services .Content .TableOfContents
88@inject ContentEngineOptions ContentEngineOptions
9- @inject IMarkdownContentService <DocSiteFrontMatter > MarkdownContentService
9+ @inject ILocalizedContentService <DocSiteFrontMatter > LocalizedContentService
1010@inject ITableOfContentService TableOfContentService
1111@inject DocSiteOptions DocSiteOptions
1212
2828 <meta property =" og:image" content =" @(DocSiteOptions.CanonicalBaseUrl?.TrimEnd('/') + '/' + DocSiteOptions.SocialImageUrl.TrimStart('/'))" />
2929 <meta name =" twitter:image" content =" @(DocSiteOptions.CanonicalBaseUrl?.TrimEnd('/') + '/' + DocSiteOptions.SocialImageUrl.TrimStart('/'))" />
3030 }
31+ @foreach ( var alt in _alternateLanguages )
32+ {
33+ <link rel =" alternate" hreflang =" @alt.Locale" href =" @(DocSiteOptions.CanonicalBaseUrl?.TrimEnd('/') + alt.Url)" />
34+ }
3135 </HeadContent >
36+
37+ @if (_isFallback )
38+ {
39+ <FallbackNotice RequestedLocale =" @_requestedLocale" DefaultLocale =" @LocalizedContentService.DefaultLocale" />
40+ }
41+
3242 <DocSiteArticle Title =" @_post.FrontMatter.Title"
3343 HtmlContent =" @_postContent"
3444 PreviousPageName =" @_previousPage?.Name"
5767 private NavigationTreeItem ? _previousPage ;
5868 private NavigationTreeItem ? _nextPage ;
5969 private Type ? _homeComponentType ;
70+ private bool _isFallback ;
71+ private string ? _requestedLocale ;
72+ private ImmutableList <AlternateLanguagePage > _alternateLanguages = [];
6073
6174 [MemberNotNull (nameof (_postContent ))]
6275 [MemberNotNull (nameof (_outline ))]
7386 fileName = " index" ;
7487 }
7588
76- var page = await MarkdownContentService . GetRenderedContentPageByUrlOrDefault (fileName );
77-
89+ var result = await LocalizedContentService . GetContentByUrl (fileName );
90+
7891 // If no index page found and we're on root, try to render Index component.
79- // This allows the user to have a custom page rather than markdown for their home page of the site.
80- if (page == null && fileName .Equals (" index" , StringComparison .OrdinalIgnoreCase ))
92+ if (result == null && fileName .Equals (" index" , StringComparison .OrdinalIgnoreCase ))
8193 {
8294 try
8395 {
84- var homeType = Type .GetType (" Index" ) ??
96+ var homeType = Type .GetType (" Index" ) ??
8597 AppDomain .CurrentDomain .GetAssemblies ()
8698 .SelectMany (a => a .GetTypes ())
8799 .FirstOrDefault (t => t .Name == " Index" && typeof (IComponent ).IsAssignableFrom (t ));
88-
100+
89101 if (homeType != null )
90102 {
91103 _homeComponentType = homeType ;
@@ -97,24 +109,31 @@ else
97109 // Fall through to show not found
98110 }
99111 }
100-
101- if (page == null )
112+
113+ if (result == null )
102114 {
103115 IsLoaded = false ;
104116 return ;
105117 }
106118
107- _outline = page .Value .Page .Outline ;
108- _post = page .Value .Page ;
109- _postContent = page .Value .HtmlContent ;
119+ _outline = result .Page .Outline ;
120+ _post = result .Page ;
121+ _postContent = result .HtmlContent ;
122+ _isFallback = result .IsFallback ;
123+ _requestedLocale = result .RequestedLocale ;
110124
111- var nextPrevious = await TableOfContentService .GetNavigationInfoAsync (page .Value .Page .Url );
125+ // Get locale-filtered navigation
126+ var locale = LocalizedContentService .GetLocaleFromUrl (fileName );
127+ var nextPrevious = await TableOfContentService .GetNavigationInfoForLocaleAsync (result .Page .Url , locale );
112128 if (nextPrevious != null )
113129 {
114130 _nextPage = nextPrevious .NextPage ;
115- _previousPage = nextPrevious .PreviousPage ;
131+ _previousPage = nextPrevious .PreviousPage ;
116132 }
117-
133+
134+ // Get alternate language links
135+ _alternateLanguages = await LocalizedContentService .GetAlternateLanguages (fileName );
136+
118137 IsLoaded = true ;
119138 }
120- }
139+ }
0 commit comments