Skip to content

Commit

Permalink
feat(tag/include_code): robust for url compuation of view raw (#4996)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored Jun 15, 2022
1 parent d449acc commit aa6c3c5
Showing 1 changed file with 2 additions and 2 deletions.
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

0 comments on commit aa6c3c5

Please sign in to comment.