mdzjs 0.0.0
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/LICENSE +21 -0
- package/README.md +84 -0
- package/package.json +37 -0
- package/preview/InteractiveBlock.js +21 -0
- package/preview/__main2.js +49 -0
- package/preview/index.html +27 -0
- package/preview/main.js +12 -0
- package/preview/package-lock.json +864 -0
- package/preview/package.json +17 -0
- package/preview/public/vite.svg +1 -0
- package/preview/src/pages/[blog]/[lang]/index.js +3 -0
- package/preview/src/pages/[blog]/index.js +3 -0
- package/preview/src/pages/about.js +6 -0
- package/preview/src/pages/articles/[data]/[color]/index.js +6 -0
- package/preview/src/pages/articles/a1.js +6 -0
- package/preview/src/pages/index.js +20 -0
- package/preview/src/pages/me.js +3 -0
- package/preview/test.mdz +21 -0
- package/preview/vite.config.js +5 -0
- package/rollup.config.js +67 -0
- package/src/converter/index.js +17 -0
- package/src/index.js +2 -0
- package/src/parser/get-component-type.js +17 -0
- package/src/parser/index.js +30 -0
- package/src/parser/jsx2js.js +23 -0
- package/src/parser/parser-markdown.js +18 -0
- package/src/parser/smart-join.js +18 -0
- package/src/test.js +21 -0
- package/src/vite/index.js +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ZAKARIA ELALAOUI
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Markdown for [Zikojs](https://github.com/zakarialaoui10/ziko.js)
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
```bash
|
|
5
|
+
npm i mdzjs
|
|
6
|
+
```
|
|
7
|
+
|
|
8
|
+
## Usage
|
|
9
|
+
|
|
10
|
+
### Config
|
|
11
|
+
```js
|
|
12
|
+
import {defineConfig} from "vite"
|
|
13
|
+
import {MDZ} from "mdzjs"
|
|
14
|
+
export default defineConfig({
|
|
15
|
+
plugins : [
|
|
16
|
+
MDZ()
|
|
17
|
+
]
|
|
18
|
+
})
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### Example
|
|
22
|
+
|
|
23
|
+
```md
|
|
24
|
+
---
|
|
25
|
+
modules :
|
|
26
|
+
- import InteractiveBlock from "./InteractiveBlock.js"
|
|
27
|
+
title : MDZ
|
|
28
|
+
background : tomato
|
|
29
|
+
---
|
|
30
|
+
**MDZ** (Markdown for ***zikojs***) is a format that allows you to append Zikojs Elements directly within Markdown.
|
|
31
|
+
|
|
32
|
+
It combines the simplicity of Markdown syntax with the power and flexibility of ***Javascript***
|
|
33
|
+
|
|
34
|
+
Here’s an example of an interactive block rendered within this MDZ file:
|
|
35
|
+
|
|
36
|
+
<InteractiveBlock data="Hello from MDZ" color="darkblue"/>
|
|
37
|
+
|
|
38
|
+
### Features of MDZ:
|
|
39
|
+
1- **Simple Integration :** Write Markdown as usual, and inject ZikoJS elements wherever needed.
|
|
40
|
+
2- **Frontmatter Support :** In this example, the title of the document is set dynamically through the frontmatter.
|
|
41
|
+
|
|
42
|
+
3- **Extensible :** Create custom components like InteractiveBlock and use them in any Markdown file.
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
// InteractiveBlock.js
|
|
47
|
+
import {Flex, input, text} from "ziko"
|
|
48
|
+
export default ({data, color})=>{
|
|
49
|
+
let txt = text(data).style({color})
|
|
50
|
+
let inp = input(data).style({
|
|
51
|
+
padding : "5px",
|
|
52
|
+
background : "transparent",
|
|
53
|
+
outline :"none",
|
|
54
|
+
boxShadow :"1px 1px 1px white",
|
|
55
|
+
fontSize : "inherit"
|
|
56
|
+
})
|
|
57
|
+
inp.onInput(e=>txt.setValue(e.value))
|
|
58
|
+
return Flex(
|
|
59
|
+
inp,
|
|
60
|
+
txt
|
|
61
|
+
).vertical(0, "space-around").size("60%").style({
|
|
62
|
+
border : "2px darkblue solid",
|
|
63
|
+
padding : "10px",
|
|
64
|
+
minHeight : "100px",
|
|
65
|
+
margin : "auto"
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
// main.js
|
|
72
|
+
import { useTitle } from "ziko"
|
|
73
|
+
import UI,{attributes} from "./test.mdz"
|
|
74
|
+
const {title, background} = attributes
|
|
75
|
+
title && useTitle(title)
|
|
76
|
+
UI().style({
|
|
77
|
+
border : "2px darkblue solid",
|
|
78
|
+
width : "70%",
|
|
79
|
+
margin : "auto",
|
|
80
|
+
padding : "10px",
|
|
81
|
+
fontFamily : "Cheeronsta",
|
|
82
|
+
background : background ?? "orange"
|
|
83
|
+
}).vertical(-1, "space-around")
|
|
84
|
+
```
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mdzjs",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"dev": "cross-env NODE_ENV=development rollup --config rollup.config.js",
|
|
10
|
+
"watch": "cross-env NODE_ENV=development rollup --config rollup.config.js -w",
|
|
11
|
+
"build": "cross-env NODE_ENV=production rollup --config rollup.config.js"
|
|
12
|
+
},
|
|
13
|
+
"./": {
|
|
14
|
+
"import": "./src/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./vite": {
|
|
17
|
+
"import": "./src/vite/index.js"
|
|
18
|
+
},
|
|
19
|
+
"author": "",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"zikojs",
|
|
22
|
+
"zikojs-addons"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"front-matter": "^4.0.2",
|
|
27
|
+
"marked": "^14.1.2",
|
|
28
|
+
"rollup": "^4.24.0",
|
|
29
|
+
"ziko": "^0.0.16"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@rollup/plugin-commonjs": "^28.0.0",
|
|
33
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
34
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
35
|
+
"cross-env": "^7.0.3"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import {Flex, input, text} from "ziko"
|
|
2
|
+
export default ({data, color})=>{
|
|
3
|
+
let txt = text(data).style({color})
|
|
4
|
+
let inp = input(data).style({
|
|
5
|
+
padding : "5px",
|
|
6
|
+
background : "transparent",
|
|
7
|
+
outline :"none",
|
|
8
|
+
boxShadow :"1px 1px 1px white",
|
|
9
|
+
fontSize : "inherit"
|
|
10
|
+
})
|
|
11
|
+
inp.onInput(e=>txt.setValue(e.value))
|
|
12
|
+
return Flex(
|
|
13
|
+
inp,
|
|
14
|
+
txt
|
|
15
|
+
).vertical(0, "space-around").size("60%").style({
|
|
16
|
+
border : "2px darkblue solid",
|
|
17
|
+
padding : "10px",
|
|
18
|
+
minHeight : "100px",
|
|
19
|
+
margin : "auto"
|
|
20
|
+
})
|
|
21
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// globalThis.S=SPA({
|
|
2
|
+
// target : document.querySelector("#app"),
|
|
3
|
+
// wrapper : Section().style({
|
|
4
|
+
// display : "flex",
|
|
5
|
+
// justifyContent: "center",
|
|
6
|
+
// alignItems : "center",
|
|
7
|
+
// height : "100vh"
|
|
8
|
+
// }),
|
|
9
|
+
// routes:{
|
|
10
|
+
// "/":()=>text("Hello world"),
|
|
11
|
+
// "/id/:id":async ({id})=>{
|
|
12
|
+
// let resp = await fetch(`https://jsonplaceholder.typicode.com/todos/${id}`)
|
|
13
|
+
// let data = await resp.json()
|
|
14
|
+
// return Flex(
|
|
15
|
+
// text(data.title)
|
|
16
|
+
// )
|
|
17
|
+
// },
|
|
18
|
+
// "/users/:user":async ({user})=>{
|
|
19
|
+
// let resp = await fetch(`https://api.github.com/users/${user}`)
|
|
20
|
+
// const {name,followers,public_repos, avatar_url}= await resp.json()
|
|
21
|
+
// // console.log({name, followers, public_repos, avatar_url})
|
|
22
|
+
// useTitle(name)
|
|
23
|
+
// useFavIcon(avatar_url)
|
|
24
|
+
// const Card = Flex(
|
|
25
|
+
// text(name).style({
|
|
26
|
+
// color : "darkblue",
|
|
27
|
+
// fontSize : "1.4rem",
|
|
28
|
+
// border : "2px darkblue solid",
|
|
29
|
+
// padding : "10px",
|
|
30
|
+
// background:"tomato"
|
|
31
|
+
// }),
|
|
32
|
+
// image(avatar_url).size("200px","auto").style({outline : "2px darkblue solid"}),
|
|
33
|
+
// Flex(
|
|
34
|
+
// text(`N° followers : ${followers}`),
|
|
35
|
+
// text(`N° repos : ${public_repos}`)
|
|
36
|
+
// ).horizontal("space-around",0).size("80%","auto").style({
|
|
37
|
+
// color : "darkblue",
|
|
38
|
+
// border : "2px darkblue solid",
|
|
39
|
+
// padding : "10px",
|
|
40
|
+
// background:"tomato"
|
|
41
|
+
// })
|
|
42
|
+
// ).size("400px","400px").vertical(0,"space-around").style({
|
|
43
|
+
// border : "2px darkblue solid",
|
|
44
|
+
// background : "coral"
|
|
45
|
+
// })
|
|
46
|
+
// return Card
|
|
47
|
+
// },
|
|
48
|
+
// }
|
|
49
|
+
// })
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite App</title>
|
|
8
|
+
<link
|
|
9
|
+
href="https://fonts.googleapis.com/css?family=Gloria+Hallelujah&display=swap"
|
|
10
|
+
rel="stylesheet"
|
|
11
|
+
/>
|
|
12
|
+
<link href="https://fonts.cdnfonts.com/css/cheeronsta" rel="stylesheet">
|
|
13
|
+
|
|
14
|
+
<!-- <style>
|
|
15
|
+
body{
|
|
16
|
+
font-family: "Gloria Hallelujah", cursive;
|
|
17
|
+
font-weight: 700;
|
|
18
|
+
text-wrap :wrap !important;
|
|
19
|
+
overflow-x: hidden;
|
|
20
|
+
}
|
|
21
|
+
</style> -->
|
|
22
|
+
</head>
|
|
23
|
+
<body>
|
|
24
|
+
<script type="module" src="/main.js"></script>
|
|
25
|
+
<div id="app"></div>
|
|
26
|
+
</body>
|
|
27
|
+
</html>
|
package/preview/main.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useTitle } from "ziko"
|
|
2
|
+
import UI,{attributes} from "./test.mdz"
|
|
3
|
+
const {title, background} = attributes
|
|
4
|
+
title && useTitle(title)
|
|
5
|
+
UI().style({
|
|
6
|
+
border : "2px darkblue solid",
|
|
7
|
+
width : "70%",
|
|
8
|
+
margin : "auto",
|
|
9
|
+
padding : "10px",
|
|
10
|
+
fontFamily : "Cheeronsta",
|
|
11
|
+
background : background ?? "orange"
|
|
12
|
+
}).vertical(-1, "space-around")
|