Skip to content

Commit

Permalink
Merge pull request quarkiverse#101 from quarkiverse/seo
Browse files Browse the repository at this point in the history
Fix quarkiverse#80: SEO tag for Qute
  • Loading branch information
ia3andy authored Sep 23, 2024
2 parents 6677f98 + 647af8e commit 0be6ce8
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 36 deletions.
32 changes: 2 additions & 30 deletions blog/site/_includes/head.html
Original file line number Diff line number Diff line change
@@ -1,40 +1,12 @@
<head>
<meta charset="utf-8">
<title>
{#if page.title ne site.title}{page.title} - {site.title}{#else}{site.title}{/if}
</title>

{#seo page site /}

<!-- Edit site and author settings in `_config.yml` to make the social details your own -->
<base href="{site.rootUrl.relative}">
<meta content="{site.title}" property="og:site_name">


<meta name="twitter:card" content="summary">
{#if page.title}
<meta name="twitter:title" content="{page.title}">
{#else}
<meta name="twitter:title" content="{site.title}">
{/if}
{#if page.url}
<meta name="twitter:url" content="{site.url.absolute}">
{/if}
{#if page.description}
<meta name="twitter:description" content="{page.description}">
{#else}
<meta name="twitter:description" content="{site.description}">
{/if}
{#if page.img}
<meta name="twitter:image:src" content="{site.rootUrl.absolute.resolve('assets/img/').resolve(page.img)}">
{/if}

{#if page.description}
<meta name="description" content="{page.description}">
{#else}
<meta name="description" content="{site.description}">
{/if}
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta property="og:image" content="">
<link rel="shortcut icon" href="{site.rootUrl.absolute.resolve('/static/assets/img/favicon/favicon.ico')}" type="image/x-icon">
<link rel="apple-touch-icon" href="{site.rootUrl.absolute.resolve('assets/img/favicon/apple-touch-icon.png')}">
<link rel="apple-touch-icon" sizes="72x72" href="{site.rootUrl.absolute.resolve('assets/img/favicon/apple-touch-icon-72x72.png')}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ public PageUrl url() {
public ZonedDateTime date() {
final String d = data.getString(DATE_KEY);
if (d == null) {
return ZonedDateTime.now();
// must be NULL if no date found to distinguish website (null) from blog posts (date)
return null;
}
return ZonedDateTime.parse(d, DateTimeFormatter.ISO_DATE_TIME);
}
Expand All @@ -59,4 +60,4 @@ public Object data(String name) {
return null;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
public class RoqCollection extends ArrayList<Page> {

public RoqCollection(List<Page> pages) {
super(pages.stream().sorted(Comparator.comparing(Page::date).reversed()).toList());
super(pages.stream()
.sorted(Comparator.comparing(Page::date, Comparator.nullsLast(Comparator.naturalOrder())).reversed())
.toList());
}

public Page findNext(Page page) {
Expand Down Expand Up @@ -55,4 +57,4 @@ public boolean isSecond() {
}
}

}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package io.quarkiverse.roq.frontmatter.runtime;

import java.time.LocalDateTime;
import java.util.Locale;
import java.util.Objects;

import io.quarkus.qute.TemplateGlobal;

@TemplateGlobal
public class RoqTemplateGlobal {
public static LocalDateTime now = LocalDateTime.now();
}
static LocalDateTime now = LocalDateTime.now();
static String roqVersion = Objects.toString(RoqTemplateGlobal.class.getPackage().getImplementationVersion(), "???");
static String locale = Locale.getDefault().toString();
}
12 changes: 12 additions & 0 deletions roq-frontmatter/runtime/src/main/resources/templates/tags/seo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{#seoTitle pageTitle=page.title siteTitle=site.title /}
{#seoDescription pageDescription=page.description siteDescription=site.description /}
{#seoAuthor pageAuthor=page.author siteAuthor=site.author /}
{#seoUrl pageUrl=page.url siteUrl=site.url /}
{#seoType page /}
{#seoImage page site /}
{#seoVerifications webmasterVerifications=site.webmasterVerifications /}
{#seoPaginator paginator=page.paginator /}
{#seoFacebook facebook=site.facebook /}
{#seoTwitter twitter=site.twitter /}
{#seoLocale pageLocale=page.lang siteLocale=site.lang defaultLocale=global:locale /}
{#seoGenerator name="Quarkus Roq" version=global:roqVersion /}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{#if pageAuthor || siteAuthor}
<!-- SEO AUTHOR -->
<meta property="article:author" content="{pageAuthor ?: siteAuthor}" />
<meta name="author" content="{pageAuthor ?: siteAuthor}" />
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{#if pageDescription || siteDescription}
<!-- SEO DESCRIPTION -->
<meta name="description" content="{pageDescription ?: siteDescription}">
<meta property="og:description" content="{pageDescription ?: siteDescription}" />
<meta name="twitter:description" content="{pageDescription ?: siteDescription}">
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{#if facebook}
<!-- SEO FACEBOOK -->
{#if facebook.admins}
<meta property="fb:admins" content="{facebook.admins}" />
{/if}

{#if facebook.publisher}
<meta property="article:publisher" content="{facebook.publisher}" />
{/if}

{#if facebook.app_id}
<meta property="fb:app_id" content="{facebook.app_id}" />
{/if}
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{#if name}
<!-- SEO GENERATOR -->
<meta name="generator" content="{name} v{version}" />
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{#if page.img and site.rootUrl}
<!-- SEO IMAGE -->
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image:src" content="{page.img.toUrl.absoluteOrElseFrom(site.rootUrl.relative.resolve('static/images/'))}" />
<meta property="og:image" content="{page.img.toUrl.absoluteOrElseFrom(site.rootUrl.relative.resolve('static/images/'))}" />
{#else}
<!-- SEO IMAGE -->
<meta name="twitter:card" content="summary">
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{#if pageLocale || siteLocale}
<!-- SEO LOCALE -->
<meta property="og:locale" content="{pageLocale ?: siteLocale}" />
{#else}
<!-- SEO LOCALE -->
<meta property="og:locale" content="{defaultLocale}" />
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{#if paginator}
<!-- SEO PAGINATOR -->
{#if paginator.previous}
<link rel="prev" href="{paginator.previous.relative}" />
{/if}
{#if paginator.next}
<link rel="next" href="{paginator.next.relative}" />
{/if}
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{#if pageTitle || siteTitle}
<!-- SEO TITLE -->
<title>
{#if pageTitle ne siteTitle}{pageTitle} - {siteTitle}{#else}{siteTitle}{/if}
</title>
<meta name="twitter:title" content="{#if pageTitle ne siteTitle}{pageTitle} - {siteTitle}{#else}{siteTitle}{/if}">
{/if}
{#if siteTitle}
<meta property="og:site_name" content="{siteTitle}">
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{#if twitter}
<!-- SEO TWITTER -->
<meta name="twitter:site" content="@{twitter}" />
<meta name="twitter:creator" content="@{twitter}" />
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{#if it.date}
<!-- SEO TYPE -->
<meta property="og:type" content="article" />
<meta property="article:published_time" content="{it.date}" />
{#else}
<!-- SEO TYPE -->
<meta property="og:type" content="website" />
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{#if pageUrl || siteUrl}
<!-- SEO URL -->
<link rel="canonical" href="{pageUrl ?: siteUrl.absolute}" />
<meta property="og:url" content="{pageUrl ?: siteUrl.absolute}" />
<meta name="twitter:url" content="{pageUrl ?: siteUrl.absolute}">
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{#if webmasterVerifications}
<!-- SEO VERIFICATION -->
{#if webmasterVerifications.google}
<meta name="google-site-verification" content="{webmasterVerifications.google}">
{/if}
{#if webmasterVerifications.bing}
<meta name="msvalidate.01" content="{webmasterVerifications.bing}">
{/if}
{#if webmasterVerifications.alexa}
<meta name="alexaVerifyID" content="{webmasterVerifications.alexa}">
{/if}
{#if webmasterVerifications.yandex}
<meta name="yandex-verification" content="{webmasterVerifications.yandex}">
{/if}
{#if webmasterVerifications.baidu}
<meta name="baidu-site-verification" content="{webmasterVerifications.baidu}">
{/if}
{#if webmasterVerifications.facebook}
<meta name="facebook-domain-verification" content="{webmasterVerifications.facebook}">
{/if}
{/if}

0 comments on commit 0be6ce8

Please sign in to comment.