Skip to content

Commit a8b8621

Browse files
committed
Fix issue with _blank urls
1 parent d9af377 commit a8b8621

File tree

5 files changed

+32
-6
lines changed

5 files changed

+32
-6
lines changed

_posts/2015-08-09-highlighting-ruby-code-in-jekyll.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ post_description: A few days ago I was trying to write a tutorial about creating
66
categories: ["Jekyll"]
77
---
88

9-
A few days ago I was trying to write a [tutorial](https://codegaze.github.io/2015/08/08/how-to-create-a-dynamic-navigation-menu-in-jekyll/){:target="\_blank"} about creating a simple dynamic menu for Jekyll and I came across a strange problem while I was trying to show and highlight some ruby code.
9+
A few days ago I was trying to write a [tutorial](/2015/08/08/how-to-create-a-dynamic-navigation-menu-in-jekyll/) about creating a simple dynamic menu for Jekyll and I came across a strange problem while I was trying to show and highlight some ruby code.
1010

1111
Instead of ruby code and html I was getting whitespace and html only.
1212

13-
I reinstalled [pip](https://pip.pypa.io/){:target="\_blank"} and [pygments](https://pygments.org/){:target="\_blank"} to check if something was wrong with my installation but that wasn't the problem.
13+
I reinstalled [pip](https://pip.pypa.io/) and [pygments](https://pygments.org/) to check if something was wrong with my installation but that wasn't the problem.
1414

1515
After a little research I found out that the problem was that Liquid, the template language Jekyll uses, considered everything inside the curly braces as code to execute.
1616

17-
That thing we call the internet helped me to find out that the solution is another tag called [raw](https://docs.shopify.com/themes/liquid-documentation/tags/theme-tags#raw){:target="\_blank"}.
17+
That thing we call the internet helped me to find out that the solution is another tag called [raw](https://docs.shopify.com/themes/liquid-documentation/tags/theme-tags#raw).
1818

1919
> **raw**
2020
> Allows output of Liquid code on a page without being parsed.

eleventy.config.cjs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const fs = require("fs");
55
const postcss = require("postcss");
66
const postcssImport = require("postcss-import");
77
const postNested = require("postcss-nested");
8+
const markdownIt = require("markdown-it");
9+
const markdownItAttrs = require("markdown-it-link-attributes");
810

911
module.exports = (eleventyConfig) => {
1012
eleventyConfig.addPlugin(syntaxHighlight);
@@ -100,6 +102,19 @@ module.exports = (eleventyConfig) => {
100102
}
101103
);
102104

105+
let markdownLib = markdownIt({ html: true, linkify: true }).use(
106+
markdownItAttrs,
107+
{
108+
pattern: /^https?:\/\//, // only external links
109+
attrs: {
110+
target: "_blank",
111+
rel: "noopener noreferrer",
112+
},
113+
}
114+
);
115+
116+
eleventyConfig.setLibrary("md", markdownLib);
117+
103118
return {
104119
dir: {
105120
input: "./",

package-lock.json

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
"@11ty/eleventy-plugin-syntaxhighlight": "^5.0.0",
1919
"autoprefixer": "^10.4.20",
2020
"cssnano": "^7.0.6",
21+
"markdown-it": "^14.1.0",
22+
"markdown-it-link-attributes": "^4.0.1",
2123
"postcss": "^8.4.49",
2224
"postcss-import": "^16.1.0",
2325
"postcss-nested": "^7.0.2"

worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
var staticAssetsCacheName = "StaticAssetsList",
22
imageAssetsCacheName = "ImgStaticList",
3-
version = "v3:1:31";
3+
version = "v3:1:32";
44

55
var staticPrimaryAssets = ["/", "/index.css"];
66

0 commit comments

Comments
 (0)