Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v2.8.2 #472

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/build-and-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
paths:
- 'source/js/**'
- 'source/css/**'
- 'source/build/**'

jobs:
build:
Expand Down
14 changes: 12 additions & 2 deletions .github/workflows/preview-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
preview-deployment:
runs-on: ubuntu-latest
environment:
name: ${{ github.event_name == 'pull_request_target' && 'PR Preview' || 'Preview' }}
name: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.user.login == 'EvanNotFound' && 'PR Preview Bypass' || github.event_name == 'pull_request_target' && 'PR Preview' || 'Preview' }}
url: ${{ steps.deploy-to-vercel.outputs.preview-url }}
steps:
- name: Determine checkout details
Expand Down Expand Up @@ -121,4 +121,14 @@ jobs:
ALIAS_DOMAINS: |
redefine-preview.vercel.app
redefine-preview-git-{SHA}.vercel.app
PR_PREVIEW_DOMAIN: "redefine-preview-pr-{PR}.vercel.app"
PR_PREVIEW_DOMAIN: "redefine-preview-pr-{PR}.vercel.app"

- name: Debug environment selection
run: |
echo "Event name: ${{ github.event_name }}"
echo "PR author: ${{ github.event.pull_request.user.login }}"
echo "Selected environment: ${{
github.event_name == 'pull_request_target' && github.event.pull_request.user.login == 'EvanNotFound' && 'PR Preview Bypass' ||
github.event_name == 'pull_request_target' && 'PR Preview' ||
'Preview'
}}"
8 changes: 6 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ global:
enable: false
custom_message: # Custom message. If empty, the site title will be displayed
# Whether to enable open graph
open_graph: true
open_graph:
enable: true
image: /images/redefine-og.webp # default og:image
description: Hexo Theme Redefine, Redefine Your Hexo Journey.
# Google Analytics
google_analytics:
enable: false # Whether to enable Google Analytics
Expand Down Expand Up @@ -275,6 +278,7 @@ articles:
image_alignment: center # image alignment. left, center
image_caption: false # Whether to display image caption
link_icon: true # Whether to display link icon
delete_mask: false # Add mask effect to <del> tags, hiding content by default and revealing on hover
title_alignment: left # Title alignment. left, center
headings_top_spacing: # Top spacing for headings from h1-h6
h1: 3.2rem
Expand Down Expand Up @@ -443,7 +447,7 @@ plugins:
# Mermaid JS. Requires hexo-filter-mermaid-diagrams (npm i hexo-filter-mermaid-diagrams). See https://mermaid.js.org/
mermaid:
enable: false # enable mermaid or not
version: "9.3.0" # default v9.3.0
version: "11.4.1" # default v11.4.1
# PLUGINS <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< end


Expand Down
28 changes: 22 additions & 6 deletions layout/components/header/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
'cdnjs': 'https://cdnjs.cloudflare.com',
'zstatic': 'https://s4.zstatic.net',
'npmmirror': 'https://registry.npmmirror.com',

}; %>
<% if (cdnLinks[provider]) { %>
<link rel="preconnect" href="<%= cdnLinks[provider] %>" crossorigin>
Expand All @@ -31,8 +30,25 @@
<meta name="robots" content="index,follow">
<meta name="googlebot" content="index,follow">
<meta name="revisit-after" content="1 days">
<% if (theme.global.open_graph) { %>
<%- open_graph() %>

<% checkDeprecation(
theme.global.open_graph === true,
'open_graph',
"Using 'open_graph: true' is deprecated. Please update to the new format:\nglobal:\n open_graph:\n enable: true\n image: your_image_path\n description: your_description"
) %>
<% if (theme.global.open_graph?.enable || theme.global.open_graph === true) { %>
<%
let ogImage = page.og_image || theme.global.open_graph?.image;
let ogDescription = page.og_description || theme.global.open_graph?.description || page.description || config.description;
let author = page.author || config.author || 'Redefine Team';
%>
<%- open_graph({
image: ogImage,
author: author,
description: ogDescription,
twitter_card: 'summary',
twitter_image: ogImage,
}) %>
<% } %>
<% if (theme.global.google_analytics.enable) { %>
<!-- Google tag (gtag.js) -->
Expand Down Expand Up @@ -92,9 +108,9 @@
<%- css('css/style') %>

<% if (theme.developer && theme.developer.enable) {%>
<%- css('build/css/tailwind.css') %>
<%- css('css/build/tailwind.css') %>
<% } else {%>
<%- renderCSS('build/css/tailwind.css') %>
<%- renderCSS('css/build/tailwind.css') %>
<% } %>

<%- renderCSS('fonts/GeistMono/geist-mono.css') %>
Expand All @@ -116,7 +132,7 @@
<link href="<%- theme.global.fonts.title.url %>" rel="stylesheet">
<% } %>
<% if (theme.global.preloader === true || theme.global.preloader.enable === true) { %>
<%- renderJS('js/libs/anime.min.js')%>
<%- renderJS('libs/anime.min.js')%>
<% } %>

<%- export_config() %>
Expand Down
4 changes: 2 additions & 2 deletions layout/components/plugins/aplayer.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div id="aplayer"></div>
<%- renderJS('js/libs/APlayer.min.js') %>
<%- renderJS('js/plugins/aplayer.js') %>
<%- renderJS('libs/APlayer.min.js') %>
<%- renderJS('plugins/aplayer.js') %>
58 changes: 31 additions & 27 deletions layout/components/scripts.ejs
Original file line number Diff line number Diff line change
@@ -1,86 +1,90 @@
<%- renderJS([
'js/tools/imageViewer.js',
'js/utils.js',
'js/main.js',
'js/layouts/navbarShrink.js',
'js/tools/scrollTopBottom.js',
'js/tools/lightDarkSwitch.js',
'js/layouts/categoryList.js'
'tools/imageViewer.js',
'utils.js',
'main.js',
'layouts/navbarShrink.js',
'tools/scrollTopBottom.js',
'tools/lightDarkSwitch.js',
'layouts/categoryList.js'
],{
module: true
}) %>

<% if (theme.navbar.search.enable) { %>
<%- renderJS('js/tools/localSearch.js', {
<%- renderJS('tools/localSearch.js', {
module: true
}) %>
<% } %>

<% if (theme.articles.code_block.copy) { %>
<%- renderJS('js/tools/codeBlock.js', {
<%- renderJS('tools/codeBlock.js', {
module: true
}) %>
<% } %>

<% if (theme.articles.lazyload) { %>
<%- renderJS('js/layouts/lazyload.js', {
<%- renderJS('layouts/lazyload.js', {
module: true
}) %>
<% } %>

<% if (theme.footer.runtime) { %>
<%- renderJS('js/tools/runtime.js') %>
<%- renderJS('js/libs/odometer.min.js') %>
<%- renderJS('tools/runtime.js') %>
<%- renderJS('libs/odometer.min.js') %>
<%- renderCSS('assets/odometer-theme-minimal.css') %>
<% } %>

<% if (theme.home_banner.subtitle.length !== 0) { %>
<%- renderJS('js/libs/Typed.min.js') %>
<%- renderJS('js/plugins/typed.js', {
<%- renderJS('libs/Typed.min.js') %>
<%- renderJS('plugins/typed.js', {
module: true
}) %>
<% } %>

<% if (theme.plugins.mermaid.enable) { %>
<%- renderJS('js/libs/mermaid.min.js') %>
<%- renderJS('js/plugins/mermaid.js') %>
<% if (theme.plugins.mermaid.version === '11.4.1') { %>
<%- renderJS('libs/mermaid.min.js') %>
<% } else { %>
<script src="https://cdn.jsdelivr.net/npm/mermaid@<%= theme.plugins.mermaid.version %>/dist/mermaid.min.js"></script>
<% } %>
<%- renderJS('plugins/mermaid.js') %>
<% } %>

<% if (theme.masonry || theme.photos || theme.gallery) { %>
<%- renderJS('js/libs/minimasonry.min.js') %>
<%- renderJS('js/plugins/masonry.js', {
<%- renderJS('libs/minimasonry.min.js') %>
<%- renderJS('plugins/masonry.js', {
module: true
}) %>
<% } %>

<% if (theme.global.preloader === false || theme.global.preloader.enable === false) { %>
<%- renderJS('js/libs/anime.min.js')%>
<%- renderJS('libs/anime.min.js')%>
<% } %>


<% if (theme.articles.toc.enable) { %>
<%- renderJS([
'js/tools/tocToggle.js',
'js/layouts/toc.js',
'js/plugins/tabs.js'
'tools/tocToggle.js',
'layouts/toc.js',
'plugins/tabs.js'
], {
module: true,
swupReload: true
}) %>
<% } %>

<%- renderJS('js/libs/moment-with-locales.min.js', { swupReload: true }) %>
<%- renderJS('js/layouts/essays.js', { swupReload: true, module: true }) %>
<%- renderJS('libs/moment-with-locales.min.js', { swupReload: true }) %>
<%- renderJS('layouts/essays.js', { swupReload: true, module: true }) %>

<% if (theme.articles.pangu_js) { %>
<%- renderJS([
'js/libs/pangu.min.js',
'js/plugins/pangu.js'
'libs/pangu.min.js',
'plugins/pangu.js'
]) %>
<% } %>

<% if (theme.bookmarks && theme.bookmarks.length !== 0) { %>
<%- renderJS('js/layouts/bookmarkNav.js', {
<%- renderJS('layouts/bookmarkNav.js', {
module: true
}) %>
<% } %>
12 changes: 6 additions & 6 deletions layout/components/swup.ejs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<%- renderJS([
'js/libs/Swup.min.js',
'js/libs/SwupSlideTheme.min.js',
'js/libs/SwupScriptsPlugin.min.js',
'js/libs/SwupProgressPlugin.min.js',
'js/libs/SwupScrollPlugin.min.js',
'js/libs/SwupPreloadPlugin.min.js']
'libs/Swup.min.js',
'libs/SwupSlideTheme.min.js',
'libs/SwupScriptsPlugin.min.js',
'libs/SwupProgressPlugin.min.js',
'libs/SwupScrollPlugin.min.js',
'libs/SwupPreloadPlugin.min.js']
) %>
<script>
const swup = new Swup({
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
"scripts": {
"npm:publish": "npm run build && npm publish",
"build": "npm run build:css && npm run build:js",
"build:css": "tailwindcss build -i source/css/tailwind.source.css -o source/build/css/tailwind.css --minify",
"build:css": "tailwindcss build -i source/css/tailwind.source.css -o source/css/build/tailwind.css --minify",
"build:js": "node source/js/build.js",
"watch:css": "tailwindcss build -i source/css/tailwind.source.css -o source/build/css/tailwind.css --watch --minify",
"watch:css": "tailwindcss build -i source/css/tailwind.source.css -o source/css/build/tailwind.css --watch --minify",
"prepare": "husky"
},
"repository": {
Expand Down
27 changes: 27 additions & 0 deletions scripts/filters/delete-mask-handle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* delete mask */

"use strict";

hexo.extend.filter.register(
"after_post_render",
function (data) {
const theme = this.theme;

// 处理del标签的代码
const regPureDelTag = /<del(?:\s+[^>]*)?>((?:(?!<\/?del[\s>])[^])*)<\/del>/g;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix potential regex issue with empty character class

The regular expression includes a negated empty character class [^] which could be problematic. Consider using a more explicit pattern.

-const regPureDelTag = /<del(?:\s+[^>]*)?>((?:(?!<\/?del[\s>])[^])*)<\/del>/g;
+const regPureDelTag = /<del(?:\s+[^>]*)?>((?:(?!<\/?del[\s>])[\s\S])*)<\/del>/g;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const regPureDelTag = /<del(?:\s+[^>]*)?>((?:(?!<\/?del[\s>])[^])*)<\/del>/g;
const regPureDelTag = /<del(?:\s+[^>]*)?>((?:(?!<\/?del[\s>])[\s\S])*)<\/del>/g;
🧰 Tools
🪛 Biome (1.9.4)

[error] 11-11: The regular expression includes this negated empty character class.

Negated empty character classes match anything.
If you want to match against [, escape it [.
Otherwise, remove the character class or fill it.

(lint/correctness/noEmptyCharacterClassInRegex)


data.content = data.content.replace(
regPureDelTag,
function (match, html) {
// 只有在配置为true时才添加mask类
if (theme.config.articles.style.delete_mask === true) {
return `<del class="mask">${html}</del>`;
}
return match;
}
);

return data;
},
0
);
20 changes: 18 additions & 2 deletions scripts/helpers/theme-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ hexo.extend.helper.register("renderJS", function (path, options = {}) {
const { module = false, async = false, swupReload = false } = options;

if (Array.isArray(path)) {
path = path.map((p) => "build/" + p);
path = path.map((p) => "js/build/" + p);
} else {
path = "build/" + path;
path = "js/build/" + path;
}

const cdnProviders = {
Expand Down Expand Up @@ -209,3 +209,19 @@ hexo.extend.helper.register("renderCSS", function (path) {
hexo.extend.helper.register("getThemeVersion", function () {
return themeVersion;
});

hexo.extend.helper.register("checkDeprecation", function (condition, id, message) {
if (condition) {
// Use Set to ensure each warning is only logged once per Hexo process
if (!global.deprecationWarnings) {
global.deprecationWarnings = new Set();
}

if (!global.deprecationWarnings.has(id)) {
hexo.log.warn(`${message}`);
global.deprecationWarnings.add(id);
}
return true;
}
return false;
});
2 changes: 1 addition & 1 deletion scripts/modules/note-large.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ hexo.extend.tag.register("notel", postNoteLarge, { ends: true });
hexo.extend.tag.register("notelarge", postNoteLarge, { ends: true });
hexo.extend.tag.register("notel-large", postNoteLarge, { ends: true });
hexo.extend.tag.register("notes-large", postNoteLarge, { ends: true });
hexo.extend.tag.register("subwarning", postNoteLarge, { ends: true });
hexo.extend.tag.register("subwarning", postNoteLarge, { ends: true });
2 changes: 1 addition & 1 deletion scripts/modules/note.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ function postNote(args, content) {

hexo.extend.tag.register("note", postNote, { ends: true });
hexo.extend.tag.register("notes", postNote, { ends: true });
hexo.extend.tag.register("subnote", postNote, { ends: true });
hexo.extend.tag.register("subnote", postNote, { ends: true });
1 change: 0 additions & 1 deletion source/build/css/tailwind.css

This file was deleted.

1,284 changes: 0 additions & 1,284 deletions source/build/js/libs/mermaid.min.js

This file was deleted.

2 changes: 0 additions & 2 deletions source/build/js/plugins/aplayer.js

This file was deleted.

1 change: 0 additions & 1 deletion source/build/js/plugins/aplayer.js.map

This file was deleted.

1 change: 1 addition & 0 deletions source/css/build/tailwind.css

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion source/css/common/markdown.styl
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,24 @@
margin 1rem 0 1rem


del.mask
text-decoration none !important
transition .2s cubic-bezier(.25, .46, .45, .94) color, .2s cubic-bezier(.25, .46, .45, .94) background

*
transition .35s cubic-bezier(.25, .46, .45, .94) opacity

&:not(:hover)
color transparent !important
background #000 !important

*
opacity 0 !important

&, *
border none !important



& > table,
.tab-pane > table
Expand Down Expand Up @@ -315,4 +333,4 @@


svg
display inline-block
display inline-block
Binary file added source/images/redefine-og.webp
Binary file not shown.
2 changes: 1 addition & 1 deletion source/js/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const glob = require("glob-promise");

const THEME_ROOT = path.join(__dirname, "../..");
const SOURCE_DIR = path.join(THEME_ROOT, "source/js");
const BUILD_DIR = path.join(THEME_ROOT, "source/build/js");
const BUILD_DIR = path.join(THEME_ROOT, "source/js/build");
const IGNORE_PATTERNS = [
path.join(SOURCE_DIR, "libs/**"),
path.join(BUILD_DIR, "**"),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2,314 changes: 2,314 additions & 0 deletions source/js/build/libs/mermaid.min.js

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading