van-mdx 0.0.1 → 0.0.2
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.
package/package.json
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "van-mdx",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Markdown for Vanjs",
|
|
3
|
+
"version": "0.0.2",
|
|
4
|
+
"description": "Markdown preprocessor for Vanjs",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"vanjs",
|
|
9
|
+
"astro-integration",
|
|
10
|
+
"mdx",
|
|
11
|
+
"markdown",
|
|
12
|
+
"preprocessor"
|
|
13
|
+
],
|
|
7
14
|
"scripts": {
|
|
8
15
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
9
16
|
},
|
|
10
17
|
"exports": {
|
|
11
18
|
".": "./src/index.js",
|
|
12
|
-
"./vite": "./src/bundlers/vite.js"
|
|
19
|
+
"./vite": "./src/bundlers/vite/index.js",
|
|
20
|
+
"./astro": "./src/bundlers/astro/index.js",
|
|
21
|
+
"./astro/entry-client": "./src/bundlers/astro/entry-client.js",
|
|
22
|
+
"./astro/entry-server": "./src/bundlers/astro/entry-server.js"
|
|
13
23
|
},
|
|
14
24
|
"author": "zakaria elalaoui",
|
|
15
25
|
"license": "MIT",
|
|
16
26
|
"dependencies": {
|
|
17
27
|
"highlight.js": "^11.11.1",
|
|
18
|
-
"mdzjs": "^0.0.
|
|
28
|
+
"mdzjs": "^0.0.10",
|
|
19
29
|
"remark-frontmatter": "^5.0.0",
|
|
20
30
|
"remark-gfm": "^4.0.1",
|
|
21
31
|
"remark-mdx": "^3.1.0",
|
|
22
32
|
"remark-parse": "^11.0.0",
|
|
23
33
|
"unified": "^11.0.5",
|
|
24
34
|
"vanjs-core": "^1.5.5",
|
|
25
|
-
"ziko": "^0.0.
|
|
35
|
+
"ziko": "^0.0.29",
|
|
36
|
+
"ziko-server": "^0.0.7"
|
|
26
37
|
}
|
|
27
38
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default function (wrapper) {
|
|
2
|
+
return (Component, props, { default: children, ...slotted }, {client}) => {
|
|
3
|
+
// if (!wrapper.hasAttribute("ssr")){
|
|
4
|
+
// console.log("ssr")
|
|
5
|
+
// return
|
|
6
|
+
// }
|
|
7
|
+
console.log({wrapper})
|
|
8
|
+
console.log(`Client ...`)
|
|
9
|
+
wrapper.setAttribute("data-engine","van-mdx")
|
|
10
|
+
const properties = props ?? {};
|
|
11
|
+
switch(client){
|
|
12
|
+
case "only" : wrapper.append(Component(properties)); break;
|
|
13
|
+
default : {
|
|
14
|
+
wrapper.innerHTML = ""
|
|
15
|
+
console.log(`Client Hydration : ${Component}`)
|
|
16
|
+
wrapper.append(Component(properties)); break;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {renderDomToString } from "ziko-server/server-only-utils"
|
|
2
|
+
function check(Component, attributes) {
|
|
3
|
+
if (typeof Component !== "function") return false;
|
|
4
|
+
return true
|
|
5
|
+
}
|
|
6
|
+
async function renderToStaticMarkup(Component, props, { default: children, ...slotted }, metadata) {
|
|
7
|
+
console.log(`renderToStaticMarkup : ${Component}`)
|
|
8
|
+
const UI = Component(props)
|
|
9
|
+
const html = renderDomToString(UI)
|
|
10
|
+
return {
|
|
11
|
+
html,
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
name : "astro-van-mdx",
|
|
17
|
+
check,
|
|
18
|
+
renderToStaticMarkup
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ViteVanMdx from "../vite/index.js"
|
|
2
|
+
const AstroVanMdx = () => ({
|
|
3
|
+
name: "astro-van-mdx",
|
|
4
|
+
hooks: {
|
|
5
|
+
"astro:config:setup": async ({ updateConfig, addRenderer }) => {
|
|
6
|
+
updateConfig({
|
|
7
|
+
vite : {
|
|
8
|
+
plugins : [
|
|
9
|
+
ViteVanMdx()
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
})
|
|
13
|
+
addRenderer({
|
|
14
|
+
name: "astro-van-mdx",
|
|
15
|
+
serverEntrypoint: "van-mdx/astro/entry-server",
|
|
16
|
+
clientEntrypoint: "van-mdx/astro/entry-client",
|
|
17
|
+
});
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
export default AstroVanMdx;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
// import ViteVanMdx from "../vite/index.js";
|
|
25
|
+
// const AstroVanMdx = () => ({
|
|
26
|
+
// name: "astro-mdzjs",
|
|
27
|
+
// hooks: {
|
|
28
|
+
// "astro:config:setup": async ({ updateConfig }) => {
|
|
29
|
+
// updateConfig({
|
|
30
|
+
// vite : {
|
|
31
|
+
// plugins : [
|
|
32
|
+
// ViteVanMdx()
|
|
33
|
+
// ]
|
|
34
|
+
// }
|
|
35
|
+
// })
|
|
36
|
+
// },
|
|
37
|
+
// },
|
|
38
|
+
// });
|
|
39
|
+
// export default AstroVanMdx;
|
|
@@ -111,6 +111,12 @@ const processMDAST = (markdownAST) => {
|
|
|
111
111
|
const hasChildren = childNodes.length > 0;
|
|
112
112
|
switch(componentType(name)){
|
|
113
113
|
case "jsx" : {
|
|
114
|
+
console.log({
|
|
115
|
+
Component : name,
|
|
116
|
+
children,
|
|
117
|
+
})
|
|
118
|
+
const f = `${name}(${processAttribute(attributes)}${hasChildren ?`, ${childNodes}`:""})`
|
|
119
|
+
console.log({f})
|
|
114
120
|
return `${name}(${processAttribute(attributes)}${hasChildren ?`, ${childNodes}`:""})`;
|
|
115
121
|
}
|
|
116
122
|
case "html" : {
|