Skip to content

Commit

Permalink
Fix SEO links
Browse files Browse the repository at this point in the history
  • Loading branch information
ia3andy committed Sep 23, 2024
1 parent 0be6ce8 commit 48ae1bf
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 17 deletions.
2 changes: 1 addition & 1 deletion blog/site/_includes/head.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<head>
<meta charset="utf-8">

{#seo page site /}
{#seo page site collections /}

<!-- Edit site and author settings in `_config.yml` to make the social details your own -->
<base href="{site.rootUrl.relative}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,22 @@ public RoqCollection(List<Page> pages) {
.toList());
}

public Page findNext(Page page) {
public Page resolveNextPage(Page page) {
if (page.next() == null) {
return null;
}
return this.get(page.next());
}

public Page findPrevious(Page page) {
public Page resolvePreviousPage(Page page) {
if (page.previous() == null) {
return null;
}
return this.get(page.previous());
}

public Page findPrev(Page page) {
return this.findPrevious(page);
public Page resolvePrevPage(Page page) {
return this.resolvePreviousPage(page);
}

public List<Page> paginated(Paginator paginator) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,37 @@
import java.util.Map;

public record RoqCollections(Map<String, RoqCollection> collections) {
public RoqCollection get(String name) {
return collections.get(name);
}

}
public Page resolveNextPage(Page page) {
final RoqCollection collection = resolveCollection(page);
if (collection == null)
return null;
return collection.resolveNextPage(page);
}

public Page resolvePreviousPage(Page page) {
final RoqCollection collection = resolveCollection(page);
if (collection == null)
return null;
return collection.resolvePreviousPage(page);
}

public RoqCollection resolveCollection(Page page) {
if (page.collection() == null) {
return null;
}
final RoqCollection collection = this.get(page.collection());
if (collection == null) {
return null;
}
return collection;
}

public Page resolvePrevPage(Page page) {
return this.resolvePreviousPage(page);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public static Object data(Page page, String key) {
}

@TemplateExtension(matchName = "*")
public static RoqCollection data(RoqCollections collections, String key) {
return collections.collections().get(key);
public static RoqCollection collection(RoqCollections collections, String key) {
return collections.get(key);
}

public static Object readTime(Page page) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{#seoType page /}
{#seoImage page site /}
{#seoVerifications webmasterVerifications=site.webmasterVerifications /}
{#seoPaginator paginator=page.paginator /}
{#seoPaginator page collections /}
{#seoFacebook facebook=site.facebook /}
{#seoTwitter twitter=site.twitter /}
{#seoLocale pageLocale=page.lang siteLocale=site.lang defaultLocale=global:locale /}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
{#if paginator}
{#if page.paginator}
<!-- SEO PAGINATOR -->
{#if paginator.previous}
<link rel="prev" href="{paginator.previous.relative}" />
{#if page.paginator.previous}
<link rel="prev" href="{page.paginator.previous.absolute}" />
{/if}
{#if paginator.next}
<link rel="next" href="{paginator.next.relative}" />
{#if page.paginator.next}
<link rel="next" href="{page.paginator.next.absolute}" />
{/if}
{/if}
{#else}
<!-- SEO COLLECTION PAGES -->
{#let prevPage = collections.resolvePreviousPage(page)}
{#if prevPage}
<link rel="prev" href="{prevPage.url.absolute}" />
{/if}
{/let}
{#let nextPage = collections.resolveNextPage(page) }
{#if nextPage}
<link rel="next" href="{nextPage.url.absolute}" />
{/if}
{/let}
{/if}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{#if pageTitle || siteTitle}
<!-- SEO TITLE -->
{#fragment title rendered=false}
{#if pageTitle && pageTitle ne siteTitle}{pageTitle} - {siteTitle}{#else}{siteTitle}{/if}
{/fragment}
<title>
{#if pageTitle ne siteTitle}{pageTitle} - {siteTitle}{#else}{siteTitle}{/if}
{#include $title /}
</title>
<meta name="twitter:title" content="{#if pageTitle ne siteTitle}{pageTitle} - {siteTitle}{#else}{siteTitle}{/if}">
<meta name="twitter:title" content="{#include $title /}">
{/if}
{#if siteTitle}
<meta property="og:site_name" content="{siteTitle}">
Expand Down

0 comments on commit 48ae1bf

Please sign in to comment.