notro-loader 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Module-level configuration store for notro's MDX plugin pipeline.
3
+ *
4
+ * The notro() Astro integration stores the user-provided remark/rehype plugins
5
+ * here during astro:config:setup. buildMdxPlugins() reads them at render time
6
+ * so that both the runtime Notion path (compileMdxCached) and the static .mdx
7
+ * path (@astrojs/mdx) use the same plugin configuration.
8
+ *
9
+ * NOTE: We use globalThis instead of module-level variables so the state
10
+ * persists across Vite module instances. Astro's integration hooks run in a
11
+ * plain Node.js module context; at build/prerender time, Vite creates new
12
+ * module instances for the same files. globalThis is the same object in both
13
+ * contexts within the same Node.js process, so storing plugins there bridges
14
+ * the two contexts without requiring a virtual module or serialisation.
15
+ */
16
+ import type { PluggableList } from 'unified';
17
+
18
+ declare global {
19
+ // eslint-disable-next-line no-var
20
+ var __notro_remarkPlugins: PluggableList | undefined;
21
+ // eslint-disable-next-line no-var
22
+ var __notro_rehypePlugins: PluggableList | undefined;
23
+ }
24
+
25
+ export function setNotroPlugins(remarkPlugins: PluggableList, rehypePlugins: PluggableList): void {
26
+ globalThis.__notro_remarkPlugins = remarkPlugins;
27
+ globalThis.__notro_rehypePlugins = rehypePlugins;
28
+ }
29
+
30
+ export function getNotroPlugins(): { remarkPlugins: PluggableList; rehypePlugins: PluggableList } {
31
+ return {
32
+ remarkPlugins: globalThis.__notro_remarkPlugins ?? [],
33
+ rehypePlugins: globalThis.__notro_rehypePlugins ?? [],
34
+ };
35
+ }
package/utils.ts ADDED
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Pure TypeScript utilities — safe to import anywhere, including astro.config.mjs.
3
+ *
4
+ * Use this entry point (`notro/utils`) when you need notro helpers in contexts
5
+ * where Astro components cannot be loaded (config files, Node scripts, etc.).
6
+ *
7
+ * For Astro components and the Content Loader, use the main `notro` entry instead.
8
+ */
9
+ export { normalizeNotionPresignedUrl, markdownHasPresignedUrls } from './src/utils/notion-url.ts';
10
+ export { getPlainText, getMultiSelect, hasTag, buildLinkToPages } from './src/utils/notion.ts';
11
+ export type { LinkToPages } from './src/types.ts';