Add solitude

This commit is contained in:
IF-chan
2024-07-05 21:01:19 +08:00
parent 26d71c4fbc
commit 71758b9fce
289 changed files with 23277 additions and 0 deletions
+142
View File
@@ -0,0 +1,142 @@
/**
* Solitude
* Merge CDN
*/
'use strict'
const { version } = require('../../package.json')
const path = require('path')
hexo.extend.filter.register('before_generate', () => {
const themeConfig = hexo.theme.config
const { CDN } = themeConfig
const thirdPartySrc = hexo.render.renderSync({ path: path.join(hexo.theme_dir, '/plugins.yml'), engine: 'yaml' })
const internalSrc = {
main: {
name: 'hexo-theme-solitude',
file: 'js/main.js',
version
},
utils: {
name: 'hexo-theme-solitude',
file: 'js/utils.js',
version
},
local_search: {
name: 'hexo-theme-solitude',
file: 'js/search/local.js',
version
},
algolia_js: {
name: 'hexo-theme-solitude',
file: 'js/search/algolia.js',
version
},
cover_local: {
name: 'hexo-theme-solitude',
file: 'js/covercolor/local.js',
version
},
cover_api: {
name: 'hexo-theme-solitude',
file: 'js/covercolor/api.js',
version
},
music_js: {
name: 'hexo-theme-solitude',
file: 'js/music.js',
version
},
right_menu_js: {
name: 'hexo-theme-solitude',
file: 'js/right_menu.js',
version
},
translate_js:{
name: 'hexo-theme-solitude',
file: 'js/tw_cn.js',
version
},
efu_ai: {
name: 'hexo-theme-solitude',
file: 'js/third_party/efu_ai.min.js',
version
},
commentBarrage: {
name: 'hexo-theme-solitude',
file: 'js/third_party/barrage.min.js',
version
},
waterfall: {
name: 'hexo-theme-solitude',
file: 'js/third_party/waterfall.min.js',
version
},
universe_js: {
name: 'hexo-theme-solitude',
file: 'js/third_party/universe.min.js',
version
},
envelope_js: {
name: 'hexo-theme-solitude',
file: 'js/third_party/envelope.min.js',
version
}
}
const minFile = file => {
return file.replace(/(?<!\.min)\.(js|css)$/g, ext => '.min' + ext)
}
const createCDNLink = (data, type, cond = '') => {
Object.keys(data).forEach(key => {
let { name, version, file, other_name } = data[key]
const cdnjs_name = other_name || name
const cdnjs_file = file.replace(/^[lib|dist]*\/|browser\//g, '')
const min_cdnjs_file = minFile(cdnjs_file)
if (cond === 'internal') file = `source/${file}`
const min_file = minFile(file)
const verType = CDN.version ? (type === 'local' ? `?v=${version}` : `@${version}`) : ''
const value = {
version,
name,
file,
cdnjs_file,
min_file,
min_cdnjs_file,
cdnjs_name
}
const cdnSource = {
local: cond === 'internal' ? `${cdnjs_file + verType}` : `/pluginsSrc/${name}/${file + verType}`,
jsdelivr: `https://cdn.jsdelivr.net/npm/${name}${verType}/${min_file}`,
unpkg: `https://unpkg.com/${name}${verType}/${file}`,
cdnjs: `https://cdnjs.cloudflare.com/ajax/libs/${cdnjs_name}/${version}/${min_cdnjs_file}`,
custom: (CDN.custom_format || '').replace(/\$\{(.+?)}/g, (match, $1) => value[$1]),
}
data[key] = cdnSource[type]
})
if (cond === 'internal') data.main_css = 'css/index.css' + (CDN.version ? `?v=${version}` : '')
return data
}
// delete null value
const deleteNullValue = obj => {
if (!obj) return
for (const i in obj) {
obj[i] === null && delete obj[i]
}
return obj
}
themeConfig.cdn = Object.assign(
createCDNLink(internalSrc, CDN.internal, 'internal'),
createCDNLink(thirdPartySrc, CDN.third_party),
deleteNullValue(CDN.option)
)
})
+19
View File
@@ -0,0 +1,19 @@
hexo.extend.filter.register('before_generate', () => {
const hexoVer = hexo.version.replace(/(^.*\..*)\..*/, '$1');
const nodeVer = process.version.replace(/^v/, '');
const [majorVer] = nodeVer.split('.');
const logger = hexo.log;
const config = hexo.config;
if (hexoVer < 7.0) {
logger.error('请把 Hexo 升级到 V7.0.0 或更高的版本!');
logger.error('Please upgrade your Hexo to V7.0.0 or higher!');
process.exit(-1);
}
if (Number(majorVer) < 14) {
logger.error('请将 Node.js 升级到 v14.0.0 或更高的版本!');
logger.error('Please upgrade Node.js to v14.0.0 or later!');
process.exit(-1);
}
});
@@ -0,0 +1,390 @@
hexo.extend.filter.register('before_generate', () => {
const defaultConfig = {
site: {
name: {
class: 'text',
custom: 'Solitude'
},
siteIcon: '/img/pwa/favicon.ico',
icon: 'icon'
},
nav: {
group: null,
menu: null,
right: {
random: false,
console: false,
custom: [],
}
},
hometop: {
enable: false,
banner: {
title: 'Solitude',
url: 'A simple theme for Hexo',
icon: null,
},
group: null,
recommendList: {
sup: 'Recommend',
title: 'Solitude Docs',
url: 'https://solitude.js.org/',
img: '/img/default.avif',
color: 'none',
}
},
aside: {
home: {
noSticky: 'about',
Sticky: 'allInfo'
},
post: {
noSticky: 'about',
Sticky: 'allInfo'
},
page: {
noSticky: 'about',
Sticky: 'allInfo'
},
card: {
style: 0,
author: {
img: '/img/logo.png',
sticker: '/img/happy-sticker.avif',
},
url: '/about/',
background: null,
content1: 'Solitude',
content2: 'A simple theme for Hexo',
sayhello: {
morning: 'Good Morning',
noon: 'Good Noon',
afternoon: 'Good Afternoon',
night: 'Good Night',
goodnight: 'Good Night',
},
sayhello2: ['Welcome to Solitude', 'A simple theme for Hexo', 'Enjoy your time', 'Have a nice day', 'Good luck'],
information: null,
},
flip: {
favicon: '',
face: '',
backface: '',
backcolor: 'var(--efu-blue)'
},
newest_comment: {
enable: false,
storage: .5,
limit: 5
},
toc: {
post: true,
page: false,
vague: true,
},
tags: {
enable: true,
limit: 20,
highlight: false,
list: [],
},
archive: {
enable: true,
type: 'month'
},
siteinfo: {
postcount: true,
wordcount: false,
pv: true,
uv: true,
updatetime: true,
runtimeenable: true,
runtime: "2023-04-20 00:00:00",
},
},
index_post_list: {
direction: 'column',
column: 2,
content: false,
length: 500,
cover: 'both'
},
page: {
error: true,
tags: true,
categories: true,
default: {
cover: ['/img/default.avif'],
}
},
post: {
default: {
cover: ['/img/default.avif'],
locate: 'China, Changsha',
copyright: {
enable: true,
license: 'CC BY-NC-SA 4.0',
licenurl: 'https://creativecommons.org/licenses/by-nc-sa/4.0/',
}
},
meta: {
date: false,
updated: false,
locate: false,
wordcount: false,
readtime: false,
pv: false,
uv: false,
comment: false,
},
award: {
enable: false,
appreciators: '/',
title: '感谢您的赞赏。',
desc: '因为有你们的支持,我才体会到写文章的价值。',
list: [],
},
rss: null,
covercolor: {
enable: false,
mode: 'local',
api: 'https://api.qjqq.cn/api/Imgcolor?img=',
time: 43200000,
},
footer: {
enable: true,
desc: "来自 Efu 的文章",
button: {
enable: true,
name: '返回首页',
url: '/'
}
}
},
theme_color: {
dark: "#ffc848",
dark_op: "#f2b94b23",
dark_op_deep: "#f2b94bdd",
dark_none: "#f2b94b00",
light: "#425AEF",
light_op: "#4259ef23",
light_op_deep: "#4259efdd",
light_none: "#4259ef01"
},
display_mode: {
type: 'auto',
universe: false
},
related_post: {
enable: false,
limit: 2,
date_type: 'created'
},
footer: {
information: {
author: false,
left: null,
right: null,
},
group: null,
randomlink: false,
privacy: null,
license: null,
links: [{
name: 'Solitude',
url: 'https://github.com/everfu/hexo-theme-solitude',
}]
},
errorpage: {
img: 'https://7.isyangs.cn/34/65f2e65eae32a-34.png',
text: '404 Not Found',
recommendList: true
},
says: {
enable: false,
home_mini: false,
style: 1,
strip: 30
},
recent_comments: {
enable: false,
limit: 50,
console: false,
page: '/recentcomments/'
},
envelope: {
enable: false,
line: 10,
speed: 20,
hover: true,
loop: true,
page: '/message/'
},
meting_api: "https://meting.qjqq.cn/?server=:server&type=:type&id=:id&auth=:auth&r=:r",
music: {
enable: false,
id: '8407304077',
server: 'netease',
type: 'playlist',
volume: 0.8,
mutex: true,
},
capsule: {
enable: false,
id: '8407304077',
server: 'netease',
type: 'playlist',
},
keyboard: {
enable: false,
list: []
},
lazyload: {
enable: false,
field: 'site',
placeholder: '/img/loading.avif',
errorimg: '/img/error_load.avif'
},
loading: {
fullpage: false,
pace: true,
},
highlight: {
enable: true,
limit: 200,
copy: true,
expand: true,
theme: 'default',
color: 'default',
},
lightbox: false,
fancybox: false,
mediumZoom: false,
mermaid: false,
OpenGraph: {
enable: false,
options: null
},
wordcount: false,
busuanzi: false,
search: {
enable: false,
type: 'local',
tags: [],
algolia: null,
local: {
preload: false,
CDN: null,
}
},
rightside: {
enable: false
},
copy: {
enable: true,
copyright: {
enable: false,
limit: 50
}
},
post_ai: {
enable: false,
modelName: 'GPT 3',
key: 'your key',
talk: 'I am a AI.',
randomPost: false,
tips: 'AI is not perfect, please use it with caution.'
},
katex: {
enable: false,
per_page: false,
copytex: false,
},
comment: {
use: null,
commentBarrage: false,
lazyload: false,
count: false,
avatar: 'https://cravatar.cn',
},
twikoo: {
envId: 'your envId',
region: null,
style: true,
accessToken: null,
option: null,
},
waline: {
envId: 'your envId',
pageview: true,
option: null,
},
valine: {
appId: 'your appId',
appKey: 'your appKey',
serverURLs: 'your serverURLs',
avatar: 'monsterid',
visitor: false,
style: true,
option: null,
},
artalk: {
server: 'your server',
site: 'your site-name',
option: null,
},
verify_site: [],
css_prefix: false,
font: {
'font-size': '16px',
'code-font-size': '16px',
'font-family': 'PingFang SC, Hiragino Sans GB,Microsoft YaHei',
'code-font-family': 'monospace, monospace',
},
extends: {
head: [],
body: [],
},
pwa: {
enable: false,
manifest: '/manifest.json',
theme_color: "#006a73",
mask_icon: '/img/pwa/favicon.ico',
apple_touch_icon: '/img/pwa/favicon.ico',
bookmark_icon: '/img/pwa/favicon.ico',
favicon_32_32: '/img/pwa/favicon_32.ico',
favicon_16_16: '/img/pwa/favicon_16.ico'
},
google_adsense: {
enable: false,
auto_ads: false,
aside_card: false,
post_card: false,
post_content: false,
enable_page_level_ads: false,
js: 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js',
client: '',
slot: '',
},
right_menu: {
enable: false,
commentBarrage: false,
translate: {
enable: false,
defaultEncoding: 2,
translateDelay: 0,
},
custom_list: []
},
CDN: {
internal: 'local',
third_party: 'cdnjs',
version: true,
custom_format: 'https://cdn.staticfile.net/${cdnjs_name}/${version}/${min_cdnjs_file}',
option: {
solitude_css: 'https://cdn2.codesign.qq.com/icons/7pOrz0WXB5ZWJPX/latest/iconfont.css',
}
}
}
hexo.theme.config = Object.assign(defaultConfig, hexo.theme.config)
}, 1)
+33
View File
@@ -0,0 +1,33 @@
hexo.extend.generator.register('404', function (locals) {
if(!this.theme.config.page.error)return
return {
path: '404.html',
layout: ['404'],
data: {
type: '404',
comment: false
}
}
})
hexo.extend.generator.register('tags', function(locals) {
if(!this.theme.config.page.tags)return
return {
path: 'tags/index.html',
layout: ['page'],
data: {
type: 'tags',
comment: false
}
};
});
hexo.extend.generator.register('categories', function(locals) {
if(!this.theme.config.page.categories)return
return {
path: 'categories/index.html',
layout: ['page'],
data: {
type: 'categories',
comment: false
}
};
});
+14
View File
@@ -0,0 +1,14 @@
hexo.on('ready', () => {
const {version} = require('../../package.json')
hexo.log.info(`
===================================================================
##### #### # ##### ###### # # ###### ######
# # # # # # # # # # #
##### # # # # # # # # # ######
# # # # # # # # # # #
###### #### ##### ##### # ### ###### ######
${version}
===================================================================
GitHub: https://github.com/everfu/hexo-theme-solitude
`)
})