File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ @inject NavigationManager Nav
2+ @inject IJSRuntime JS
3+
4+ @using Microsoft .AspNetCore .Components
5+
6+ @if (_markup .HasValue )
7+ {
8+ @_markup.Value
9+ }
10+
11+ @code {
12+ [Parameter , EditorRequired ]
13+ public string Id { get ; set ; } = default ! ;
14+
15+ private MarkupString ? _markup ;
16+
17+ protected override void OnParametersSet ()
18+ {
19+ if (string .IsNullOrWhiteSpace (Id ))
20+ {
21+ _markup = null ;
22+ return ;
23+ }
24+
25+ _markup = new MarkupString (
26+ $$"""
27+ <!-- Google tag (gtag.js) -->
28+ <script async src="https://www.googletagmanager.com/gtag/js?id={{Id }}"></script>
29+ <script>
30+ window.dataLayer = window.dataLayer || [];
31+ function gtag(){dataLayer.push(arguments);}
32+ gtag('js', new Date());
33+
34+ gtag('config', '{{Id }}');
35+ </script>
36+ """ );
37+ }
38+ }
Original file line number Diff line number Diff line change 1- @inherits LayoutComponentBase
1+ @using BlazorApps .Components
2+ @inherits LayoutComponentBase
3+ @inject IConfiguration Config
4+
5+ <GoogleAnalytics Id =" @Config[" GoogleAnalytics:Id " ]" />
26
37<FluentLayout >
48 <FluentHeader >
5- BlazorApps
9+ @Config ["Title"]
610 </FluentHeader >
711 <FluentStack Class =" main" Orientation =" Orientation.Horizontal" Width =" 100%" >
812 <NavMenu />
2024 </FluentBodyContent >
2125 </FluentStack >
2226 <FluentFooter >
23- <a href =" https://www.fluentui-blazor.net " target =" _blank" >Documentation and demos </a >
27+ Copyright & copy ; 2024 - @DateTime.UtcNow.Year & nbsp ; <a href =" https://www.junian.dev/ " target =" _blank" >junian.dev </a >
2428 <FluentSpacer />
25- <a href =" https://learn.microsoft. com/en-us/aspnet/core/ blazor" target =" _blank" >About Blazor </a >
29+ <a href =" https://github. com/junian/ blazor-apps " target =" _blank" >GitHub </a >
2630 </FluentFooter >
2731</FluentLayout >
Original file line number Diff line number Diff line change 1+ {
2+ "Title" : " Blazor Lab" ,
3+ "GoogleAnalytics" : {
4+ "Id" : " G-YDEHTJ6WH0"
5+ }
6+ }
Original file line number Diff line number Diff line change 44< head >
55 < meta charset ="utf-8 " />
66 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 " />
7- < title > BlazorApps </ title >
7+ < title > Blazor Apps </ title >
88 < base href ="/ " />
99 < link rel ="preload " id ="webassembly " />
1010 < link href ="_content/Microsoft.FluentUI.AspNetCore.Components/css/reboot.css " rel ="stylesheet " />
3131 < script src ="_framework/blazor.webassembly#[.{fingerprint}].js "> </ script >
3232</ body >
3333
34- </ html >
34+ </ html >
You can’t perform that action at this time.
0 commit comments