@compiiile/compiiile 2.19.0 → 2.20.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.
@@ -119,190 +119,3 @@
119
119
  }
120
120
  }
121
121
  </script>
122
-
123
- <style scoped>
124
- :deep(.markdown-content) {
125
- margin-right: calc(var(--toc-width) + 80px);
126
-
127
- h1,
128
- h2,
129
- h3,
130
- h4,
131
- h5 {
132
- &:before {
133
- /* hack to offset scroll on route hash navigation */
134
- padding-top: calc(var(--top-bar-height) - 1px);
135
- margin-top: calc((var(--top-bar-height) - 1px) * -1);
136
- content: " ";
137
- display: block;
138
- }
139
- }
140
-
141
- h2,
142
- h3,
143
- h4,
144
- h5,
145
- h6 {
146
- margin: 20px 0 10px;
147
- }
148
-
149
- h2 {
150
- margin-top: 40px;
151
- }
152
-
153
- p code,
154
- li code,
155
- table code {
156
- padding: 2px 4px;
157
- border-radius: 3px;
158
- background-color: var(--code-background-color);
159
- border: solid 1px var(--code-background-color); /* same color, useful when printing without background graphics */
160
- color: var(--code-color);
161
- font-family: var(--monospace);
162
- font-size: 0.85rem;
163
- }
164
-
165
- p,
166
- ul {
167
- line-height: 1.618rem;
168
- margin-bottom: 1rem;
169
- }
170
-
171
- ul {
172
- padding-left: 40px;
173
- }
174
-
175
- hr {
176
- margin: 40px 0;
177
- background-color: var(--separator-color);
178
- height: 1px;
179
- border: 0;
180
- }
181
-
182
- blockquote {
183
- background-color: var(--blockquote-background-color);
184
- border: solid 1px var(--blockquote-border-color);
185
- border-radius: 8px;
186
- padding: 0.5em 1em;
187
- color: var(--blockquote-color);
188
- margin: 20px 0;
189
-
190
- p {
191
- margin-bottom: 0;
192
- }
193
-
194
- code {
195
- background-color: rgb(169 156 231 / 22%);
196
- }
197
- }
198
-
199
- img {
200
- max-width: 100%;
201
- margin: 20px auto;
202
- display: block;
203
- object-fit: contain;
204
- height: auto;
205
- }
206
-
207
- a {
208
- color: var(--link-color);
209
- }
210
-
211
- table {
212
- padding: 0;
213
- border-collapse: collapse;
214
- margin-bottom: 20px;
215
- display: block;
216
- max-width: 100%;
217
- overflow-x: auto;
218
- }
219
-
220
- table tr {
221
- border-top: 1px solid var(--table-border-color);
222
- background-color: var(--table-odd-lines-background-color);
223
- margin: 0;
224
- padding: 0;
225
- }
226
-
227
- table tr:nth-child(2n) {
228
- background-color: var(--table-even-lines-background-color);
229
- }
230
-
231
- table tr th {
232
- font-weight: bold;
233
- border: 1px solid var(--table-border-color);
234
- text-align: left;
235
- margin: 0;
236
- padding: 6px 13px;
237
- }
238
-
239
- table tr td {
240
- border: 1px solid var(--table-border-color);
241
- text-align: left;
242
- margin: 0;
243
- padding: 6px 13px;
244
- }
245
-
246
- table tr th :first-child,
247
- table tr td :first-child {
248
- margin-top: 0;
249
- }
250
-
251
- table tr th :last-child,
252
- table tr td :last-child {
253
- margin-bottom: 0;
254
- }
255
-
256
- pre code {
257
- margin-bottom: 1rem;
258
- }
259
-
260
- pre.astro-code {
261
- margin-bottom: 20px;
262
- font-size: 0.85rem;
263
- }
264
-
265
- .header-anchor {
266
- float: left;
267
- margin-left: -0.87em;
268
- padding-right: 0.23em;
269
- font-weight: 500;
270
- opacity: 0;
271
- transition: opacity 0.25s;
272
- text-decoration: none;
273
- }
274
-
275
- h1:hover .header-anchor,
276
- h2:hover .header-anchor,
277
- h3:hover .header-anchor,
278
- h4:hover .header-anchor,
279
- h5:hover .header-anchor,
280
- h6:hover .header-anchor,
281
- .header-anchor:focus {
282
- opacity: 1;
283
- }
284
- }
285
-
286
- .siblings {
287
- display: flex;
288
- margin-right: calc(var(--toc-width) + 80px);
289
- color: var(--link-color);
290
- margin-top: 80px;
291
- gap: 20px;
292
- flex-wrap: wrap;
293
-
294
- .sibling-link {
295
- text-decoration: none;
296
- border-radius: 2px;
297
-
298
- &:focus-visible {
299
- outline: solid 1px var(--separator-color);
300
- }
301
- }
302
-
303
- .sibling-link--next {
304
- text-align: right;
305
- margin-left: auto;
306
- }
307
- }
308
- </style>
@@ -73,11 +73,11 @@
73
73
  </script>
74
74
 
75
75
  <style>
76
- @import "reveal.js/dist/reveal.css";
77
- @import "reveal.js/dist/theme/black.css";
76
+ @import "reveal.js/reveal.css";
77
+ @import "reveal.js/theme/black.css";
78
78
  @import "../style/slides.css";
79
79
 
80
- :global(#app) {
80
+ #app {
81
81
  height: 100%;
82
82
  }
83
83
 
@@ -17,7 +17,7 @@
17
17
  }
18
18
  },
19
19
  mounted() {
20
- // This is to delegate folder state to the client instead of the values computed on page load to prevent blinking
20
+ // This is to delegate folder state to the client instead of the values computed on page load to prevent blinking
21
21
  document.getElementById("compiiile-folders-state-style")?.remove()
22
22
  }
23
23
  }
@@ -60,7 +60,7 @@ const tableOfContent = getHeadings()
60
60
 
61
61
  <WorkspaceLayout title={title} description={description} isNotFoundPage={false}>
62
62
  <ContentWrapper name={name} tableOfContent={tableOfContent}>
63
- <Content/>
63
+ <Content />
64
64
  </ContentWrapper>
65
65
  </WorkspaceLayout>
66
66
  }
@@ -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
+ }
@@ -3,6 +3,7 @@
3
3
  @import "./layouts.css";
4
4
  @import "./print.css";
5
5
  @import "./code-theme.css";
6
+ @import "./content.css";
6
7
 
7
8
  *,
8
9
  *::before,
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,27 @@ const astroConfig = {
56
60
  {
57
61
  name: "include-dependencies",
58
62
  hooks: {
59
- "astro:build:setup": ({ vite }) => {
60
- vite.ssr.noExternal.push(
61
- "kleur",
62
- "clsx",
63
- "vue",
64
- "@vue/compiler-dom",
65
- "@vue/compiler-core",
66
- "@vue/shared",
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
+ // fixing packages not included for certain environments (like 'piccolore' when installed globally)
64
+ "astro:build:setup": ({ updateConfig }) => {
65
+ updateConfig({
66
+ ssr: {
67
+ noExternal: true
68
+ },
69
+ environments: {
70
+ prerender: {
71
+ resolve: {
72
+ noExternal: true
73
+ }
74
+ }
75
+ }
76
+ })
85
77
  }
86
78
  }
87
79
  }
88
80
  ],
89
81
  ...(process.env.VITE_COMPIIILE_SITE_URL ? { site: process.env.VITE_COMPIIILE_SITE_URL } : {}),
90
82
  vite: {
91
- plugins: [compiiile()],
83
+ plugins: [compiiile(sharedContext)],
92
84
  resolve: {
93
85
  preserveSymlinks: true,
94
86
  alias: {
@@ -101,7 +93,7 @@ const astroConfig = {
101
93
  }
102
94
  }
103
95
  },
104
- markdown: markdownConfig,
96
+ markdown: markdownConfig(sharedContext),
105
97
  output: "static",
106
98
  base: "/",
107
99
  trailingSlash: "never",
@@ -1,19 +1,14 @@
1
- import Context from "./models/Context.js"
2
1
  import { createMarkdownProcessor } from "@astrojs/markdown-remark"
3
- import markdownConfig from "./markdownConfig.js"
2
+ import { rehypePlugins, remarkPlugins, shikiConfig } from "./markdownConfig.js"
4
3
  import path from "node:path"
5
4
  import { loadConfig } from "../loadConfig.js"
6
5
  import { promises as fs } from "node:fs"
7
6
 
8
- const source = "."
9
-
10
- let context = null
11
-
12
7
  const pathFromSource = (filePath) => {
13
8
  return filePath?.replace(process.env.COMPIIILE_SOURCE + "/", "")
14
9
  }
15
10
 
16
- export default function compiiile() {
11
+ export default function compiiile(sharedContext) {
17
12
  const virtualModuleId = "virtual:compiiile"
18
13
  const resolvedVirtualModuleId = "\0" + virtualModuleId
19
14
 
@@ -29,14 +24,10 @@ export default function compiiile() {
29
24
  return
30
25
  }
31
26
 
32
- context = new Context()
33
- context.filesTree = await context.scanDirectoryRecursively(source)
34
- process.env.context = JSON.stringify(context)
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
27
+ return `const fileList = ${JSON.stringify(sharedContext.fileList)};\n\n
28
+ const filesTree = ${JSON.stringify(sharedContext.filesTree)};\n\n
29
+ const routeList = ${JSON.stringify(sharedContext.routeList)};\n\n
30
+ const site = ${JSON.stringify(sharedContext.site)};\n\n
40
31
  export { fileList, filesTree, routeList, site };`
41
32
  },
42
33
  async hotUpdate({ file, read }) {
@@ -47,12 +38,16 @@ export default function compiiile() {
47
38
  try {
48
39
  const content = await read()
49
40
 
50
- const routeListItem = context.routeList.find((route) => route.fullPath === absolutePath)
41
+ const routeListItem = sharedContext.routeList.find((route) => route.fullPath === absolutePath)
51
42
 
52
- const markdownProcessor = await createMarkdownProcessor(markdownConfig)
43
+ const markdownProcessor = await createMarkdownProcessor({
44
+ remarkPlugins,
45
+ rehypePlugins: rehypePlugins(sharedContext),
46
+ shikiConfig
47
+ })
53
48
  const renderedMarkdown = await markdownProcessor.render(content)
54
49
 
55
- const title = context.getFileTitleFromProcessedMarkdown(renderedMarkdown)
50
+ const title = sharedContext.getFileTitleFromProcessedMarkdown(renderedMarkdown)
56
51
  const meta = renderedMarkdown.metadata.frontmatter
57
52
  meta.title = title || path.parse(file).name
58
53
 
@@ -64,11 +59,11 @@ export default function compiiile() {
64
59
  const currentStateIsAsSlides = !!meta.asSlides
65
60
 
66
61
  if (prevStateWasAsSlides !== currentStateIsAsSlides) {
67
- const newRoutePath = context.generateRoutePathFromFilePath(
62
+ const newRoutePath = sharedContext.generateRoutePathFromFilePath(
68
63
  routeListItem.fullPath,
69
64
  "",
70
65
  currentStateIsAsSlides,
71
- context.getEntryFileMatcher([routeListItem.fullPath])
66
+ sharedContext.getEntryFileMatcher([routeListItem.fullPath])
72
67
  )
73
68
 
74
69
  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 default {
10
- remarkPlugins: [remarkEmoji],
11
- rehypePlugins: [
12
- rehypeImagePlugin,
13
- rehypeLinkPlugin,
14
- rehypeSlug,
15
- [
16
- rehypeAutolinkHeadings,
17
- {
18
- behavior: "prepend",
19
- content: () => [h("span", "#")],
20
- properties: {
21
- ariaHidden: true,
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
- shikiConfig: { theme: "css-variables" }
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 markdownConfig from "../markdownConfig.js"
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"
@@ -152,7 +152,11 @@ export default class {
152
152
  encoding: "utf8"
153
153
  })
154
154
 
155
- const markdownProcessor = await createMarkdownProcessor(markdownConfig)
155
+ const markdownProcessor = await createMarkdownProcessor({
156
+ remarkPlugins,
157
+ rehypePlugins: rehypePlugins(this),
158
+ shikiConfig
159
+ })
156
160
  const renderedMarkdown = await markdownProcessor.render(markdownContent)
157
161
 
158
162
  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
- node.properties.href = context.fileRouteMap?.[filePath.substring(1)] + linkTargetUrl.hash
14
- } else {
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
  }