Skip to content

Commit

Permalink
Fix links opening externally
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbassi committed Jul 18, 2019
1 parent 7c3195e commit 0f2d9df
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/utils/markdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import path from 'path';
import {
extract_frontmatter,
langs,
link_renderer
} from '@sveltejs/site-kit/utils/markdown';
import marked from 'marked';
import { makeSlugProcessor } from './slug';
Expand All @@ -13,6 +12,16 @@ import 'prismjs/components/prism-bash';

const makeSlug = makeSlugProcessor(SLUG_PRESERVE_UNICODE);

function linkRenderer(href, title, text) {
let title_attr = '';

if (title !== null) {
title_attr = ` title="${title}"`;
}

return `<a href="${href}"${title_attr}>${text}</a>`;
}

export function getPages(directory) {
return fs
.readdirSync(`content/${directory}`)
Expand Down Expand Up @@ -44,7 +53,7 @@ export function getPage(filepath) {

const renderer = new marked.Renderer();

renderer.link = link_renderer;
renderer.link = linkRenderer;

renderer.code = (source, lang) => {
const plang = langs[lang];
Expand Down

0 comments on commit 0f2d9df

Please sign in to comment.