Skip to content

Commit 465f29a

Browse files
authored
Merge pull request #52 from linkdotnet/feature/brand
Feature/brand
2 parents 94d5cac + cedab28 commit 465f29a

File tree

10 files changed

+58
-21
lines changed

10 files changed

+58
-21
lines changed

Readme.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The appsettings.json file has a lot of options to customize the content of the b
2323
```json
2424
{
2525
"BlogName": "linkdotnet",
26+
"BlogBrandUrl": "http//some.url/image.png",
2627
"GithubAccountUrl": "",
2728
"LinkedInAccountUrl": "",
2829
"Introduction": {
@@ -59,11 +60,12 @@ The appsettings.json file has a lot of options to customize the content of the b
5960

6061
| Property | Type | Description |
6162
| ------------------------- | -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
62-
| BlogName | string | Name of your blog. Is used in the navbar and is used as the title of the page. |
63+
| BlogName | string | Name of your blog. Is used in the navbar and is used as the title of the page. Will not be shown when `BlogBrandUrl` is set |
64+
| BlogBrandUrl | string | The url to an image which is used as a brand image in the navigation bar. If not set or `null` the `BlogName` will be shown |
6365
| GithubAccountUrl | string | Url to your github account. If not set the navigation link is not shown |
6466
| LinkedInAccountUrl | string | Url to your LinkedIn account. If not set the navigation link is not shown |
6567
| Introduction | | Is used for the introduction part of the blog |
66-
| Description | MarkdownString | Small introduction text for yourself. This is also used for `<meta name="description">` tag. For this the markup will be converted to plain text. |
68+
| Description | MarkdownString | Small introduction text for yourself. This is also used for `<meta name="description">` tag. For this the markup will be converted to plain text |
6769
| BackgroundUrl | string | Url or path to the background image |
6870
| ProfilePictureUrl | string | Url or path to your profile picture |
6971
| PersistenceProvider | string | Declares the type of the storage provider (one of the following: `SqlServer`, `SqliteServer`, `RavenDb`, `InMemory`). More in-depth explanation down below |
@@ -161,4 +163,4 @@ Furthermore the following tags are set:
161163
| Tag | Index | Display Blog Post |
162164
| ---------------------------------------- | ------------------------------------ | ----------------------------- |
163165
| Title of the web page | Defined in AppConfiguration.BlogName | Title of the blogpost |
164-
| &lt;meta name="keyword" content="" /&gt; | not set | Tags defined in the Blog Post |
166+
| &lt;meta name="keyword" content="" /&gt; | not set | Tags defined in the Blog Post |

src/LinkDotNet.Blog.Web/AppConfiguration.cs

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public record AppConfiguration
77
{
88
public string BlogName { get; init; }
99

10+
public string BlogBrandUrl { get; init; }
11+
1012
public string LinkedinAccountUrl { get; init; }
1113

1214
public bool HasLinkedinAccount => !string.IsNullOrEmpty(LinkedinAccountUrl);

src/LinkDotNet.Blog.Web/AppConfigurationFactory.cs

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public static AppConfiguration Create(IConfiguration config)
1414
var configuration = new AppConfiguration
1515
{
1616
BlogName = config["BlogName"],
17+
BlogBrandUrl = config["BlogBrandUrl"],
1718
GithubAccountUrl = config["GithubAccountUrl"],
1819
LinkedinAccountUrl = config["LinkedInAccountUrl"],
1920
Introduction = config.GetSection("Introduction").Get<Introduction>(),

src/LinkDotNet.Blog.Web/Shared/MainLayout.razor

+1-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
<NavMenu/>
77

88
<main>
9-
<div class="page">
10-
@Body
11-
</div>
9+
@Body
1210
</main>
1311
</div>
1412
<Footer></Footer>

src/LinkDotNet.Blog.Web/Shared/NavMenu.razor

+23-9
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,20 @@
22
@inject NavigationManager navigationManager
33
@implements IDisposable
44

5-
<nav class="navbar navbar-expand-lg position-absolute navbar-background inverted-colors navbar-dark" style="width: 100%">
5+
<nav class="navbar navbar-expand-lg navbar-background inverted-colors navbar-dark w-100">
66
<div class="container-fluid">
7-
<a class="nav-brand barcode ms-5" href="/">@configuration.BlogName</a>
7+
@if (configuration.BlogBrandUrl != null)
8+
{
9+
<a class="nav-brand ms-5" href="/">
10+
<img style="max-height: 62px;"
11+
src="@configuration.BlogBrandUrl.ToAbsoluteUrl(navigationManager.BaseUri)"
12+
alt="brand" />
13+
</a>
14+
}
15+
else
16+
{
17+
<a class="nav-brand barcode ms-5" href="/">@configuration.BlogName</a>
18+
}
819
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
920
<span class="navbar-toggler-icon"></span>
1021
</button>
@@ -13,23 +24,26 @@
1324
<li class="nav-item active"><a class="nav-link" href="/">Home</a></li>
1425
@if (configuration.HasLinkedinAccount)
1526
{
16-
<li class="nav-item"><a class="nav-link" target="_blank" href="@configuration.LinkedinAccountUrl"><i
17-
class="fab fa-linkedin"></i>
18-
LinkedIn</a></li>
27+
<li class="nav-item">
28+
<a class="nav-link" target="_blank" href="@configuration.LinkedinAccountUrl">
29+
<i
30+
class="fab fa-linkedin"></i>
31+
LinkedIn</a></li>
1932
}
2033
@if (configuration.HasGithubAccount)
2134
{
22-
<li class="nav-item"><a class="nav-link" target="_blank" href="@configuration.GithubAccountUrl"><i class="fab
23-
fa-github"></i>
24-
Github</a></li>
35+
<li class="nav-item">
36+
<a class="nav-link" target="_blank" href="@configuration.GithubAccountUrl"><i class="fab
37+
fa-github"></i>
38+
Github</a></li>
2539
}
2640
@if (configuration.IsAboutMeEnabled)
2741
{
2842
<li class="nav-item">
2943
<a class="nav-link" href="AboutMe"><i class="far fa-address-card"></i> About
3044
me</a></li>
3145
}
32-
46+
3347
<AccessControl CurrentUri="@currentUri"></AccessControl>
3448
<li class="nav-item d-flex">
3549
<SearchInput SearchEntered="NavigateToSearchPage"></SearchInput>

src/LinkDotNet.Blog.Web/appsettings.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"AllowedHosts": "*",
1010
"BlogName": "Blogname",
11+
"BlogBrandUrl": null,
1112
"GithubAccountUrl": "",
1213
"LinkedInAccountUrl": "",
1314
"Introduction": {

src/LinkDotNet.Blog.Web/wwwroot/css/basic.css

-4
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,6 @@ section {
145145
padding-bottom: 10px;
146146
}
147147

148-
.page {
149-
padding-top: 88px;
150-
}
151-
152148
.table th {
153149
background: var(--button-primary-color);
154150
color: var(--white);

src/LinkDotNet.Blog.Web/wwwroot/css/bundle.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/LinkDotNet.Blog.IntegrationTests/Web/Shared/NavMenuTests.cs

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Linq;
22
using AngleSharp.Html.Dom;
3+
using AngleSharpWrappers;
34
using Bunit;
45
using Bunit.TestDoubles;
56
using FluentAssertions;
@@ -81,8 +82,28 @@ public void ShouldPassCorrectUriToComponent()
8182
this.AddTestAuthorization();
8283
var cut = RenderComponent<NavMenu>();
8384

84-
Services.GetService<NavigationManager>()!.NavigateTo("test");
85+
Services.GetRequiredService<NavigationManager>().NavigateTo("test");
8586

8687
cut.FindComponent<AccessControl>().Instance.CurrentUri.Should().Contain("test");
8788
}
89+
90+
[Fact]
91+
public void ShouldShowBrandImageIfAvailable()
92+
{
93+
var config = new AppConfiguration
94+
{
95+
ProfileInformation = new ProfileInformation(),
96+
BlogBrandUrl = "http://localhost/img.png",
97+
};
98+
Services.AddScoped(_ => config);
99+
this.AddTestAuthorization();
100+
101+
var cut = RenderComponent<NavMenu>();
102+
103+
var brandImage = cut.Find(".nav-brand img");
104+
105+
var image = brandImage.Unwrap() as IHtmlImageElement;
106+
image.Should().NotBeNull();
107+
image.Source.Should().Be("http://localhost/img.png");
108+
}
88109
}

tests/LinkDotNet.Blog.UnitTests/Web/AppConfigurationFactoryTests.cs

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public void ShouldMapFromAppConfiguration()
1414
var inMemorySettings = new Dictionary<string, string>
1515
{
1616
{ "BlogName", "UnitTest" },
17+
{ "BlogBrandUrl", "http://localhost" },
1718
{ "GithubAccountUrl", "github" },
1819
{ "LinkedInAccountUrl", "linkedIn" },
1920
{ "ConnectionString", "cs" },
@@ -38,6 +39,7 @@ public void ShouldMapFromAppConfiguration()
3839
var appConfiguration = AppConfigurationFactory.Create(configuration);
3940

4041
appConfiguration.BlogName.Should().Be("UnitTest");
42+
appConfiguration.BlogBrandUrl.Should().Be("http://localhost");
4143
appConfiguration.GithubAccountUrl.Should().Be("github");
4244
appConfiguration.HasGithubAccount.Should().BeTrue();
4345
appConfiguration.LinkedinAccountUrl.Should().Be("linkedIn");

0 commit comments

Comments
 (0)