Skip to content

Commit

Permalink
Make cdn links local and change icon
Browse files Browse the repository at this point in the history
  • Loading branch information
haxiomic committed Dec 1, 2023
1 parent 673f68d commit ed671c2
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function DemoScene(props: {

let expandButton = document.createElement('div');
expandButton.style.visibility = showUI ? 'visible' : 'hidden';
expandButton.className = 'expand-button ' + (props.expanded ? 'icon-navicon' : 'icon-expand');
expandButton.className = 'expand-button ' + (props.expanded ? 'icon-compress' : 'icon-expand');
expandButton.onclick = () => {
props.onExpandToggle(!props.expanded);
}
Expand Down Expand Up @@ -234,6 +234,17 @@ function App() {
{children}
</code>
)
},
a(props) {
// replace absolute links with local ones
let { href, ...rest } = props;
let pattern = /^https:\/\/cdn-luma.com\/[^#]+#(.*)/;
if (href && pattern.test(href)) {
let before = href;
let match = href.match(pattern);
href = '#' + match![1];
}
return <a {...rest} href={href} />
}
}}
>{readme}</Markdown>
Expand Down

0 comments on commit ed671c2

Please sign in to comment.