pngwn / MDsveX

A markdown preprocessor for Svelte.
https://mdsvex.pngwn.io
MIT License
2.47k stars 103 forks source link

Cannot load layout path in versions >v0.12.0 #635

Closed jaaneh closed 3 months ago

jaaneh commented 3 months ago

Trying to up from v0.10.6 to latest (0.12.2) and it results in

error during build:
Error: The layout path you provided couldn't be found at either /home/jan/dev/content/packages/lms/src/lib/components/ui/Layout.svelte or /home/jan/dev/content/packages/lms/home/jan/dev/content/packages/lms/src/lib/components/ui/Layout.svelte. Please double-check it and try again.

This works fine on any version below 0.12.0, including 0.11.1.

// svelte.config.js
import preprocess from 'svelte-preprocess';
import node from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { mdsvex } from 'mdsvex';
import callouts from 'remark-emoji-callout';
import gfm from 'remark-gfm';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
import codeBlockPlugin from './src/lib/utils/remarkPlugins/codeBlockPlugin.js';

/** @type {import('@sveltejs/kit').Config} */
const config = {
  // Consult https://kit.svelte.dev/docs/integrations#preprocessors
  // for more information about preprocessors
  preprocess: [
    vitePreprocess(),
    mdsvex({
      layout: path.join(__dirname, './src/lib/components/ui/Layout.svelte'),
      extensions: ['.md', '.svx'],
      remarkPlugins: [
        gfm,
        callouts,
        {
          dataAttribute: 'custom-callout',
          titleTextTagName: 'span',
          iconTagName: 'span'
          // ...
        },
        codeBlockPlugin
      ]
    }),
    preprocess({
      postcss: true
    })
  ],
  extensions: ['.svelte', '.md'],

  kit: {
    adapter: node()
  }
};

export default config;

We're still on Svelte 3 and Vite 4

// package.json
"svelte": "^3.54.0",
"mdsvex": "^0.12.2",
"vite": "^4.5.3",
pngwn commented 3 months ago

Ah, must have screwed up the path resolution when we made some internal changes. I'll check this ASAP.

pngwn commented 3 months ago

Can you try version 0.12.3 please: https://github.com/pngwn/MDsveX/releases/tag/mdsvex%400.12.3

jaaneh commented 3 months ago

@pngwn seems to work from what I can see. Appreciate it a bunch!

pngwn commented 3 months ago

Awesome, ty!