feat: use hexo
This commit is contained in:
34
themes/vanilla/scripts/math-api.js
Normal file
34
themes/vanilla/scripts/math-api.js
Normal file
@@ -0,0 +1,34 @@
|
||||
// function filter(config) {
|
||||
// return function (content) {
|
||||
// return content
|
||||
// .replace(
|
||||
// /\$\$\n([\w\W]+?)\n\$\$/gm,
|
||||
// (_, eq) => `})`
|
||||
// )
|
||||
// .replace(
|
||||
// /([\s^])\$(.+?)\$([\s$])/g,
|
||||
// (_, s, eq, e) =>
|
||||
// `${s}})${e}`
|
||||
// );
|
||||
// };
|
||||
// }
|
||||
|
||||
// const config = (hexo.config.mathapi = Object.assign(
|
||||
// {
|
||||
// color: undefined,
|
||||
// alternateColor: undefined,
|
||||
// },
|
||||
// hexo.config.mathapi
|
||||
// ));
|
||||
|
||||
// const mathapi = filter(config);
|
||||
|
||||
// hexo.extend.filter.register(
|
||||
// "before_post_render",
|
||||
// (data) => {
|
||||
// // if (!data.mathapi && !config.every_page) return;
|
||||
// data.content = mathapi(data.content);
|
||||
// return data;
|
||||
// },
|
||||
// 5
|
||||
// );
|
40
themes/vanilla/scripts/redirect.js
Executable file
40
themes/vanilla/scripts/redirect.js
Executable file
@@ -0,0 +1,40 @@
|
||||
const generator = (hexo) => ({ posts, pages }) =>
|
||||
[
|
||||
...posts
|
||||
.filter(({ redirect_from }) => redirect_from)
|
||||
.map((page) =>
|
||||
(typeof page.redirect_from === "string"
|
||||
? [page.redirect_from]
|
||||
: page.redirect_from
|
||||
).map((redirect) => ({ redirect, page }))
|
||||
)
|
||||
.reduce((result, current) => [...result, ...current], []),
|
||||
...pages
|
||||
.filter(({ redirect_from }) => redirect_from)
|
||||
.map((page) =>
|
||||
(typeof page.redirect_from === "string"
|
||||
? [page.redirect_from]
|
||||
: page.redirect_from
|
||||
).map((redirect) => ({ redirect, page }))
|
||||
)
|
||||
.reduce((result, current) => [...result, ...current], []),
|
||||
].map(({ redirect, page }) => ({
|
||||
path: `${redirect}/index.html`,
|
||||
data: {
|
||||
target: page,
|
||||
redirect_from: redirect,
|
||||
layout: hexo.config.redirect.layout,
|
||||
},
|
||||
layout: hexo.config.redirect.layout,
|
||||
}));
|
||||
|
||||
hexo.config.redirect = Object.assign(
|
||||
{
|
||||
enable: true,
|
||||
layout: "redirect",
|
||||
},
|
||||
hexo.config.redirect
|
||||
);
|
||||
|
||||
hexo.extend.generator.register("redirect", generator(hexo));
|
||||
// module.exports = generator;
|
Reference in New Issue
Block a user