Skip to content

Commit

Permalink
Meta Cleanup & New
Browse files Browse the repository at this point in the history
  • Loading branch information
kristofzerbe committed Jul 17, 2024
1 parent 1816b80 commit d8ce45e
Show file tree
Hide file tree
Showing 9 changed files with 149 additions and 100 deletions.
11 changes: 10 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ offline: false

# Site
title: kiko.io
designation: kiko.io's {TITLE}
subtitle: Memorable (Tech) Stuff
description: Blog about memorable (tech) stuff by Kristof Zerbe
description_short: by Kristof Zerbe
Expand All @@ -17,6 +18,7 @@ hero:
file: $19-05-Israel-0228.jpg
name: Sea Wall
url: /images/hero.jpg
favicon: favicon.ico
icon: /images/icon-192x192.png
keywords:
author: Kristof Zerbe
Expand Down Expand Up @@ -246,7 +248,14 @@ feed:
blogroll:
data_file: "21.13 Blogroll.md"
opml_template: opml.handlebars
opml_path: blogroll.opml
opml_path: blogroll.xml

# Search (OpenSearch)
search:
path: search
url_parameter: q
opensearch_template: opensearch.handlebars
opensearch_path: opensearch.xml

# Sitemap: WAS! https://github.com/hexojs/hexo-generator-sitemap
sitemap:
Expand Down
8 changes: 8 additions & 0 deletions scripts/events/on-generateBefore-get-dynamic-blogroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ hexo.on('generateBefore', function() {
const mdPage = path.join("_dynamic", page.name + ".md");
page = getMD(hexo, mdPage, page);

page.designation = config.designation.replace("{TITLE}", page.title);
page.owner = {
name: config.author,
email: config.email,
id: config.url
}
page.docs = page.permalink;

let blogrollUpdated = fs.statSync(mdBlogroll).mtime; // modified time
if (!page.updated || blogrollUpdated > new Date(page.updated)) {
page.updated = updateMDField(hexo, mdPage, "updated", blogrollUpdated);
Expand Down
5 changes: 3 additions & 2 deletions scripts/generators/generator-dynamic-blogroll.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ hexo.extend.generator.register("dynamic-blogroll", async function(locals) {
let page = locals.dynamic.blogroll;

page.content = page.content
.replace("{% blogroll_length %}", page.items.length)
.replace("{% generation_date %}", _helpers.moment().format("dddd, DD MMMM YYYY hh:mm"));
.replaceAll("{% blogroll_length %}", page.items.length)
.replaceAll("{% blogroll_path %}", config.blogroll.opml_path)
.replaceAll("{% generation_date %}", _helpers.moment().format("dddd, DD MMMM YYYY hh:mm"));

let promises = [];

Expand Down
34 changes: 32 additions & 2 deletions scripts/generators/generator-dynamic-search.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,46 @@
const log = require('hexo-log')({ debug: false, silent: false });
const { magenta } = require('chalk');
const path = require('path');
const fs = require("hexo-fs");
const handlebars = require("handlebars");

const _rootDir = hexo.source_dir.replace("source", "");

hexo.extend.generator.register("dynamic-search", async function(locals) {
log.info("Generating Dynamic Page " + magenta("SEARCH") + " ...");

const config = this.config;

let result = [];

// Page
let page = locals.dynamic.search;
page.urlparam = config.search.url_parameter;

return {
result.push({
data: page,
path: path.join(page.name, "index.html"),
layout: "search"
};
});

// opensearch.xml
const osTemplate = path.join(_rootDir, config.template_dir, config.search.opensearch_template);
if (!fs.existsSync(osTemplate)) { throw "OpenSearch Template file not found"; }

const osSource = fs.readFileSync(osTemplate).toString('utf8');
const os = handlebars.compile(osSource);
const osResult = os({
shortname: config.title,
faviconUrl: config.url + "/" + config.favicon,
searchUrl: config.url + "/" + config.search.path,
searchParameter: config.search.url_parameter
});

result.push({
path: config.search.opensearch_path,
data: osResult
});


return result;
});
2 changes: 1 addition & 1 deletion source/_dynamic/blogroll.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ I think everyone who runs a blog also reads a lot of other blogs. So do I. Be it

Over the years, the articles of certain bloggers keep popping up in my lists or notes and I want to share the blogs/websites of these {% blogroll_length %} amazing people with you here ... in a good ol' blogroll, including the last post fetched on {% generation_date %}.

There's also an <a href="/blogroll.opml" download="blogroll.opml">OPML file</a> for the quick import into your feed reader ...
There's also an <a href="/{% blogroll_path %}" download="{% blogroll_path %}">OPML file (XML)</a> for the quick import into your feed reader ...

---
8 changes: 8 additions & 0 deletions templates/opensearch.handlebars
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>{{shortname}}</ShortName>
<Description>Search {{shortname}}</Description>
<InputEncoding>UTF-8</InputEncoding>
<Image width="16" height="16" type="image/x-icon">{{faviconUrl}}</Image>
<Url type="text/html" method="get" template="{{searchUrl}}?{{searchParameter}}={searchTerms}&amp;ref=opensearch"/>
<moz:SearchForm>{{searchUrl}}</moz:SearchForm>
</OpenSearchDescription>
11 changes: 7 additions & 4 deletions templates/opml.handlebars
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<opml version="1.0">
<head>
<title>kiko.io's Blogroll</title>
{{#if updated}}
<dateCreated>{{toISOString updated}}</dateCreated>
{{else}}
<title>{{designation}}</title>
<dateCreated>{{toISOString date}}</dateCreated>
{{#if updated}}
<dateModified>{{toISOString updated}}</dateModified>
{{/if}}
<ownerName>{{owner.name}}</ownerName>
<ownerEmail>{{owner.email}}</ownerEmail>
<ownerId>{{owner.id}}</ownerId>
<docs>{{docs}}</docs>
</head>
<body>
{{#each items}}
Expand Down
168 changes: 79 additions & 89 deletions themes/landscape/layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -195,131 +195,121 @@
}
%>

<head data-area="<%= meta.area %>"
data-subarea="<%= meta.subarea %>"
data-type="<%= meta.type %>">
<head data-area="<%= meta.area %>" data-subarea="<%= meta.subarea %>"data-type="<%= meta.type %>">
<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="generator" content="<%= config.meta_generator %>">
<meta name="author" content="<%= config.author %>">
<meta name="fediverse:creator" content="@<%= config.mastodon.user %>@<%= config.mastodon.server %>" />

<title><%= meta.title %></title>
<meta name="author" content="<%= config.author %>">
<meta name="title" content="<%= meta.title %>">
<% if (meta.description) { %>
<% if (meta.description) { %>
<meta name="description" content="<%= meta.description %>">
<% }%>
<% if (excerpt) { %>
<% }%>
<% if (excerpt) { %>
<meta name="excerpt" content="<%= excerpt %>">
<% }%>

<link rel="canonical" href="<%= url.replace("index.html", "") %>">
<% if (!meta.app) { %>
<link rel="manifest" href="/manifest.json">
<link rel="icon" href="/favicon.ico">
<link rel="apple-touch-icon" href="/images/apple-touch-icon.png">
<meta name="theme-color" content="#444">
<% } else { %>
<link rel="manifest" href="manifest.json">
<link rel="icon" href="favicon.ico">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<meta name="theme-color" content="<%= meta.app.color %>">
<% }%>

<%#!-- JSON-LD (schema.org) for Google --%>
<% if (!meta.app) { %>
<%
let jsonPartial = "json-ld-" + meta.type;
let jsonLD = partial('_partial/meta/' + jsonPartial, { meta: meta });
try {
jsonLD = jsonLD.replace(/\\/g, '\\\\');
jsonLD = JSON.stringify(JSON.parse(jsonLD));
} catch (error) {
console.error(error);
console.log(jsonLD);
console.log(excerptDesc);
}
%>
<script type="application/ld+json"><%- jsonLD %></script>
<% }%>

<%#!-- Open Graph --%>
<% }%>

<meta property="og:site_name" content="<%= config.title %>">
<meta property="og:type" content="blog">
<meta property="og:url" content="<%= url.replace("index.html", "") %>">
<meta property="og:title" content="<%= meta.title %>">
<% if (meta.description) { %>
<% if (meta.description) { %>
<meta property="og:description" content="<%= meta.description %>">
<% } %>
<% } %>
<meta property="og:logo" content="<%= config.url + config.icon %>" />
<meta property="og:image" content="<%= config.url + meta.imageUrl %>">
<meta property="og:locale" content="en_US">

<meta property="fediverse:creator" content="@<%= config.mastodon.user %>@<%= config.mastodon.server %>" />

<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="<%= url.replace("index.html", "") %>">
<meta property="twitter:title" content="<%= meta.title %>">
<% if (meta.description) { %>
<% if (meta.description) { %>
<meta property="twitter:description" content="<%= meta.description %>">
<% } %>
<% } %>
<meta property="twitter:image" content="<%= config.url + meta.imageUrl %>">

<%#!-- webmention.io --%>
<% if (!meta.app) {
let jsonPartial = "json-ld-" + meta.type;
let jsonLD = partial('_partial/meta/' + jsonPartial, { meta: meta });
try {
jsonLD = jsonLD.replace(/\\/g, '\\\\');
jsonLD = JSON.stringify(JSON.parse(jsonLD));
} catch (error) {
console.error(error);
console.log(jsonLD);
console.log(excerptDesc);
}
%>
<script type="application/ld+json"><%- jsonLD %></script><% }%>

<link rel="canonical" href="<%= url.replace("index.html", "") %>">

<link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/" type="text/html" />
<link rel="license" href="https://creativecommons.org/licenses/by-sa/4.0/rdf" type="application/rdf+xml" />

<link rel="webmention" href="https://webmention.io/<%= config.title %>/webmention" />
<link rel="pingback" href="https://webmention.io/<%= config.title %>/xmlrpc" />

<%#!-- IndieAuth --%>
<link rel="authorization_endpoint" href="https://indieauth.com/auth" />
<link rel="token_endpoint" href="https://tokens.indieauth.com/token" />
<link href="https://github.com/<%= config.github_user %>" rel="me authn">
<link href="mailto:<%= config.email %>" rel="me authn">

<link rel="me authn" href="https://github.com/<%= config.github_user %>">
<link rel="me authn" href="mailto:<%= config.email %>">
<link rel="me authn" href="https://<%= config.mastodon.server %>/@<%= config.mastodon.user %>">

<%#!-- Feeds --%>
<!-- <link rel="alternate" href="%= url_for(config.feed.default) %"
title="%= meta.title %" type="application/atom+xml"> -->
<%
config.feed.feed_types.forEach(e => {
if (e.alternate_link === true) { %>
<link rel="alternate" href="<%= url_for(e.output) %>" title="<%= e.title %>" type="<%= e.content %>">
<% }
}); %>

<link rel="preload" href="/css/fonts/lexend/webfonts/Lexend-ExtraLight.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/fonts/lexend/webfonts/Lexend-Light.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/fonts/lexend/webfonts/Lexend-Regular.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/fonts/lexend/webfonts/Lexend-Medium.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/fonts/lexend/webfonts/Lexend-SemiBold.woff2" as="font" type="font/woff2" crossorigin>
<link rel="blogroll" type="text/xml" href="<%= config.url %>/<%= config.blogroll.opml_path %>" title="<%= config.designation.replace("{TITLE}", "Blogroll") %>">
<link rel="search" type="application/opensearchdescription+xml" href="<%= config.url %>/<%= config.search.opensearch_path %>" title="<%= config.title %>"/>

<% config.feed.feed_types.forEach(e => { if (e.alternate_link === true) { %>
<link rel="alternate" type="<%= e.content %>" href="<%= config.url %>/<%= e.output %>" title="<%= config.designation.replace("{TITLE}", e.title) %>">
<% }}); %>

<meta name="color-scheme" content="light dark">
<% if (!meta.app) { %>
<meta name="theme-color" content="#444">
<link rel="manifest" href="/manifest.json">
<link rel="icon" href="/<%= config.favicon %>">
<link rel="apple-touch-icon" href="/images/apple-touch-icon.png">
<% } else { %>
<meta name="theme-color" content="<%= meta.app.color %>">
<link rel="manifest" href="manifest.json">
<link rel="icon" href="favicon.ico">
<link rel="apple-touch-icon" href="apple-touch-icon.png">
<% }%>

<link rel="preload" as="font" type="font/woff2" href="/css/fonts/lexend/webfonts/Lexend-ExtraLight.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/lexend/webfonts/Lexend-Light.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/lexend/webfonts/Lexend-Regular.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/lexend/webfonts/Lexend-Medium.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/lexend/webfonts/Lexend-SemiBold.woff2" crossorigin>

<link rel="preload" href="/css/fonts/opensans/opensans-regular.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/fonts/opensans/opensans-italic.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/fonts/opensans/opensans-semibold.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/fonts/opensans/opensans-semibolditalic.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/opensans/opensans-regular.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/opensans/opensans-italic.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/opensans/opensans-semibold.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/opensans/opensans-semibolditalic.woff2" crossorigin>

<link rel="preload" href="/css/fonts/sourcecodepro/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/fonts/sourcecodepro/WOFF2/TTF/SourceCodePro-It.ttf.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/fonts/sourcecodepro/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/fonts/sourcecodepro/WOFF2/TTF/SourceCodePro-BoldIt.ttf.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/sourcecodepro/WOFF2/TTF/SourceCodePro-Regular.ttf.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/sourcecodepro/WOFF2/TTF/SourceCodePro-It.ttf.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/sourcecodepro/WOFF2/TTF/SourceCodePro-Bold.ttf.woff2" crossorigin>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/sourcecodepro/WOFF2/TTF/SourceCodePro-BoldIt.ttf.woff2" crossorigin>

<link rel="preload" href="/css/fonts/forkawesome/forkawesome-webfont.woff2" as="font" type="font/woff2" crossorigin>

<% if (!page.photograph) { %>
<link rel="preload" as="image" id="img-preload" href="/images/hero.jpg"
imagesrcset="/images/hero-mobile.jpg 480w, /images/hero-tablet.jpg 768w">
<link rel="preload" as="image" id="photo-preload" href="/images/hero.jpg"
imagesrcset="/images/hero-mobile.jpg 480w, /images/hero-tablet.jpg 768w">
<% } else { %>
<link rel="preload" as="image" id="img-preload" href="<%= meta.imageUrl %>"
imagesrcset="<%= meta.imageUrl.replace("normal", "mobile") %> 480w, <%= meta.imageUrl.replace("normal", "tablet") %> 768w">
<link rel="preload" as="image" id="photo-preload" href="<%= meta.photoUrl %>"
imagesrcset="<%= meta.photoUrl.replace("normal", "mobile") %> 480w, <%= meta.photoUrl.replace("normal", "tablet") %> 768w">
<% } %>
<link rel="preload" as="font" type="font/woff2" href="/css/fonts/forkawesome/forkawesome-webfont.woff2" crossorigin>

<% if (!page.photograph) { %>
<link rel="preload" as="image" type="image/jpeg" href="/images/hero.jpg" imagesrcset="/images/hero-mobile.jpg 480w, /images/hero-tablet.jpg 768w" id="img-preload">
<link rel="preload" as="image" type="image/jpeg" href="/images/hero.jpg" imagesrcset="/images/hero-mobile.jpg 480w, /images/hero-tablet.jpg 768w" id="photo-preload">
<% } else { %>
<link rel="preload" as="image" type="image/jpeg" href="<%= meta.imageUrl %>" imagesrcset="<%= meta.imageUrl.replace("normal", "mobile") %> 480w, <%= meta.imageUrl.replace("normal", "tablet") %> 768w" id="img-preload">
<link rel="preload" as="image" type="image/jpeg" href="<%= meta.photoUrl %>" imagesrcset="<%= meta.photoUrl.replace("normal", "mobile") %> 480w, <%= meta.photoUrl.replace("normal", "tablet") %> 768w" id="photo-preload">
<% } %>

<%- css('css/dist/asset-bundle.min.css') %>
<%- css('css/style.css') %>

<% if (page.photograph) { %>
<% if (page.photograph) { %>
<style>
#banner {
background-size: cover;
Expand All @@ -334,7 +324,7 @@
#banner { background-image: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, rgba(0,0,0,0) 75%), url("/photos/normal/<%= page.photograph.file %>"); }
}
</style>
<% } %>
<% } %>

<script>
var theme = "light"; //default
Expand Down
2 changes: 1 addition & 1 deletion themes/landscape/layout/search.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
const queryString = window.location.search;
const urlParams = new URLSearchParams(queryString);
const searchString = urlParams.get("q");
const searchString = urlParams.get("<%= page.urlparam %>");
window.addEventListener('DOMContentLoaded', (event) => {
let pagefind = new PagefindUI({
Expand Down

0 comments on commit d8ce45e

Please sign in to comment.