diff --git a/packages/integrations/mdx/src/utils.ts b/packages/integrations/mdx/src/utils.ts index c824c39c3..6eb7a3570 100644 --- a/packages/integrations/mdx/src/utils.ts +++ b/packages/integrations/mdx/src/utils.ts @@ -24,9 +24,9 @@ export function getFileInfo(id: string, config: AstroConfig): FileInfo { const fileId = id.split('?')[0]; let fileUrl: string; const isPage = fileId.includes('/pages/'); - if(isPage) { + if (isPage) { fileUrl = fileId.replace(/^.*?\/pages\//, sitePathname).replace(/(\/index)?\.mdx$/, ''); - } else if(url && url.pathname.startsWith(config.root.pathname)) { + } else if (url && url.pathname.startsWith(config.root.pathname)) { fileUrl = url.pathname.slice(config.root.pathname.length); } else { fileUrl = fileId; diff --git a/packages/integrations/mdx/test/mdx-get-static-paths.test.js b/packages/integrations/mdx/test/mdx-get-static-paths.test.js index f5d48922c..b4dc179d0 100644 --- a/packages/integrations/mdx/test/mdx-get-static-paths.test.js +++ b/packages/integrations/mdx/test/mdx-get-static-paths.test.js @@ -24,6 +24,9 @@ describe('getStaticPaths', () => { expect($('p').text()).to.equal('First mdx file'); expect($('#one').text()).to.equal('hello', 'Frontmatter included'); expect($('#url').text()).to.equal('/src/content/1.mdx', 'url is included'); - expect($('#file').text()).to.contain('fixtures/mdx-get-static-paths/src/content/1.mdx', 'file is included'); + expect($('#file').text()).to.contain( + 'fixtures/mdx-get-static-paths/src/content/1.mdx', + 'file is included' + ); }); });