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

feat(tag/include_code): robust for url compuation of view raw #4996

Merged
merged 1 commit into from
Jun 15, 2022
Merged
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions lib/plugins/tag/include_code.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

const { exists, readFile } = require('hexo-fs');
const { basename, extname, join } = require('path');
const { basename, extname, join, posix } = require('path');

// Lazy require highlight.js & prismjs
let highlight, prismHighlight;
Expand Down Expand Up @@ -55,7 +55,7 @@ module.exports = ctx => function includeCodeTag(args) {

// If the title is not defined, use file name instead
const title = match[1] || basename(path);
const caption = `<span>${title}</span><a href="${ctx.config.root}${codeDir}${path}">view raw</a>`;
const caption = `<span>${title}</span><a href="${posix.join(ctx.config.root, codeDir, path)}">view raw</a>`;

const hljsCfg = ctx.config.highlight || {};
const prismjsCfg = ctx.config.prismjs || {};
Expand Down