From f3633415b8a515e48a1fdeca83edc2790390a2cc Mon Sep 17 00:00:00 2001 From: fechin Date: Tue, 22 Nov 2022 13:00:05 +0800 Subject: [PATCH] Do not remove trailing '.html' from permalinks by default --- _config.yml | 2 +- themes/coo/layout/_partial/head.ejs | 8 ++++---- themes/coo/layout/_partial/index/card.ejs | 2 +- themes/coo/layout/_partial/index/recommend.ejs | 2 +- themes/coo/layout/_partial/post/popular_card.ejs | 2 +- themes/coo/layout/_partial/post/prevnext.ejs | 4 ++-- themes/coo/layout/_partial/post/title.ejs | 2 +- themes/coo/layout/_partial/sidebar.ejs | 4 ++-- themes/coo/layout/index.ejs | 2 +- themes/coo/layout/notes.ejs | 4 ++-- themes/coo/scripts/seo.js | 5 ----- themes/coo/scripts/share.js | 2 +- 12 files changed, 17 insertions(+), 22 deletions(-) diff --git a/_config.yml b/_config.yml index afc2016..81b7c79 100644 --- a/_config.yml +++ b/_config.yml @@ -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 diff --git a/themes/coo/layout/_partial/head.ejs b/themes/coo/layout/_partial/head.ejs index 56bc7aa..b4fc3bd 100644 --- a/themes/coo/layout/_partial/head.ejs +++ b/themes/coo/layout/_partial/head.ejs @@ -14,7 +14,7 @@ - + @@ -36,9 +36,9 @@ - - - + + + diff --git a/themes/coo/layout/_partial/index/card.ejs b/themes/coo/layout/_partial/index/card.ejs index 4ab5867..b8a1e6f 100644 --- a/themes/coo/layout/_partial/index/card.ejs +++ b/themes/coo/layout/_partial/index/card.ejs @@ -1,4 +1,4 @@ - +

<%- title %>

diff --git a/themes/coo/layout/_partial/index/recommend.ejs b/themes/coo/layout/_partial/index/recommend.ejs index fef03ac..51818bb 100644 --- a/themes/coo/layout/_partial/index/recommend.ejs +++ b/themes/coo/layout/_partial/index/recommend.ejs @@ -1,7 +1,7 @@
<% theme.index_recommends.forEach(function (filePath) { %> <% let post = site.posts.findOne({slug: filePath}); %> - +

<%= post.title %>

diff --git a/themes/coo/layout/_partial/post/popular_card.ejs b/themes/coo/layout/_partial/post/popular_card.ejs index 1ab10f6..59703e9 100644 --- a/themes/coo/layout/_partial/post/popular_card.ejs +++ b/themes/coo/layout/_partial/post/popular_card.ejs @@ -1,4 +1,4 @@ -

<%= post.title %> diff --git a/themes/coo/layout/_partial/post/prevnext.ejs b/themes/coo/layout/_partial/post/prevnext.ejs index 8aca2f0..e2e08fc 100644 --- a/themes/coo/layout/_partial/post/prevnext.ejs +++ b/themes/coo/layout/_partial/post/prevnext.ejs @@ -1,6 +1,6 @@ <% if (page.prev) { %>

-

@@ -8,7 +8,7 @@ <% if (page.next) { %>

-

diff --git a/themes/coo/layout/_partial/post/title.ejs b/themes/coo/layout/_partial/post/title.ejs index 9da0a47..8f10bfa 100644 --- a/themes/coo/layout/_partial/post/title.ejs +++ b/themes/coo/layout/_partial/post/title.ejs @@ -6,7 +6,7 @@ <% } %> <% } else { %> <% if (false){ %> -

<%= page.title || __('no_title') %>

+

<%= page.title || __('no_title') %>

<% } else { %>

<%= page.title || __('no_title') %>

<% } %> diff --git a/themes/coo/layout/_partial/sidebar.ejs b/themes/coo/layout/_partial/sidebar.ejs index b96fd31..5bd9d18 100644 --- a/themes/coo/layout/_partial/sidebar.ejs +++ b/themes/coo/layout/_partial/sidebar.ejs @@ -27,7 +27,7 @@
- + <%- post.title %> Cheat sheet @@ -52,7 +52,7 @@ diff --git a/themes/coo/layout/index.ejs b/themes/coo/layout/index.ejs index 4145d0c..3fe80db 100644 --- a/themes/coo/layout/index.ejs +++ b/themes/coo/layout/index.ejs @@ -11,7 +11,7 @@
<% 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 diff --git a/themes/coo/layout/notes.ejs b/themes/coo/layout/notes.ejs index ffa6142..6e4ce06 100644 --- a/themes/coo/layout/notes.ejs +++ b/themes/coo/layout/notes.ejs @@ -8,12 +8,12 @@ JavaScript
- <%= post.title %>

<%- post.excerpt %>

<% }); %> diff --git a/themes/coo/scripts/seo.js b/themes/coo/scripts/seo.js index 0bc90f3..d587967 100644 --- a/themes/coo/scripts/seo.js +++ b/themes/coo/scripts/seo.js @@ -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$/, ""); }); \ No newline at end of file diff --git a/themes/coo/scripts/share.js b/themes/coo/scripts/share.js index f21d7ee..97cf383 100644 --- a/themes/coo/scripts/share.js +++ b/themes/coo/scripts/share.js @@ -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":