From f6f6e028ea9de8d05636e78f290d63be62b8d29b Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Sat, 24 Dec 2016 12:24:04 +0100 Subject: [PATCH] Make links detect target automatically and replace false with null for no attribute New version of Harp would render attribute=false as attribute="false", while attribute=null renders element without attribute. --- website/_includes/_footer.jade | 2 +- website/_includes/_mixins.jade | 8 +++++--- website/_includes/_navigation.jade | 4 ++-- website/_includes/_sidebar.jade | 4 ++-- website/index.jade | 8 ++++---- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/website/_includes/_footer.jade b/website/_includes/_footer.jade index e49ba309f..c83fd2988 100644 --- a/website/_includes/_footer.jade +++ b/website/_includes/_footer.jade @@ -11,7 +11,7 @@ footer.o-footer.u-text.u-border-dotted each url, item in group li - +a(url)(target=url.includes("http") ? "_blank" : false)=item + +a(url)=item if SECTION != "docs" +grid-col("quarter") diff --git a/website/_includes/_mixins.jade b/website/_includes/_mixins.jade index c4fbf8367..8fe24b11b 100644 --- a/website/_includes/_mixins.jade +++ b/website/_includes/_mixins.jade @@ -20,7 +20,8 @@ mixin h(level, id) info: https://mathiasbynens.github.io/rel-noopener/ mixin a(url, trusted) - a(href=url target="_blank" rel=!trusted ? "noopener nofollow" : false)&attributes(attributes) + - external = url.includes("http") + a(href=url target=external ? "_blank" : null rel=external && !trusted ? "noopener nofollow" : null)&attributes(attributes) block @@ -74,7 +75,8 @@ mixin aside-code(label, language) see assets/css/_components/_buttons.sass mixin button(url, trusted, ...style) - a.c-button.u-text-label(href=url class=prefixArgs(style, "c-button") role="button" target="_blank" rel=!trusted ? "noopener nofollow" : false)&attributes(attributes) + - external = url.includes("http") + a.c-button.u-text-label(href=url class=prefixArgs(style, "c-button") role="button" target=external ? "_blank" : null rel=external && !trusted ? "noopener nofollow" : null)&attributes(attributes) block @@ -148,7 +150,7 @@ mixin tag() mixin list(type, start) if type - ol.c-list.o-block.u-text(class="c-list--#{type}" style=(start === 0 || start) ? "counter-reset: li #{(start - 1)}" : false)&attributes(attributes) + ol.c-list.o-block.u-text(class="c-list--#{type}" style=(start === 0 || start) ? "counter-reset: li #{(start - 1)}" : null)&attributes(attributes) block else diff --git a/website/_includes/_navigation.jade b/website/_includes/_navigation.jade index 881a5db56..beb33be4b 100644 --- a/website/_includes/_navigation.jade +++ b/website/_includes/_navigation.jade @@ -2,7 +2,7 @@ include _mixins -nav.c-nav.u-text.js-nav(class=landing ? "c-nav--theme" : false) +nav.c-nav.u-text.js-nav(class=landing ? "c-nav--theme" : null) a(href='/') #[+logo] if SUBSECTION != "index" @@ -11,7 +11,7 @@ nav.c-nav.u-text.js-nav(class=landing ? "c-nav--theme" : false) ul.c-nav__menu each url, item in NAVIGATION li.c-nav__menu__item - a(href=url target=url.includes("http") ? "_blank" : false)=item + +a(url)=item li.c-nav__menu__item +a(gh("spaCy"))(aria-label="GitHub").u-hidden-xs #[+icon("github", 20)] diff --git a/website/_includes/_sidebar.jade b/website/_includes/_sidebar.jade index a0d4d4cd3..241a77132 100644 --- a/website/_includes/_sidebar.jade +++ b/website/_includes/_sidebar.jade @@ -9,5 +9,5 @@ menu.c-sidebar.js-sidebar.u-text li.u-text-label.u-color-subtle=menu each url, item in items - li(class=(CURRENT == url || (CURRENT == "index" && url == "./")) ? "is-active" : false) - +a(url)(target=url.includes("http") ? "_blank" : false)=item + li(class=(CURRENT == url || (CURRENT == "index" && url == "./")) ? "is-active" : null) + +a(url)=item diff --git a/website/index.jade b/website/index.jade index 56add5710..9d53432fc 100644 --- a/website/index.jade +++ b/website/index.jade @@ -22,7 +22,7 @@ include _includes/_mixins | process entire web dumps, spaCy is the library you want to | be using. - +button("/docs/api", true, "primary")(target="_self") + +button("/docs/api", true, "primary") | Facts & figures +grid-col("third").o-card @@ -35,7 +35,7 @@ include _includes/_mixins | think of spaCy as the Ruby on Rails of Natural Language | Processing. - +button("/docs/usage", true, "primary")(target="_self") + +button("/docs/usage", true, "primary") | Get started +grid-col("third").o-card @@ -51,7 +51,7 @@ include _includes/_mixins | connect the statistical models trained by these libraries | to the rest of your application. - +button("/docs/usage/deep-learning", true, "primary")(target="_self") + +button("/docs/usage/deep-learning", true, "primary") | Read more .o-inline-list.o-block.u-border-bottom.u-text-small.u-text-center.u-padding-small @@ -105,7 +105,7 @@ include _includes/_mixins +item Robust, rigorously evaluated accuracy .o-inline-list - +button("/docs/usage/lightning-tour", true, "secondary")(target="_self") + +button("/docs/usage/lightning-tour", true, "secondary") | See examples .o-block.u-text-center.u-padding