-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathLinksRenderPartial.cshtml
More file actions
51 lines (50 loc) · 1.97 KB
/
LinksRenderPartial.cshtml
File metadata and controls
51 lines (50 loc) · 1.97 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
49
50
51
@model cloudscribe.SimpleContent.ContentTemplates.ViewModels.ListWithContentModel
@using cloudscribe.SimpleContent.ContentTemplates
@using cloudscribe.SimpleContent.ContentTemplates.Configuration
@using cloudscribe.SimpleContent.ContentTemplates.ViewModels
@inject IStringLocalizer<ContentTemplateResources> sr
@inject ILinkListOptionsProvider optionsProvider
@inject IOptions<IconCssClasses> iconClassesAccessor
@{
var icons = iconClassesAccessor.Value;
var sorted = Model.Items.OrderBy(x => x.Sort).ToList();
var options = await optionsProvider.ResolveLinkListOptions(Context.Request.Host.Host, Context.Request.Path);
var imageStyle = "height:" + options.ImageRenderMaxHeight.ToString() + "px;";
}
@functions {
public string GetTarget(ListItemModel item)
{
if (item.OpensInNewWindow) { return "_blank"; }
return null;
}
}
<div class="content-top">
@Html.Raw(Model.ContentAbove)
</div>
<ul class="list-group">
@for (int i = 0; i < Model.Items.Count; i++)
{
<li class="list-group-item d-flex justify-content-between align-items-start flex-column">
<div>
<h4 class="d-flex align-items-start"><a href="@sorted[i].LinkUrl" target="@GetTarget(sorted[i])">@sorted[i].Title</a>
@if (GetTarget(sorted[i]) == "_blank")
{
<span class="@icons.OpenInNewWindow ms-2 fs-6" aria-hidden="true"></span>
}
</h4>
</div>
<div class="d-flex me-auto">
@if (!string.IsNullOrWhiteSpace(sorted[i].ResizedUrl))
{
<a target="@GetTarget(sorted[i])" href="@sorted[i].LinkUrl">
<img class="flex-start me-2" src="@sorted[i].ResizedUrl" style="@imageStyle" alt="@sorted[i].AltText" />
</a>
}
<p class="list-group-item-description">@sorted[i].Description</p>
</div>
</li>
}
</ul>
<div class="mt-3 content-bottom">
@Html.Raw(Model.ContentBelow)
</div>