Skip to content

Commit

Permalink
Sharing & link resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
alanta committed Nov 19, 2020
1 parent 256eb23 commit c2380c4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 21 deletions.
2 changes: 2 additions & 0 deletions Models/IPageMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Kentico.Kontent.Statiq.Memoirs.Models
public interface IPageMetadata
{
public string MetadataTwitterCreator { get; }

public string Url { get; }
public string UrlSlug { get; }
public string MetadataMetaKeywords { get; }
public IEnumerable<IAsset> MetadataTwitterImage { get; }
Expand Down
30 changes: 16 additions & 14 deletions appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,19 @@
"DeliveryOptions": {
"ProjectId": "e10d7fbd-315f-01e2-20a5-e067cdf43f2f"
},
"LinkHideExtensions": "true",
"Host": "",
"LinksUseHttps": true,
"Site": {
"name": "Memoirs",
"title": "Memoirs",
"description": "I will take you on the fabulous world of exploration. Travel, culture, lifestyle. Eat, Pray, Love!",
"Logo": "assets/images/logo.png",
"Favicon": "assets/images/logo.png",
"Copyright": "Memoirs",
"lazyimages": false,
"authorbox": true
}
}
"LinkHideExtensions": "true",
"Host": "",
"LinksUseHttps": true,
"LinkRoot": "",
"LinkLowercase": true,
"Site": {
"name": "Memoirs",
"title": "Memoirs",
"description": "I will take you on the fabulous world of exploration. Travel, culture, lifestyle. Eat, Pray, Love!",
"Logo": "assets/images/logo.png",
"Favicon": "assets/images/logo.png",
"Copyright": "Memoirs",
"lazyimages": false,
"authorbox": true
}
}
10 changes: 7 additions & 3 deletions input/Shared/pagination.cshtml
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
@using Statiq.Common
@model MemoirsTheme.Models.IPagedContent
@{
var context = ViewData["StatiqExecutionContext"] as IExecutionContext;
}
@if (Model.TotalItems > 1)
{
<div class="pagination">
@if (Model.PreviousUrl != null)
{
<a class="ml-1 mr-1" href="@Model.PreviousUrl">&laquo; </a>
<a class="ml-1 mr-1" href="@context.GetLink(Model.PreviousUrl)">&laquo; </a>
}
else
{
Expand All @@ -16,12 +20,12 @@
<span class="ml-1 mr-1">@(index.ToString())</span>
}
else {
<a class="ml-1 mr-1" href="@Model.PagingUrl(index)">@index</a>
<a class="ml-1 mr-1" href="@context.GetLink(Model.PagingUrl(index))">@index</a>
}
}

@if(Model.NextUrl != null){
<a class="ml-1 mr-1" href="@Model.NextUrl"> &raquo;</a>
<a class="ml-1 mr-1" href="@context.GetLink(Model.NextUrl)"> &raquo;</a>
}else{
<span> &raquo;</span>
}
Expand Down
12 changes: 9 additions & 3 deletions input/Shared/share.html → input/Shared/share.cshtml
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
@using Statiq.Common
@using System.Web
@model Kentico.Kontent.Statiq.Memoirs.Models.IPageMetadata
@{
var url = IExecutionContext.Current.GetLink(Model.Url, true);
}
<div class="share">
<p>
Share
</p>
<ul>
<li class="ml-1 mr-1">
<a target="_blank" href="https://twitter.com/intent/tweet?text={{ page.title }}&url={{ page.url | absolute_url }}" onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
<a target="_blank" href="https://twitter.com/intent/tweet?text=@HttpUtility.UrlEncode(Model.Title)&url=@HttpUtility.UrlEncode(url)" onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
<i class="fab fa-twitter"></i>
</a>
</li>

<li class="ml-1 mr-1">
<a target="_blank" href="https://facebook.com/sharer.php?u={{ page.url | absolute_url }}" onclick="window.open(this.href, 'facebook-share', 'width=550,height=435');return false;">
<a target="_blank" href="https://facebook.com/sharer.php?u=@HttpUtility.UrlEncode(url)" onclick="window.open(this.href, 'facebook-share', 'width=550,height=435');return false;">
<i class="fab fa-facebook-f"></i>
</a>
</li>

<li class="ml-1 mr-1">
<a target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url={{ page.url | absolute_url }}" onclick="window.open(this.href, 'width=550,height=435');return false;">
<a target="_blank" href="https://www.linkedin.com/shareArticle?mini=true&url=@HttpUtility.UrlEncode(url)" onclick="window.open(this.href, 'width=550,height=435');return false;">
<i class="fab fa-linkedin-in"></i>
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion input/post.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{% include comments.html %}

<!-- Share -->
{% include share.html %}
<partial name="Shared/share" model="Model"/>

<!-- Related Post -->
{% include related-posts.html %}
Expand Down

0 comments on commit c2380c4

Please sign in to comment.