diff --git a/website/astro.config.mjs b/website/astro.config.mjs index c91ee0bc..89bffbc9 100644 --- a/website/astro.config.mjs +++ b/website/astro.config.mjs @@ -17,7 +17,7 @@ const baseNoTrailing = base.endsWith('/') ? base.slice(0, -1) : base; // this rehype plugin fixes relative links // it works by prepending the base + page path to anchor links -// and by prepending the base path to all other relative links +// and by prepending the base path to other relative links starting with / // this is necessary when using a base href like // examples with base as "mybase": // #gain -> /mybase/learn/effects/#gain @@ -27,23 +27,20 @@ function relativeURLFix() { const chunks = file.history[0].split('/src/pages/'); // file.history[0] is the file path const path = chunks[chunks.length - 1].slice(0, -4); // only path inside src/pages, without .mdx return rehypeUrls((url) => { - // NOTE: the base argument to the URL constructor is ignored if the input is already - // absolute and used if not, which facilitates the comparison below - // true if origins are same, and relative urls are considered as origin equal to site var value - if (new URL(site).origin === new URL(url.href, site).origin) { - let newHref = baseNoTrailing; - if (url.href.startsWith('#')) { - // special case: a relative anchor link to the current page - newHref += `/${path}/${url.href}`; - } else { - // any other same origin link - // NOTE: this does strip off serialized queries and fragments - newHref += (url.pathname.endsWith('/') ? url.pathname : url.pathname + '/'); - } - // console.log(url.href + ' -> ', newHref); - return newHref; + let newHref = baseNoTrailing; + if (url.href.startsWith('#')) { + // special case: a relative anchor link to the current page + newHref += `/${path}/${url.href}`; + } else if (url.href.startsWith('/')) { + // any other relative url starting with / + // NOTE: this does strip off serialized queries and fragments + newHref += url.pathname.endsWith('/') ? url.pathname : url.pathname + '/'; + } else { + // leave this URL alone + return; } - return; + // console.log(url.href + ' -> ', newHref); + return newHref; })(tree); }; } diff --git a/website/src/pages/workshop/getting-started.mdx b/website/src/pages/workshop/getting-started.mdx index 4259623c..3d37a5cf 100644 --- a/website/src/pages/workshop/getting-started.mdx +++ b/website/src/pages/workshop/getting-started.mdx @@ -7,9 +7,7 @@ import { MiniRepl } from '../../docs/MiniRepl'; # Welcome -
-![Strudel Icon](/icons/strudel_icon.png) -
+
![Strudel Icon](/icons/strudel_icon.png)
Welcome to the Strudel documentation pages! You've come to the right place if you want to learn how to make music with code.