lion/patches
2025-10-03 09:37:32 +02:00
..
@mdjs+mdjs-preview+0.6.0.patch feat: improved Astro integration 2025-10-03 09:37:32 +02:00
lit+2.8.0.patch feat: initial Astro integration 2025-10-03 09:37:32 +02:00
README.md feat: improved Astro integration 2025-10-03 09:37:32 +02:00

@mdjs/core@0.20.0

mdjsStoryParse.js

The original file URL is here: URL

Why

Astro does not call mdjsStoryParse every time an md file is changed while watching. The function is called only once. However some shared variables are set on the level of the mdjsStoryParse. That leads to the situation that those variable are shared among all md files which is not according to the design. The orignal idea is to share those per an md file. As a result when generating __mdjs-stories.js files, they get polluted with the data from other files.

About the fix

This way the shared variables instantiated on every transformer function call.

mdjsParse.js

Why patching

Astro does not call mdjsParse every time an md file is changed while watching. The function is called only once. However some shared variables are set on the level of the mdjsParse. That leads to the situation that those variable are shared among all md files which is not according to the design. The orignal idea is to share those per an md file. As a result when generating __mdjs-stories.js files, they get polluted with the data from other files.

About the patch

This way the shared variables instantiated on every transformer function call.

mdjsSetupCode.js

Dynamic imports for @mdjs/mdjs-preview/define and @mdjs/mdjs-story/define were removed. These imports are inlined into __mdjs-story.js by remarkProcessDemos.mjs remark plugin. This is done to enable dist bundling.

@astrojs/markdown-remark

The patch is done to inhance the id naming of tag HTML elements.

Why updating naming

In the current implementation of the portal we need to concatenate md pages. Astro creates unique values for the id attributes for <H> tags (h1, h2, etc. ). The problem is that the id's are not longer unique after concatenation. There might be multiple overview id's which is not correct for navigation.

What the solution is about

The solution is to add the parent directory name to the each id as a prefix. That is if the md file being parsed is called docs/tools/my.md and let's say there is an h2 tag in with id called overview, then after applying patch, the new id value becomes tools-overview.

lit

The patch is required to make astro build work correctly. lit is added as an external library for the build option in astro.config.mjs. And without the patch the build throws errors.