0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-05-07 14:28:40 +00:00

Experimental fix for broken internal document links

This commit is contained in:
G.Ambatte
2026-04-05 21:16:23 +12:00
parent a4e3f2006d
commit af98694e48
4 changed files with 16 additions and 8 deletions
@@ -33,7 +33,7 @@ const INITIAL_CONTENT = dedent`
<link href='/homebrew/bundle.css' type="text/css" rel='stylesheet' />
<link href="${brewRendererStylesUrl}" rel="stylesheet" />
<link href="${headerNavStylesUrl}" rel="stylesheet" />
<base target=_blank>
<base target="_top">
</head><body style='overflow: hidden'><div></div></body></html>`;
@@ -272,6 +272,14 @@ const BrewRenderer = (props)=>{
const frameDidMount = ()=>{ //This triggers when iFrame finishes internal "componentDidMount"
scrollToHash(window.location.hash);
navigation.addEventListener('navigate', (e)=>{
console.log(e);
if(e.hashChange && e.destination.sameDocument){
const dest = e.destination.url.slice(e.destination.url.indexOf('#'));
scrollToHash(dest);
}
});
setTimeout(()=>{ //We still see a flicker where the style isn't applied yet, so wait 100ms before showing iFrame
renderPages(); //Make sure page is renderable before showing
setState((prevState)=>({
@@ -104,7 +104,7 @@ const HeaderNavItem = ({ link, text, depth, className })=>{
if(!link || !text) return;
return <li>
<a href={`#${link}`} target='_self' className={`depth-${depth} ${className ?? ''}`}>
<a href={`#${link}`} className={`depth-${depth} ${className ?? ''}`}>
{trimString(text, depth)}
</a>
</li>;
+3 -3
View File
@@ -70,9 +70,9 @@ renderer.link = function (token) {
if(title) {
out += ` title="${escape(title)}"`;
}
if(self) {
out += ' target="_self"';
}
// if(self) {
// out += ' target="_self"';
// }
out += `>${text}</a>`;
return out;
};
+3 -3
View File
@@ -34,9 +34,9 @@ renderer.link = function (href, title, text) {
if(title) {
out += ` title="${title}"`;
}
if(self) {
out += ' target="_self"';
}
// if(self) {
// out += ' target="_self"';
// }
out += `>${text}</a>`;
return out;
};