Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

fix: convert the example name to kebab-case in the iframe/anchor url … #95

Closed
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
51 changes: 26 additions & 25 deletions src/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,31 +170,32 @@ class Generator {
if (doc.description) {
// Replaces <example> tags with <iframe> tags
doc.description = doc.description.replace(
/<example name="([^"]+)"( height="\d+")?><\/example>/g,
`<div class="i-example">
<h5 class="i-example__heading">
<a
href="${doc.slug}-$1.html"
target="_blank"
class="plain-link"
data-toggle="tooltip"
data-placement="top"
title="Open in a new window"
>
<i class="fa fa-external-link-square fa-fw"></i>
Example
</a>
</h5>
<div class="i-example__body">
<div
class="i-example__iframe"
lazyframe
data-src="${doc.slug}-$1.html"
data-initinview="true"
data-title="Loading..." $2
></div>
</div>
</div>\n`
/<example name="([^"]+)"( height="\d+")?><\/example>/g,
(_match, name, optionalHeight) =>
`<div class="i-example">
<h5 class="i-example__heading">
<a
href="${doc.slug}-${_.kebabCase(name)}.html"
target="_blank"
class="plain-link"
data-toggle="tooltip"
data-placement="top"
title="Open in a new window"
>
<i class="fa fa-external-link-square fa-fw"></i>
Example
</a>
</h5>
<div class="i-example__body">
<div
class="i-example__iframe"
lazyframe
data-src="${doc.slug}-${_.kebabCase(name)}.html"
data-initinview="true"
data-title="Loading..." ${optionalHeight}
></div>
</div>
</div>\n`
);

// Replaces <info|success|warning|danger> tags with alert divs
Expand Down