Do not remove trailing '.html' from permalinks by default

This commit is contained in:
fechin committed 2022-11-22 13:00:05 +08:00
1 parent bf51180d21
commit f3633415b8
12 files changed
+17 -22

No files matched your search

+1 -1
View File
@@ -19,7 +19,7 @@ permalink: :name.html
permalink_defaults:
pretty_urls:
trailing_index: false # Set to false to remove trailing 'index.html' from permalinks
trailing_html: false # Set to false to remove trailing '.html' from permalinks
trailing_html: true # Set to false to remove trailing '.html' from permalinks
# Directory
source_dir: source
+4 -4
View File
@@ -14,7 +14,7 @@
<meta name="description" content="<%- page_description() %>"/>
<!-- for social -->
<meta property="og:url" content="<%- ext_url_for(url) %>"/>
<meta property="og:url" content="<%- url_for(url) %>"/>
<meta property="og:title" content="<%- page_title() %>"/>
<meta property="og:site_name" content="<%- config.title %>"/>
<meta property="og:description" content="<%- page_description() %>"/>
@@ -36,9 +36,9 @@
<link rel="icon shortcut" type="image/png" href="/images/favicon.png?v=1"/>
<!-- misc -->
<link rel="canonical" href="<%- ext_url_for(url) %>"/>
<link rel="prefetch" href="<%- ext_url_for(config.url) %>"/>
<link rel="prerender" href="<%- ext_url_for(config.url) %>"/>
<link rel="canonical" href="<%- url_for(url) %>"/>
<link rel="prefetch" href="<%- url_for(config.url) %>"/>
<link rel="prerender" href="<%- url_for(config.url) %>"/>
<link rel="alternate" href="/atom.xml" title="<%- config.title %>" type="application/atom+xml"/>
<!-- font -->
+1 -1
View File
@@ -1,4 +1,4 @@
<a href="<%- ext_url_for(url) %>">
<a href="<%- url_for(url) %>">
<div class="card <%- background %>">
<i class="icon <%- icon %>"></i>
<p><%- title %></p>
@@ -1,7 +1,7 @@
<section class="w-full grid grid-cols-2 md:grid-cols-4 gap-6 md:gap-8">
<% theme.index_recommends.forEach(function (filePath) { %>
<% let post = site.posts.findOne({slug: filePath}); %>
<a href="<%= ext_url_for(post.path) %>">
<a href="<%= url_for(post.path) %>">
<div class="card <%= post.background %>">
<i class="icon <%= post.icon %>"></i>
<p><%= post.title %></p>
@@ -1,4 +1,4 @@
<a href="<%= ext_url_for(post.path) %>"
<a href="<%= url_for(post.path) %>"
class="group flex items-center p-3 bg-slate-50 rounded-lg hover:shadow dark:bg-slate-900 hover:bg-emerald-500 fadeIn">
<div class="ml-4 truncate hover:text-clip overflow-hidden">
<p class="mb-1 text-sm font-medium text-slate-900 dark:text-slate-300 group-hover:text-white"><%= post.title %>
+2 -2
View File
@@ -1,6 +1,6 @@
<% if (page.prev) { %>
<p>
<a href="<%= ext_url_for(page.prev.path) %>" rel="next" title="<%= page.prev.title %>">
<a href="<%= url_for(page.prev.path) %>" rel="next" title="<%= page.prev.title %>">
<%= __('prev', page.prev.title) %>
</a>
</p>
@@ -8,7 +8,7 @@
<% if (page.next) { %>
<p>
<a href="<%= ext_url_for(page.next.path) %>" rel="next" title="<%= page.next.title %>">
<a href="<%= url_for(page.next.path) %>" rel="next" title="<%= page.next.title %>">
<%= __('next', page.next.title) %>
</a>
</p>
+1 -1
View File
@@ -6,7 +6,7 @@
<% } %>
<% } else { %>
<% if (false){ %>
<h1><a href="<%- ext_url_for(page.path) %>"><%= page.title || __('no_title') %></a></h1>
<h1><a href="<%- url_for(page.path) %>"><%= page.title || __('no_title') %></a></h1>
<% } else { %>
<h1><%= page.title || __('no_title') %></h1>
<% } %>
+2 -2
View File
@@ -27,7 +27,7 @@
<div class="flex justify-center w-10 h-10 text-white p-5 rounded-full mr-4 <%- post.background %>">
<i class="self-center icon <%- post.icon %> text-2xl"></i>
</div>
<a href="<%- ext_url_for(post.path) %>" class="underline mx-1 font-medium text-slate-700 dark:text-slate-300">
<a href="<%- url_for(post.path) %>" class="underline mx-1 font-medium text-slate-700 dark:text-slate-300">
<%- post.title %> <span class="text-sm font-light text-slate-700 dark:text-slate-500">Cheat sheet</span>
</a>
</li>
@@ -52,7 +52,7 @@
<ul>
<% posts.forEach(function (post){ %>
<li class="mt-2">
<a href="<%- ext_url_for(post.path) %>" class="underline mx-1 text-sm text-slate-700 dark:text-slate-300"><%- post.title %></a>
<a href="<%- url_for(post.path) %>" class="underline mx-1 text-sm text-slate-700 dark:text-slate-300"><%- post.title %></a>
</li>
<% }); %>
</ul>
+1 -1
View File
@@ -11,7 +11,7 @@
<div class="w-full grid grid-cols-2 md:grid-cols-4 gap-6 md:gap-8 mb-6 text-slate-800">
<% site.categories.findOne({name: category}).posts.sort('-date').map(function(post){ %>
<%- partial('_partial/index/card', {
url: ext_url_for(post.path),
url: url_for(post.path),
title: post.title,
icon: post.icon == undefined ? 'icon-style' : post.icon,
background: post.background == undefined ? 'bg-emerald-500' : post.background
+2 -2
View File
@@ -8,12 +8,12 @@
<a href="#" class="px-2 py-1 text-slate-100 bg-slate-600 rounded hover:bg-slate-500">JavaScript</a>
</div>
<div class="mt-2">
<a href="<%- ext_url_for(post.path) %>"
<a href="<%- url_for(post.path) %>"
class="text-2xl font-bold text-slate-700 dark:text-slate-300 underline"><%= post.title %></a>
<p class="mt-2 text-slate-600 dark:text-slate-300"><%- post.excerpt %></p>
</div>
<div class="flex items-center justify-between mt-4">
<a href="<%- ext_url_for(post.path) %>" class="underline text-blue-500 dark:opacity-70">Read more</a>
<a href="<%- url_for(post.path) %>" class="underline text-blue-500 dark:opacity-70">Read more</a>
</div>
</div>
<% }); %>
-5
View File
@@ -66,9 +66,4 @@ hexo.extend.helper.register("page_image", function () {
imageURL = `${this.config.url}/assets/image/${homePng}?v=${version}`;
}
return imageURL;
});
hexo.extend.helper.register("ext_url_for", function (url) {
url = this.url_for(url);
return url.replace(/(\/index)?\.html$/, "");
});
+1 -1
View File
@@ -3,7 +3,7 @@ const {encodeURL} = require('hexo-util');
hexo.extend.helper.register("share_link", function (type) {
let title = this.page_title();
let description = this.page_description();
let url = this.ext_url_for(this.url);
let url = this.url_for(this.url);
let link = "";
switch (type) {
case "facebook":