|
1 | 1 | @using LinkDotNet.Blog.Domain
|
2 |
| -<div class="d-flex flex-row justify-content-center" style="font-size: 1.25em;"> |
3 |
| - @if (Social.HasLinkedinAccount) |
| 2 | +<div class="d-flex flex-row justify-content-center h3 gap-4 py-2"> |
| 3 | + @foreach (var account in AllSocialAccounts.Where(a => a.HasAccount)) |
4 | 4 | {
|
5 |
| - <a id="linkedin" class="nav-link px-3 py-2" target="_blank" href="@Social.LinkedInAccountUrl" aria-label="LinkedIn" rel="noreferrer"> |
6 |
| - <i class="linkedin"></i> |
7 |
| - </a> |
8 |
| - } |
9 |
| - @if (Social.HasGithubAccount) |
10 |
| - { |
11 |
| - <a id="github" class="nav-link px-3 py-2" target="_blank" href="@Social.GithubAccountUrl" aria-label="Github" rel="noreferrer"> |
12 |
| - <i class="github"></i> |
13 |
| - </a> |
14 |
| - } |
15 |
| - @if (Social.HasTwitterAccount) |
16 |
| - { |
17 |
| - <a id="twitter" class="nav-link px-3 py-2" target="_blank" href="@Social.TwitterAccountUrl" aria-label="Twitter" rel="noreferrer"> |
18 |
| - <i class="twitter"></i> |
19 |
| - </a> |
20 |
| - } |
21 |
| - |
22 |
| - @if (Social.HasYoutubeAccount) |
23 |
| - { |
24 |
| - <a id="youtube" class="nav-link px-3 py-2" target="_blank" href="@Social.YoutubeAccountUrl" aria-label="Youtube" rel="noreferrer"> |
25 |
| - <i class="youtube"></i> |
| 5 | + <a id="@account.Id" class="nav-link" target="_blank" href="@account.Url" aria-label="@account.Name" rel="noreferrer"> |
| 6 | + <i class="@account.Icon"></i> |
26 | 7 | </a>
|
27 | 8 | }
|
28 | 9 | </div>
|
29 | 10 |
|
30 | 11 | @code {
|
| 12 | + private List<SocialAccount> AllSocialAccounts => |
| 13 | + [ |
| 14 | + // Icons have to be defined in the icons.css |
| 15 | + new("linkedin", Social.HasLinkedinAccount, Social.LinkedInAccountUrl, "LinkedIn", "linkedin"), |
| 16 | + new("github", Social.HasGithubAccount, Social.GithubAccountUrl, "Github", "github"), |
| 17 | + new("twitter", Social.HasTwitterAccount, Social.TwitterAccountUrl, "Twitter", "twitter"), |
| 18 | + new("youtube", Social.HasYoutubeAccount, Social.YoutubeAccountUrl, "Youtube", "youtube") |
| 19 | + ]; |
31 | 20 |
|
32 | 21 | [Parameter, EditorRequired]
|
33 | 22 | public required Social Social { get; set; }
|
| 23 | + |
| 24 | + private record SocialAccount(string Id, bool HasAccount, string? Url, string Name, string Icon); |
34 | 25 | }
|
0 commit comments