@compiiile/compiiile 2.18.12 → 2.20.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/.compiiile/components.d.ts +23 -0
- package/.compiiile/src/components/ContentWrapper.vue +0 -187
- package/.compiiile/src/components/SlidesContent.vue +3 -3
- package/.compiiile/src/components/layout/navBar/FilesTree.vue +1 -0
- package/.compiiile/src/components/layout/navBar/NavBar.vue +4 -0
- package/.compiiile/src/components/layout/navBar/NavListItem.vue +142 -26
- package/.compiiile/src/layouts/BaseLayout.astro +2 -0
- package/.compiiile/src/layouts/NavBarFoldersStateLoader.astro +81 -0
- package/.compiiile/src/layouts/WorkspaceLayout.astro +1 -1
- package/.compiiile/src/pages/[...path].astro +1 -1
- package/.compiiile/src/style/content.css +185 -0
- package/.compiiile/src/style/index.css +1 -0
- package/4-pro-features.mdx +5 -5
- package/5-pro-slides.mdx +2 -0
- package/6-deploy.mdx +1 -0
- package/README.md +36 -16
- package/bin/config.js +14 -28
- package/bin/loadConfig.js +6 -0
- package/bin/vitePluginCompiiile/index.js +11 -17
- package/bin/vitePluginCompiiile/markdownConfig.js +28 -20
- package/bin/vitePluginCompiiile/models/Context.js +4 -3
- package/bin/vitePluginCompiiile/rehypeLinkPlugin.js +4 -4
- package/compiiile.config.js +7 -4
- package/dist/style.css +2 -1
- package/package.json +13 -12
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/* Putting the style from the ContentWrapper component here so that no "flash" occur in dev mode with HMR */
|
|
2
|
+
.page .content-wrapper .markdown-content {
|
|
3
|
+
margin-right: calc(var(--toc-width) + 80px);
|
|
4
|
+
|
|
5
|
+
h1,
|
|
6
|
+
h2,
|
|
7
|
+
h3,
|
|
8
|
+
h4,
|
|
9
|
+
h5 {
|
|
10
|
+
&:before {
|
|
11
|
+
/* hack to offset scroll on route hash navigation */
|
|
12
|
+
padding-top: calc(var(--top-bar-height) - 1px);
|
|
13
|
+
margin-top: calc((var(--top-bar-height) - 1px) * -1);
|
|
14
|
+
content: " ";
|
|
15
|
+
display: block;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
h2,
|
|
20
|
+
h3,
|
|
21
|
+
h4,
|
|
22
|
+
h5,
|
|
23
|
+
h6 {
|
|
24
|
+
margin: 20px 0 10px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
h2 {
|
|
28
|
+
margin-top: 40px;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
p code,
|
|
32
|
+
li code,
|
|
33
|
+
table code {
|
|
34
|
+
padding: 2px 4px;
|
|
35
|
+
border-radius: 3px;
|
|
36
|
+
background-color: var(--code-background-color);
|
|
37
|
+
border: solid 1px var(--code-background-color); /* same color, useful when printing without background graphics */
|
|
38
|
+
color: var(--code-color);
|
|
39
|
+
font-family: var(--monospace);
|
|
40
|
+
font-size: 0.85rem;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
p,
|
|
44
|
+
ul {
|
|
45
|
+
line-height: 1.618rem;
|
|
46
|
+
margin-bottom: 1rem;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
ul {
|
|
50
|
+
padding-left: 40px;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
hr {
|
|
54
|
+
margin: 40px 0;
|
|
55
|
+
background-color: var(--separator-color);
|
|
56
|
+
height: 1px;
|
|
57
|
+
border: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
blockquote {
|
|
61
|
+
background-color: var(--blockquote-background-color);
|
|
62
|
+
border: solid 1px var(--blockquote-border-color);
|
|
63
|
+
border-radius: 8px;
|
|
64
|
+
padding: 0.5em 1em;
|
|
65
|
+
color: var(--blockquote-color);
|
|
66
|
+
margin: 20px 0;
|
|
67
|
+
|
|
68
|
+
p {
|
|
69
|
+
margin-bottom: 0;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
code {
|
|
73
|
+
background-color: rgb(169 156 231 / 22%);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
img {
|
|
78
|
+
max-width: 100%;
|
|
79
|
+
margin: 20px auto;
|
|
80
|
+
display: block;
|
|
81
|
+
object-fit: contain;
|
|
82
|
+
height: auto;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
a {
|
|
86
|
+
color: var(--link-color);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
table {
|
|
90
|
+
padding: 0;
|
|
91
|
+
border-collapse: collapse;
|
|
92
|
+
margin-bottom: 20px;
|
|
93
|
+
display: block;
|
|
94
|
+
max-width: 100%;
|
|
95
|
+
overflow-x: auto;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
table tr {
|
|
99
|
+
border-top: 1px solid var(--table-border-color);
|
|
100
|
+
background-color: var(--table-odd-lines-background-color);
|
|
101
|
+
margin: 0;
|
|
102
|
+
padding: 0;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
table tr:nth-child(2n) {
|
|
106
|
+
background-color: var(--table-even-lines-background-color);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
table tr th {
|
|
110
|
+
font-weight: bold;
|
|
111
|
+
border: 1px solid var(--table-border-color);
|
|
112
|
+
text-align: left;
|
|
113
|
+
margin: 0;
|
|
114
|
+
padding: 6px 13px;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
table tr td {
|
|
118
|
+
border: 1px solid var(--table-border-color);
|
|
119
|
+
text-align: left;
|
|
120
|
+
margin: 0;
|
|
121
|
+
padding: 6px 13px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
table tr th :first-child,
|
|
125
|
+
table tr td :first-child {
|
|
126
|
+
margin-top: 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
table tr th :last-child,
|
|
130
|
+
table tr td :last-child {
|
|
131
|
+
margin-bottom: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
pre code {
|
|
135
|
+
margin-bottom: 1rem;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
pre.astro-code {
|
|
139
|
+
margin-bottom: 20px;
|
|
140
|
+
font-size: 0.85rem;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.header-anchor {
|
|
144
|
+
float: left;
|
|
145
|
+
margin-left: -0.87em;
|
|
146
|
+
padding-right: 0.23em;
|
|
147
|
+
font-weight: 500;
|
|
148
|
+
opacity: 0;
|
|
149
|
+
transition: opacity 0.25s;
|
|
150
|
+
text-decoration: none;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
h1:hover .header-anchor,
|
|
154
|
+
h2:hover .header-anchor,
|
|
155
|
+
h3:hover .header-anchor,
|
|
156
|
+
h4:hover .header-anchor,
|
|
157
|
+
h5:hover .header-anchor,
|
|
158
|
+
h6:hover .header-anchor,
|
|
159
|
+
.header-anchor:focus {
|
|
160
|
+
opacity: 1;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.siblings {
|
|
165
|
+
display: flex;
|
|
166
|
+
margin-right: calc(var(--toc-width) + 80px);
|
|
167
|
+
color: var(--link-color);
|
|
168
|
+
margin-top: 80px;
|
|
169
|
+
gap: 20px;
|
|
170
|
+
flex-wrap: wrap;
|
|
171
|
+
|
|
172
|
+
.sibling-link {
|
|
173
|
+
text-decoration: none;
|
|
174
|
+
border-radius: 2px;
|
|
175
|
+
|
|
176
|
+
&:focus-visible {
|
|
177
|
+
outline: solid 1px var(--separator-color);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.sibling-link--next {
|
|
182
|
+
text-align: right;
|
|
183
|
+
margin-left: auto;
|
|
184
|
+
}
|
|
185
|
+
}
|
package/4-pro-features.mdx
CHANGED
|
@@ -558,6 +558,7 @@ The `CGrid` component allows you to use a grid layout (very useful for slides):
|
|
|
558
558
|
</div>
|
|
559
559
|
|
|
560
560
|

|
|
561
|
+
|
|
561
562
|
</CGrid>
|
|
562
563
|
```
|
|
563
564
|
|
|
@@ -634,7 +635,6 @@ The `CDetails` component allows you to hide a block and reveal it by clicking on
|
|
|
634
635
|
```
|
|
635
636
|
</CDetails>
|
|
636
637
|
|
|
637
|
-
|
|
638
638
|
### CSlide
|
|
639
639
|
|
|
640
640
|
The `CSlide` component can be used for every slide, it allows you to align content the way you want (horizontally and vertically), and to use custom themes.
|
|
@@ -656,8 +656,8 @@ The `CSlide` component can be used for every slide, it allows you to align conte
|
|
|
656
656
|
|
|
657
657
|
</CSlide>
|
|
658
658
|
```
|
|
659
|
-
</CDetails>
|
|
660
659
|
|
|
660
|
+
</CDetails>
|
|
661
661
|
|
|
662
662
|
### CGap
|
|
663
663
|
|
|
@@ -666,7 +666,7 @@ The `CGap` component can be used in slides, allowing you to add a gap between el
|
|
|
666
666
|
- The gap can be set with the `width` and `height` prop (accepting CSS values).
|
|
667
667
|
|
|
668
668
|
<CDetails summary="Example">
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
669
|
+
```mdx
|
|
670
|
+
<CGap height="100px" />
|
|
671
|
+
```
|
|
672
672
|
</CDetails>
|
package/5-pro-slides.mdx
CHANGED
|
@@ -43,6 +43,7 @@ description: "Use icons, admonitions, mermaid diagrams, markmap mindmaps in Mark
|
|
|
43
43
|
|
|
44
44
|
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. From [xodnnhm](https://giphy.com/xodnnhm).
|
|
45
45
|
</div>
|
|
46
|
+
|
|
46
47
|
</CGrid>
|
|
47
48
|
|
|
48
49
|
---
|
|
@@ -68,6 +69,7 @@ description: "Use icons, admonitions, mermaid diagrams, markmap mindmaps in Mark
|
|
|
68
69
|
<span slot="title">Title</span>
|
|
69
70
|
<span slot="description">Some description</span>
|
|
70
71
|
</CCard>
|
|
72
|
+
|
|
71
73
|
</CGrid>
|
|
72
74
|
|
|
73
75
|
---
|
package/6-deploy.mdx
CHANGED
|
@@ -30,6 +30,7 @@ You'll have all your static files generated in the `.compiiile/dist` folder, rea
|
|
|
30
30
|
## Deploy your Markdown files on Vercel :globe_with_meridians:
|
|
31
31
|
|
|
32
32
|
In your project's `Settings` tab, put these settings:
|
|
33
|
+
|
|
33
34
|
- Framework preset: `Other`
|
|
34
35
|
- Build command: `compiiile build --title="Hello world!"`
|
|
35
36
|
- Output directory: `.compiiile/dist`
|
package/README.md
CHANGED
|
@@ -21,7 +21,8 @@ That's what Compiiile does. And it does it hassle-free !
|
|
|
21
21
|
## Features
|
|
22
22
|
|
|
23
23
|
- [x] 📦 **No config required, everything just works out of the box, without changing your files** (resolves images and
|
|
24
|
-
relative links (cross-references), print-ready rendering, :sunny: light and :first_quarter_moon_with_face: dark
|
|
24
|
+
relative links (cross-references), print-ready rendering, :sunny: light and :first_quarter_moon_with_face: dark
|
|
25
|
+
themes)
|
|
25
26
|
- [x] 🌱 Available everywhere with static files deployment: just host it somewhere and access it in any browser on your
|
|
26
27
|
computer, phone or whatever you are using
|
|
27
28
|
- [x] :link: Quick access to your files via the navbar and links to the previous and next file (with table of content
|
|
@@ -49,7 +50,8 @@ You can install Compiiile either globally or per-project:
|
|
|
49
50
|
|
|
50
51
|
### Globally
|
|
51
52
|
|
|
52
|
-
Open a terminal and type one of these commands, whether using [npm](https://www.npmjs.com/)
|
|
53
|
+
Open a terminal and type one of these commands, whether using [npm](https://www.npmjs.com/)
|
|
54
|
+
or [yarn](https://yarnpkg.com/) depending on which package manager you are using:
|
|
53
55
|
|
|
54
56
|
```bash
|
|
55
57
|
yarn global add @compiiile/compiiile # install globally with yarn
|
|
@@ -188,14 +190,18 @@ Other frontmatter keys are handled:
|
|
|
188
190
|
- `textAlign`: possible values
|
|
189
191
|
are [CSS text-align values](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align) (`left`, `center`, ...). This
|
|
190
192
|
changes the default text alignment in slides. The default value is `center`.
|
|
191
|
-
- `ignore` : Boolean value (`true` or `false`) to ignore the current file and exclude it from Compiiile (the file is not
|
|
192
|
-
|
|
193
|
+
- `ignore` : Boolean value (`true` or `false`) to ignore the current file and exclude it from Compiiile (the file is not
|
|
194
|
+
ignored by default).
|
|
195
|
+
- `hidden` : Boolean value (`true` or `false`) to hide the file from the navbar and siblings links (the file is not
|
|
196
|
+
hidden by default).
|
|
193
197
|
|
|
194
|
-
> :bulb: You can override slides theme (light or dark) by passing it to a `theme` query parameter in your slide url (for
|
|
198
|
+
> :bulb: You can override slides theme (light or dark) by passing it to a `theme` query parameter in your slide url (for
|
|
199
|
+
> example `/s/slides?theme=light`). See the `theme` config parameter below for valid values.
|
|
195
200
|
|
|
196
201
|
### Routing
|
|
197
202
|
|
|
198
|
-
The home page of Compiiile (`/`) points to a `README.md` file located at the root of your folder, or fallbacks to an
|
|
203
|
+
The home page of Compiiile (`/`) points to a `README.md` file located at the root of your folder, or fallbacks to an
|
|
204
|
+
`index.md` file.
|
|
199
205
|
|
|
200
206
|
## Custom configuration
|
|
201
207
|
|
|
@@ -219,6 +225,7 @@ Here is the list of parameters that you can set to customize Compiiile (none are
|
|
|
219
225
|
| `printReady` | `Boolean` | Add a `/print` page to display a full ready-to-print content (uses `@compiiile/compiiile-print`) |
|
|
220
226
|
| `css` | `string` | A relative path to a custom CSS file to customize the style <br/>:warning: Requires `compiiile-pro` |
|
|
221
227
|
| `integrations` | `AstroIntegration[]` | An array of Astro Integrations for [custom Astro hooks implementations](https://docs.astro.build/en/reference/integrations-reference/#astroconfigsetup): injecting CSS, javascript, etc |
|
|
228
|
+
| `collapseFolders` | `Boolean` | If set to `true`, folders in the navbar will be collapsed by default. Defaults to `false` |
|
|
222
229
|
|
|
223
230
|
You can use these parameters in 2 ways:
|
|
224
231
|
|
|
@@ -249,13 +256,17 @@ export default {
|
|
|
249
256
|
|
|
250
257
|
> ⚠️ You should bear in mind that script arguments have priority over config file parameters.
|
|
251
258
|
|
|
252
|
-
> :bulb: Compiiile uses [c12](https://github.com/unjs/c12) to load the config file, which allows to **extend config
|
|
259
|
+
> :bulb: Compiiile uses [c12](https://github.com/unjs/c12) to load the config file, which allows to **extend config
|
|
260
|
+
> values** from other files. See
|
|
261
|
+
> the [dedicated c12 documentation](https://github.com/unjs/c12?tab=readme-ov-file#extending-configuration) for more
|
|
262
|
+
> information.
|
|
253
263
|
|
|
254
264
|
## Public files
|
|
255
265
|
|
|
256
266
|
If you want some files to be public, just create a folder named `public` at the root of your Compiiile folder.
|
|
257
267
|
|
|
258
|
-
For example, if you want to link to a local PDF in your Markdown file, you can put your PDF in your local public
|
|
268
|
+
For example, if you want to link to a local PDF in your Markdown file, you can put your PDF in your local public
|
|
269
|
+
directory, in `public/my-pdf.pdf`.
|
|
259
270
|
Then, all you have to do is creating a link in Markdown with an absolute path like so :
|
|
260
271
|
|
|
261
272
|
```markdown
|
|
@@ -317,7 +328,9 @@ import Test from "./Test.vue"
|
|
|
317
328
|
<Test client:load />
|
|
318
329
|
```
|
|
319
330
|
|
|
320
|
-
You should
|
|
331
|
+
You should
|
|
332
|
+
use [Astro's client directives](https://docs.astro.build/en/reference/directives-reference/#client-directives) to load
|
|
333
|
+
your component's script (`client:load` is not necessary on all your components).
|
|
321
334
|
|
|
322
335
|
### Using config data values
|
|
323
336
|
|
|
@@ -342,9 +355,11 @@ description: some description
|
|
|
342
355
|
{ frontmatter.description }
|
|
343
356
|
```
|
|
344
357
|
|
|
345
|
-
> :books: More info in
|
|
358
|
+
> :books: More info in
|
|
359
|
+
> the [dedicated Astro documentation](https://docs.astro.build/en/guides/integrations-guide/mdx/#using-frontmatter-variables-in-mdx).
|
|
346
360
|
|
|
347
|
-
In your custom components, you can access the current page's frontmatter by using the `pageFrontmatter` property from
|
|
361
|
+
In your custom components, you can access the current page's frontmatter by using the `pageFrontmatter` property from
|
|
362
|
+
Compiiile's Vite plugin:
|
|
348
363
|
|
|
349
364
|
```vue
|
|
350
365
|
<template>
|
|
@@ -367,9 +382,11 @@ In your custom components, you can access the current page's frontmatter by usin
|
|
|
367
382
|
|
|
368
383
|
## Ignoring files and folders
|
|
369
384
|
|
|
370
|
-
To ignore a whole folder or some files matching a certain pattern, you can add a `.compiiileignore` at the root of the
|
|
385
|
+
To ignore a whole folder or some files matching a certain pattern, you can add a `.compiiileignore` at the root of the
|
|
386
|
+
folder where you run Compiiile.
|
|
371
387
|
|
|
372
|
-
This file accepts glob patterns to ignore files. For example, if you want to ignore files containing the word `preview`
|
|
388
|
+
This file accepts glob patterns to ignore files. For example, if you want to ignore files containing the word `preview`
|
|
389
|
+
and files starting with a number,
|
|
373
390
|
you can simply put these 2 lines in your `.compiiileignore`:
|
|
374
391
|
|
|
375
392
|
```ignorelang
|
|
@@ -400,12 +417,15 @@ You can read more about it and the roadmap in the [dedicated contributing guide]
|
|
|
400
417
|
|
|
401
418
|
You can add features to Compiiile by using the following projects:
|
|
402
419
|
|
|
403
|
-
- [compiiile-pro](https://compiiile.me/c/3-pro-installation): Enhance your Markdown files, add diagrams, mindmaps,
|
|
404
|
-
|
|
420
|
+
- [compiiile-pro](https://compiiile.me/c/3-pro-installation): Enhance your Markdown files, add diagrams, mindmaps,
|
|
421
|
+
admonitions, and ready-made components
|
|
422
|
+
- [compiiile-print](https://github.com/compiiile/compiiile-print): Add a print ready page containing all your Markdown
|
|
423
|
+
files
|
|
405
424
|
|
|
406
425
|
Here is a list of projects related to Compiiile developed by the community:
|
|
407
426
|
|
|
408
|
-
- [compiiile-actions-cloudflare-pages](https://github.com/marketplace/actions/compiiile-cloudflare-pages): A simple
|
|
427
|
+
- [compiiile-actions-cloudflare-pages](https://github.com/marketplace/actions/compiiile-cloudflare-pages): A simple
|
|
428
|
+
GitHub action to deploy a Compiiile site to CloudFlare pages
|
|
409
429
|
|
|
410
430
|
## Support
|
|
411
431
|
|
package/bin/config.js
CHANGED
|
@@ -13,6 +13,7 @@ import { createRequire } from "node:module"
|
|
|
13
13
|
import { packageDirectory } from "package-directory"
|
|
14
14
|
|
|
15
15
|
import { loadConfig } from "./loadConfig.js"
|
|
16
|
+
import Context from "./vitePluginCompiiile/models/Context.js";
|
|
16
17
|
|
|
17
18
|
const { argv, localIntegrations, configFromFile, source, hasPublicFiles, publicDir } = await loadConfig()
|
|
18
19
|
|
|
@@ -38,6 +39,9 @@ if (packageDir) {
|
|
|
38
39
|
viteServerFsAllowList.push(packageDir)
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
let sharedContext = new Context()
|
|
43
|
+
sharedContext.filesTree = await sharedContext.scanDirectoryRecursively(".")
|
|
44
|
+
|
|
41
45
|
const astroConfig = {
|
|
42
46
|
server: {
|
|
43
47
|
host: argv.host,
|
|
@@ -56,39 +60,21 @@ const astroConfig = {
|
|
|
56
60
|
{
|
|
57
61
|
name: "include-dependencies",
|
|
58
62
|
hooks: {
|
|
59
|
-
"astro:build:setup": ({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"@babel/parser",
|
|
68
|
-
"estree-walker",
|
|
69
|
-
"source-map-js",
|
|
70
|
-
"@vue/runtime-dom",
|
|
71
|
-
"@vue/runtime-core",
|
|
72
|
-
"@vue/reactivity",
|
|
73
|
-
"@vue/server-renderer",
|
|
74
|
-
"@vue/compiler-ssr",
|
|
75
|
-
"html-escaper",
|
|
76
|
-
"@oslojs/encoding",
|
|
77
|
-
"cssesc",
|
|
78
|
-
"fzf",
|
|
79
|
-
"@astrojs/internal-helpers",
|
|
80
|
-
"mrmime",
|
|
81
|
-
"zod",
|
|
82
|
-
"entities",
|
|
83
|
-
"piccolore"
|
|
84
|
-
)
|
|
63
|
+
"astro:build:setup": ({ updateConfig }) => {
|
|
64
|
+
updateConfig({
|
|
65
|
+
vite: {
|
|
66
|
+
ssr: {
|
|
67
|
+
noExternal: true
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
})
|
|
85
71
|
}
|
|
86
72
|
}
|
|
87
73
|
}
|
|
88
74
|
],
|
|
89
75
|
...(process.env.VITE_COMPIIILE_SITE_URL ? { site: process.env.VITE_COMPIIILE_SITE_URL } : {}),
|
|
90
76
|
vite: {
|
|
91
|
-
plugins: [compiiile()],
|
|
77
|
+
plugins: [compiiile(sharedContext)],
|
|
92
78
|
resolve: {
|
|
93
79
|
preserveSymlinks: true,
|
|
94
80
|
alias: {
|
|
@@ -101,7 +87,7 @@ const astroConfig = {
|
|
|
101
87
|
}
|
|
102
88
|
}
|
|
103
89
|
},
|
|
104
|
-
markdown: markdownConfig,
|
|
90
|
+
markdown: markdownConfig(sharedContext),
|
|
105
91
|
output: "static",
|
|
106
92
|
base: "/",
|
|
107
93
|
trailingSlash: "never",
|
package/bin/loadConfig.js
CHANGED
|
@@ -107,6 +107,10 @@ export const loadConfig = async () => {
|
|
|
107
107
|
.option("printReady", {
|
|
108
108
|
describe: "Add a /print page to display a full ready-to-print content (uses @compiiile/compiiile-print)"
|
|
109
109
|
})
|
|
110
|
+
.option("collapseFolders", {
|
|
111
|
+
describe: "Whether folders are collapsed by default in the navbar (expanded by default)",
|
|
112
|
+
default: false
|
|
113
|
+
})
|
|
110
114
|
.help()
|
|
111
115
|
.version(packageJSON.version).argv
|
|
112
116
|
|
|
@@ -123,6 +127,8 @@ export const loadConfig = async () => {
|
|
|
123
127
|
process.env.VITE_COMPIIILE_DATA = typeof argv.data === "string" ? argv.data : JSON.stringify(argv.data ?? {})
|
|
124
128
|
process.env.VITE_COMPIIILE_USE_AUTO_TITLES = /true/i.test(argv.useAutoTitles) // defaults to `false` if not set or not equal to `true`
|
|
125
129
|
|
|
130
|
+
process.env.VITE_COMPIIILE_COLLAPSE_FOLDERS = /true/i.test(argv.collapseFolders) // defaults to `false` if not set or not equal to `true`
|
|
131
|
+
|
|
126
132
|
// Handling logo and favicon
|
|
127
133
|
process.env.VITE_COMPIIILE_LOGO = null
|
|
128
134
|
|
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import Context from "./models/Context.js"
|
|
2
2
|
import { createMarkdownProcessor } from "@astrojs/markdown-remark"
|
|
3
|
-
import
|
|
3
|
+
import {rehypePlugins, remarkPlugins, shikiConfig} from "./markdownConfig.js"
|
|
4
4
|
import path from "node:path"
|
|
5
5
|
import { loadConfig } from "../loadConfig.js"
|
|
6
6
|
import { promises as fs } from "node:fs"
|
|
7
7
|
|
|
8
8
|
const source = "."
|
|
9
9
|
|
|
10
|
-
let context = null
|
|
11
|
-
|
|
12
10
|
const pathFromSource = (filePath) => {
|
|
13
11
|
return filePath?.replace(process.env.COMPIIILE_SOURCE + "/", "")
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
export default function compiiile() {
|
|
14
|
+
export default function compiiile(sharedContext) {
|
|
17
15
|
const virtualModuleId = "virtual:compiiile"
|
|
18
16
|
const resolvedVirtualModuleId = "\0" + virtualModuleId
|
|
19
17
|
|
|
@@ -29,14 +27,10 @@ export default function compiiile() {
|
|
|
29
27
|
return
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return `const fileList = ${JSON.stringify(context.fileList)};\n\n
|
|
37
|
-
const filesTree = ${JSON.stringify(context.filesTree)};\n\n
|
|
38
|
-
const routeList = ${JSON.stringify(context.routeList)};\n\n
|
|
39
|
-
const site = ${JSON.stringify(context.site)};\n\n
|
|
30
|
+
return `const fileList = ${JSON.stringify(sharedContext.fileList)};\n\n
|
|
31
|
+
const filesTree = ${JSON.stringify(sharedContext.filesTree)};\n\n
|
|
32
|
+
const routeList = ${JSON.stringify(sharedContext.routeList)};\n\n
|
|
33
|
+
const site = ${JSON.stringify(sharedContext.site)};\n\n
|
|
40
34
|
export { fileList, filesTree, routeList, site };`
|
|
41
35
|
},
|
|
42
36
|
async hotUpdate({ file, read }) {
|
|
@@ -47,12 +41,12 @@ export default function compiiile() {
|
|
|
47
41
|
try {
|
|
48
42
|
const content = await read()
|
|
49
43
|
|
|
50
|
-
const routeListItem =
|
|
44
|
+
const routeListItem = sharedContext.routeList.find((route) => route.fullPath === absolutePath)
|
|
51
45
|
|
|
52
|
-
const markdownProcessor = await createMarkdownProcessor(
|
|
46
|
+
const markdownProcessor = await createMarkdownProcessor({remarkPlugins, rehypePlugins: rehypePlugins(sharedContext), shikiConfig})
|
|
53
47
|
const renderedMarkdown = await markdownProcessor.render(content)
|
|
54
48
|
|
|
55
|
-
const title =
|
|
49
|
+
const title = sharedContext.getFileTitleFromProcessedMarkdown(renderedMarkdown)
|
|
56
50
|
const meta = renderedMarkdown.metadata.frontmatter
|
|
57
51
|
meta.title = title || path.parse(file).name
|
|
58
52
|
|
|
@@ -64,11 +58,11 @@ export default function compiiile() {
|
|
|
64
58
|
const currentStateIsAsSlides = !!meta.asSlides
|
|
65
59
|
|
|
66
60
|
if (prevStateWasAsSlides !== currentStateIsAsSlides) {
|
|
67
|
-
const newRoutePath =
|
|
61
|
+
const newRoutePath = sharedContext.generateRoutePathFromFilePath(
|
|
68
62
|
routeListItem.fullPath,
|
|
69
63
|
"",
|
|
70
64
|
currentStateIsAsSlides,
|
|
71
|
-
|
|
65
|
+
sharedContext.getEntryFileMatcher([routeListItem.fullPath])
|
|
72
66
|
)
|
|
73
67
|
|
|
74
68
|
this.environment.hot.send({
|
|
@@ -5,26 +5,34 @@ import rehypeSlug from "rehype-slug"
|
|
|
5
5
|
import rehypeAutolinkHeadings from "rehype-autolink-headings"
|
|
6
6
|
import { h } from "hastscript"
|
|
7
7
|
import rehypeHandleYamlMatterPlugin from "./rehypeHandleYamlMatterPlugin.js"
|
|
8
|
+
import { unified } from '@astrojs/markdown-remark';
|
|
8
9
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
tabIndex: -1,
|
|
23
|
-
class: "header-anchor"
|
|
24
|
-
}
|
|
10
|
+
export const remarkPlugins = [remarkEmoji]
|
|
11
|
+
export const rehypePlugins = (sharedContext) => [
|
|
12
|
+
rehypeImagePlugin,
|
|
13
|
+
rehypeSlug,
|
|
14
|
+
[
|
|
15
|
+
rehypeAutolinkHeadings,
|
|
16
|
+
{
|
|
17
|
+
behavior: "prepend",
|
|
18
|
+
content: () => [h("span", "#")],
|
|
19
|
+
properties: {
|
|
20
|
+
ariaHidden: true,
|
|
21
|
+
tabIndex: -1,
|
|
22
|
+
class: "header-anchor"
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
rehypeHandleYamlMatterPlugin
|
|
24
|
+
}
|
|
28
25
|
],
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
rehypeHandleYamlMatterPlugin,
|
|
27
|
+
[rehypeLinkPlugin, sharedContext]
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
export const shikiConfig = { theme: "css-variables" }
|
|
31
|
+
|
|
32
|
+
export default (sharedContext) => ({
|
|
33
|
+
processor: unified({
|
|
34
|
+
remarkPlugins,
|
|
35
|
+
rehypePlugins: rehypePlugins(sharedContext)
|
|
36
|
+
}),
|
|
37
|
+
shikiConfig
|
|
38
|
+
})
|
|
@@ -5,7 +5,7 @@ import FileListItem from "./FileListItem.js"
|
|
|
5
5
|
import FilesTreeItem from "./FilesTreeItem.js"
|
|
6
6
|
import RouteListItem from "./RouteListItem.js"
|
|
7
7
|
import { createMarkdownProcessor } from "@astrojs/markdown-remark"
|
|
8
|
-
import
|
|
8
|
+
import {remarkPlugins, rehypePlugins, shikiConfig} from "../markdownConfig.js"
|
|
9
9
|
import { unemojify } from "node-emoji"
|
|
10
10
|
import slugify from "slugify"
|
|
11
11
|
import parseIgnore from "parse-gitignore"
|
|
@@ -30,7 +30,8 @@ export default class {
|
|
|
30
30
|
siteUrl: process.env.VITE_COMPIIILE_SITE_URL !== "" ? process.env.VITE_COMPIIILE_SITE_URL : undefined,
|
|
31
31
|
base: process.env.VITE_COMPIIILE_BASE,
|
|
32
32
|
data: JSON.parse(process.env.VITE_COMPIIILE_DATA),
|
|
33
|
-
theme: process.env.VITE_COMPIIILE_THEME
|
|
33
|
+
theme: process.env.VITE_COMPIIILE_THEME,
|
|
34
|
+
collapseFolders: JSON.parse(process.env.VITE_COMPIIILE_COLLAPSE_FOLDERS)
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -151,7 +152,7 @@ export default class {
|
|
|
151
152
|
encoding: "utf8"
|
|
152
153
|
})
|
|
153
154
|
|
|
154
|
-
const markdownProcessor = await createMarkdownProcessor(
|
|
155
|
+
const markdownProcessor = await createMarkdownProcessor({remarkPlugins, rehypePlugins: rehypePlugins(this), shikiConfig})
|
|
155
156
|
const renderedMarkdown = await markdownProcessor.render(markdownContent)
|
|
156
157
|
|
|
157
158
|
fileListItem.textContent = unemojify(
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { visit } from "unist-util-visit"
|
|
2
2
|
|
|
3
|
-
export default function rehypeLinkPlugin() {
|
|
3
|
+
export default function rehypeLinkPlugin(sharedContext) {
|
|
4
4
|
return (tree, file) => {
|
|
5
|
-
const context = JSON.parse(process.env.context || "{}")
|
|
6
5
|
visit(tree, "element", (node) => {
|
|
7
6
|
if (node.tagName === "a") {
|
|
8
7
|
if (node.properties.href.match(/^\.{1,2}\/.*/)) {
|
|
@@ -10,8 +9,9 @@ export default function rehypeLinkPlugin() {
|
|
|
10
9
|
const path = decodeURI(linkTargetUrl.pathname).replaceAll("%20", " ")
|
|
11
10
|
const decodedFilePath = decodeURIComponent(decodeURIComponent(path))
|
|
12
11
|
const filePath = decodedFilePath.replace(process.env.COMPIIILE_SOURCE, "")
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
|
|
13
|
+
node.properties.href = sharedContext?.fileRouteMap?.[filePath.substring(1)] + linkTargetUrl.hash
|
|
14
|
+
} else if(!node.properties.href.startsWith("#")){
|
|
15
15
|
node.properties.target = "_blank"
|
|
16
16
|
}
|
|
17
17
|
}
|