docs: rename article slug

This commit is contained in:
2021-02-13 22:17:45 +09:00
parent ac0d966308
commit 2afd947660
68 changed files with 18 additions and 32 deletions

View File

@@ -0,0 +1,34 @@
// function filter(config) {
// return function (content) {
// return content
// .replace(
// /\$\$\n([\w\W]+?)\n\$\$/gm,
// (_, eq) => `![](https://math.now.sh?from=${encodeURIComponent(eq)})`
// )
// .replace(
// /([\s^])\$(.+?)\$([\s$])/g,
// (_, s, eq, e) =>
// `${s}![](https://math.now.sh?inline=${encodeURIComponent(eq)})${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/uio/scripts/redirect.js Executable file
View 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;