@compiiile/compiiile 2.14.3 → 2.15.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.
@@ -14,6 +14,14 @@
14
14
  console.log(this.$context)
15
15
  console.groupEnd()
16
16
  }
17
+
18
+ const activeLink = document.querySelector(".nav-list-item .link-active")
19
+ const nav = document.querySelector("body > .page > nav")
20
+
21
+ const activeLinkTop = activeLink?.getBoundingClientRect()?.y
22
+ if (activeLink && nav && activeLinkTop > window.innerHeight) {
23
+ nav.scrollTop = activeLinkTop - window.innerHeight + nav.offsetTop
24
+ }
17
25
  },
18
26
  methods: {
19
27
  async onScroll() {
@@ -6,7 +6,7 @@ import SlidesLayout from "../layouts/SlidesLayout.astro"
6
6
  import path from "node:path"
7
7
 
8
8
  export async function getStaticPaths() {
9
- const markdownFiles = await Astro.glob('@source/**/*.{md,mdx}')
9
+ const markdownFiles = Object.values(import.meta.glob('@source/**/*.{md,mdx}', { eager: true }))
10
10
 
11
11
  return routeList.map(route => {
12
12
  const md = markdownFiles.find(post => {
@@ -22,6 +22,8 @@
22
22
  --table-even-lines-background-color: #232329;
23
23
  --pre-background-color: var(--darker-background-color);
24
24
  --pre-color: #d2d7e0;
25
+ --astro-code-background: var(--darker-background-color);
26
+ --astro-code-foreground: var(--pre-color);
25
27
  --highlight-color: #9985fe;
26
28
  --slides-controls: #eeaa6f;
27
29
  /* ----------------------- */
@@ -72,11 +72,11 @@ Strikethrough uses two tildes. ~~Scratch this.~~
72
72
  To have a line break without a paragraph, you will need to use two trailing spaces.
73
73
  Note that this line is separate, but within the same paragraph.
74
74
 
75
- - Unordered list can use asterisks
75
+ - Unordered list can use asterisks
76
76
 
77
- * Or minuses
77
+ * Or minuses
78
78
 
79
- - Or pluses
79
+ - Or pluses
80
80
  ```
81
81
 
82
82
  1. First ordered list item
@@ -91,11 +91,11 @@ Strikethrough uses two tildes. ~~Scratch this.~~
91
91
  To have a line break without a paragraph, you will need to use two trailing spaces.
92
92
  Note that this line is separate, but within the same paragraph.
93
93
 
94
- - Unordered list can use asterisks
94
+ - Unordered list can use asterisks
95
95
 
96
- * Or minuses
96
+ * Or minuses
97
97
 
98
- - Or pluses
98
+ - Or pluses
99
99
 
100
100
  ## Links
101
101
 
@@ -211,12 +211,12 @@ Quote break.
211
211
  ## Checkboxes
212
212
 
213
213
  ```md
214
- - [ ] a todo item
215
- - [x] I've done this one
214
+ - [ ] a todo item
215
+ - [x] I've done this one
216
216
  ```
217
217
 
218
- - [ ] a todo item
219
- - [x] I've done this one
218
+ - [ ] a todo item
219
+ - [x] I've done this one
220
220
 
221
221
  ## Inline HTML
222
222
 
@@ -10,9 +10,9 @@ asSlides: true
10
10
 
11
11
  ## It can contain some lists
12
12
 
13
- - My first list item
14
- - A second list item
15
- - [Some link](https://github.com/AlbanCrepel/compiiile)
13
+ - My first list item
14
+ - A second list item
15
+ - [Some link](https://github.com/AlbanCrepel/compiiile)
16
16
 
17
17
  ---
18
18
 
@@ -35,9 +35,9 @@ npm install @compiiile/compiiile-pro # install as a project dependency with npm
35
35
 
36
36
  Once installed, 3 commands are available that act the same as the usual `compiiile` command:
37
37
 
38
- - `compiiile-pro dev`
39
- - `compiiile-pro build`
40
- - `compiiile-pro preview`
38
+ - `compiiile-pro dev`
39
+ - `compiiile-pro build`
40
+ - `compiiile-pro preview`
41
41
 
42
42
  ## License
43
43
 
@@ -98,12 +98,12 @@ You can become an affiliate and earn 20% on each sale by referring new customers
98
98
 
99
99
  Here is a list of features that the pro version adds:
100
100
 
101
- - add a button to copy code blocks and be able to specify the code block file name
102
- - add admonitions (or alerts) with different semantic colors
103
- - use any [Phosphor Icon](https://phosphoricons.com/) in your Markdown files or Vue components
104
- - add [MermaidJs](https://mermaid.js.org/#/) integration to write diagrams in Markdown, without compromising on style
105
- - add [Markmap](https://markmap.js.org/) integration to write mindmaps in Markdown from bullet-points lists
106
- - add [d2](https://d2lang.com/) integration to write diagrams
107
- - use ready-to-use components (for slides layouts, etc) in `mdx` files
101
+ - add a button to copy code blocks and be able to specify the code block file name
102
+ - add admonitions (or alerts) with different semantic colors
103
+ - use any [Phosphor Icon](https://phosphoricons.com/) in your Markdown files or Vue components
104
+ - add [MermaidJs](https://mermaid.js.org/#/) integration to write diagrams in Markdown, without compromising on style
105
+ - add [Markmap](https://markmap.js.org/) integration to write mindmaps in Markdown from bullet-points lists
106
+ - add [d2](https://d2lang.com/) integration to write diagrams
107
+ - use ready-to-use components (for slides layouts, etc) in `mdx` files
108
108
 
109
109
  See an overview of these features in the next page.
@@ -538,18 +538,18 @@ The `CGrid` component allows you to use a grid layout (very useful for slides):
538
538
  </CGrid>
539
539
  ```
540
540
 
541
- - The `template` prop works just like the `grid-template-columns` CSS property, you can omit the `fr` unit, it will be processed automatically.
542
- - `template="1 1"` will make 2 columns of equal width
543
- - `template="2 1"` will make 2 columns with the first one using 2/3 width
544
- - You can vertically align items with the `align` prop, working like the `align-items` CSS property.
545
- - You can specify the gap between components with the `gap` prop (defaults to `40px`)
541
+ - The `template` prop works just like the `grid-template-columns` CSS property, you can omit the `fr` unit, it will be processed automatically.
542
+ - `template="1 1"` will make 2 columns of equal width
543
+ - `template="2 1"` will make 2 columns with the first one using 2/3 width
544
+ - You can vertically align items with the `align` prop, working like the `align-items` CSS property.
545
+ - You can specify the gap between components with the `gap` prop (defaults to `40px`)
546
546
 
547
547
  ### CCard
548
548
 
549
549
  The `CCard` component can be used as a traditional card or a link.
550
550
 
551
- - The `title` and `description` slots can be used for traditional cards
552
- - To get it to work as a link, just provide a Markdown link as default slot, and specify a hint text if needed with the `hintText` prop
551
+ - The `title` and `description` slots can be used for traditional cards
552
+ - To get it to work as a link, just provide a Markdown link as default slot, and specify a hint text if needed with the `hintText` prop
553
553
 
554
554
  <CGrid gap="20px" template="1 1">
555
555
  <CCard hintText="Go to the specific page">
package/CHANGELOG.md CHANGED
@@ -6,20 +6,20 @@ v2 now uses Astro under the hood !
6
6
 
7
7
  **:fire: New features**:
8
8
 
9
- - :tada: Added MDX support
10
- - :zap: Added Hot Reload support
9
+ - :tada: Added MDX support
10
+ - :zap: Added Hot Reload support
11
11
 
12
12
  **:wrench: Fix**:
13
13
 
14
- - No more Markdown markup on search results
14
+ - No more Markdown markup on search results
15
15
 
16
16
  **:warning: Breaking changes**:
17
17
 
18
- - Config file should now use ESM syntax:
19
- The file should use `export default {}` instead of `module.exports = {}`
20
- - No more route hash:
21
- What was before `https://compiiile.me/#/c/markdown-preview` is now `https://compiiile.me/c/markdown-preview`
22
- - No more dynamic section hash on page scroll
23
- - Images size use a new syntax:
24
- The new syntax must be in the image's `alt` attribute, preceded by a `pipe`: `![Alt text|100px](imageUrl)` (the value can be in `px` or `%` and represents the image's width).
25
- If no margin must be applied, a special attribute can be added like so: `![Alt text|100px;no-margin](imageUrl)`
18
+ - Config file should now use ESM syntax:
19
+ The file should use `export default {}` instead of `module.exports = {}`
20
+ - No more route hash:
21
+ What was before `https://compiiile.me/#/c/markdown-preview` is now `https://compiiile.me/c/markdown-preview`
22
+ - No more dynamic section hash on page scroll
23
+ - Images size use a new syntax:
24
+ The new syntax must be in the image's `alt` attribute, preceded by a `pipe`: `![Alt text|100px](imageUrl)` (the value can be in `px` or `%` and represents the image's width).
25
+ If no margin must be applied, a special attribute can be added like so: `![Alt text|100px;no-margin](imageUrl)`
package/CONTRIBUTING.md CHANGED
@@ -10,8 +10,8 @@ Whether, we will always aim to keep the code base and features simple.
10
10
 
11
11
  Here is the current roadmap and feature ideas for incoming releases:
12
12
 
13
- - [ ] being able to resize the navbar
14
- - [ ] tag files with frontmatter and search files having specific tags
13
+ - [ ] being able to resize the navbar
14
+ - [ ] tag files with frontmatter and search files having specific tags
15
15
 
16
16
  If a fix needs to be done or your contributing idea is part of this roadmap, it will most likely be taken into account.
17
17
 
@@ -21,8 +21,8 @@ People should also understand that I am not working full-time on this project an
21
21
 
22
22
  You can launch a local version of the project by cloning the repository, installing the dependencies (with `yarn install`, and use these 3 commands):
23
23
 
24
- - `yarn dev`
25
- - `yarn build`
26
- - `yarn preview`
24
+ - `yarn dev`
25
+ - `yarn build`
26
+ - `yarn preview`
27
27
 
28
28
  Your code should also comply with the project's code style by running `yarn lint` and `yarn format`.
package/README.md CHANGED
@@ -20,26 +20,26 @@ That's what Compiiile does. And it does it hassle-free !
20
20
 
21
21
  ## Features
22
22
 
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 themes)
25
- - [x] 🌱 Available everywhere with static files deployment: just host it somewhere and access it in any browser on your
26
- computer, phone or whatever you are using
27
- - [x] :link: Quick access to your files via the navbar and links to the previous and next file (with table of content
28
- generation)
29
- - [x] :tv: Display some files as slides
30
- - [x] :mag: **Full-text quick search with content preview**
31
- - [x] :zap: Hot-reload content preview as you edit it
32
- - [x] :tada: Supports MDX files: add your own components to your documentation
33
- - [x] :bulb: Can serve as knowledge base, and handles symlinks to reuse content
34
- - [x] :wrench: Customizable by env variables or config file, it's up to you
35
- - [x] :star2: You get it, it simply does the job, period.
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 themes)
25
+ - [x] 🌱 Available everywhere with static files deployment: just host it somewhere and access it in any browser on your
26
+ computer, phone or whatever you are using
27
+ - [x] :link: Quick access to your files via the navbar and links to the previous and next file (with table of content
28
+ generation)
29
+ - [x] :tv: Display some files as slides
30
+ - [x] :mag: **Full-text quick search with content preview**
31
+ - [x] :zap: Hot-reload content preview as you edit it
32
+ - [x] :tada: Supports MDX files: add your own components to your documentation
33
+ - [x] :bulb: Can serve as knowledge base, and handles symlinks to reuse content
34
+ - [x] :wrench: Customizable by env variables or config file, it's up to you
35
+ - [x] :star2: You get it, it simply does the job, period.
36
36
 
37
37
  ### What Compiiile isn't
38
38
 
39
- - It's not a markdown editor, there are already plenty available, just choose the one that works best for you, even the
40
- simplest text editor will do.
41
- - It's not like VuePress, VitePress, Docusaurus or Notion. Compiiile's goal is to stay simple and stupidly easy without
42
- any configuration.
39
+ - It's not a markdown editor, there are already plenty available, just choose the one that works best for you, even the
40
+ simplest text editor will do.
41
+ - It's not like VuePress, VitePress, Docusaurus or Notion. Compiiile's goal is to stay simple and stupidly easy without
42
+ any configuration.
43
43
 
44
44
  > The goal is to help people rely purely on a **language** (_markdown_), not on _any_ platform.
45
45
 
@@ -112,9 +112,9 @@ Et voilà, you should be able to preview your files in your browser :tada:.
112
112
 
113
113
  Once installed, 3 commands are available to see your beautiful markdown files :eyes::
114
114
 
115
- - `compiiile dev`: creates a web server to check your markdown files (alias to only `compiiile`)
116
- - `compiiile build`: builds all the files for you to serve them production-ready
117
- - `compiiile preview`: preview your production-ready build
115
+ - `compiiile dev`: creates a web server to check your markdown files (alias to only `compiiile`)
116
+ - `compiiile build`: builds all the files for you to serve them production-ready
117
+ - `compiiile preview`: preview your production-ready build
118
118
 
119
119
  You can run the command you want in your terminal while being in the desired folder.
120
120
 
@@ -178,13 +178,13 @@ like: `https://compiiile.me/s/slides-preview?print-pdf`.
178
178
 
179
179
  Other frontmatter keys are handled:
180
180
 
181
- - `title`: set the title to be displayed in the navbar and for SEO
182
- - `description`: set the description for SEO
183
- - `textAlign`: possible values
184
- are [CSS text-align values](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align) (`left`, `center`, ...). This
185
- changes the default text alignment in slides. The default value is `center`.
186
- - `ignore` : Boolean value (`true` or `false`) to ignore the current file and exclude it from Compiiile (the file is not ignored by default).
187
- - `hidden` : Boolean value (`true` or `false`) to hide the file from the navbar and siblings links (the file is not hidden by default).
181
+ - `title`: set the title to be displayed in the navbar and for SEO
182
+ - `description`: set the description for SEO
183
+ - `textAlign`: possible values
184
+ are [CSS text-align values](https://developer.mozilla.org/en-US/docs/Web/CSS/text-align) (`left`, `center`, ...). This
185
+ changes the default text alignment in slides. The default value is `center`.
186
+ - `ignore` : Boolean value (`true` or `false`) to ignore the current file and exclude it from Compiiile (the file is not ignored by default).
187
+ - `hidden` : Boolean value (`true` or `false`) to hide the file from the navbar and siblings links (the file is not hidden by default).
188
188
 
189
189
  > :bulb: You can override slides theme by passing it to a `theme` query parameter in your slide url (for example `/s/slides?theme=light`). See the `theme` config parameter below for valid values.
190
190
 
@@ -338,15 +338,15 @@ you can simply put these 2 lines in your `.compiiileignore`:
338
338
 
339
339
  ## Common issues
340
340
 
341
- - Make sure that the absolute path to the folder where you are running Compiiile doesn't contain any special character
342
- as it could prevent the project initialization.
341
+ - Make sure that the absolute path to the folder where you are running Compiiile doesn't contain any special character
342
+ as it could prevent the project initialization.
343
343
 
344
344
  ## Special thanks
345
345
 
346
- - [Astro](https://github.com/withastro/astro) for enabling us developers to make lightweight websites
347
- - [fzf-for-js](https://github.com/ajitid/fzf-for-js) for the search feature
348
- - [reveal.js](https://revealjs.com/) for displaying markdown files as slides
349
- - [Vite](https://vitejs.dev/) for helping modern frontend developers keep their mental health sane :heart:
346
+ - [Astro](https://github.com/withastro/astro) for enabling us developers to make lightweight websites
347
+ - [fzf-for-js](https://github.com/ajitid/fzf-for-js) for the search feature
348
+ - [reveal.js](https://revealjs.com/) for displaying markdown files as slides
349
+ - [Vite](https://vitejs.dev/) for helping modern frontend developers keep their mental health sane :heart:
350
350
 
351
351
  ## Contributing
352
352
 
@@ -359,12 +359,12 @@ You can read more about it and the roadmap in the [dedicated contributing guide]
359
359
 
360
360
  You can add features to Compiiile by using the following projects:
361
361
 
362
- - [compiiile-pro](https://compiiile.me/c/3-pro-installation): Enhance your Markdown files, add diagrams, mindmaps, admonitions, and ready-made components
363
- - [compiiile-print](https://github.com/compiiile/compiiile-print): Add a print ready page containing all your Markdown files
362
+ - [compiiile-pro](https://compiiile.me/c/3-pro-installation): Enhance your Markdown files, add diagrams, mindmaps, admonitions, and ready-made components
363
+ - [compiiile-print](https://github.com/compiiile/compiiile-print): Add a print ready page containing all your Markdown files
364
364
 
365
365
  Here is a list of projects related to Compiiile developed by the community:
366
366
 
367
- - [compiiile-actions-cloudflare-pages](https://github.com/marketplace/actions/compiiile-cloudflare-pages): A simple GitHub action to deploy a Compiiile site to CloudFlare pages
367
+ - [compiiile-actions-cloudflare-pages](https://github.com/marketplace/actions/compiiile-cloudflare-pages): A simple GitHub action to deploy a Compiiile site to CloudFlare pages
368
368
 
369
369
  ## Support
370
370
 
package/bin/config.js CHANGED
@@ -7,17 +7,19 @@ import path from "node:path"
7
7
  import { copyFileSync, cpSync, existsSync } from "node:fs"
8
8
  import { fileURLToPath } from "node:url"
9
9
  import markdownConfig from "./vitePluginCompiiile/markdownConfig.js"
10
- import resolvePackagePath from "resolve-package-path"
11
- import requireg from "requireg"
12
10
  import sitemap from "@astrojs/sitemap"
13
11
  import { loadConfig } from "c12"
14
- const source = process.cwd()
15
- process.env.COMPIIILE_SOURCE = source
16
-
17
12
  import yargs from "yargs/yargs"
18
13
  import { hideBin } from "yargs/helpers"
19
14
 
20
- import { readFile } from "fs/promises"
15
+ import { readFile } from "node:fs/promises"
16
+ // Making sure fonts are accessible by vite's server
17
+ import { createRequire } from "node:module"
18
+ import { packageDirectory } from "pkg-dir"
19
+
20
+ const source = process.cwd()
21
+ process.env.COMPIIILE_SOURCE = source
22
+
21
23
  const packageJSON = JSON.parse(await readFile(fileURLToPath(new URL("../package.json", import.meta.url))))
22
24
 
23
25
  /*
@@ -150,27 +152,15 @@ if (argv.logo) {
150
152
  }
151
153
  }
152
154
 
153
- // Making sure fonts are accessible by vite's server
154
- import { createRequire } from "node:module"
155
155
  const require = createRequire(import.meta.url)
156
156
  const pathName = require.resolve("@fontsource-variable/archivo")
157
- import { packageDirectory } from "pkg-dir"
157
+
158
158
  const viteServerFsAllowList = [source, fileURLToPath(new URL("../", import.meta.url)), path.resolve(pathName, "../../")]
159
159
  const packageDir = await packageDirectory()
160
160
  if (packageDir) {
161
161
  viteServerFsAllowList.push(packageDir)
162
162
  }
163
163
 
164
- const resolve = (mod) => {
165
- const resolvedModule = requireg.resolve("vue")
166
- const packagePath = resolvePackagePath(mod, resolvedModule)
167
- // Check to work on both Windows (using `\`) and UNIX systems (using `/`)
168
- return packagePath.slice(
169
- 0,
170
- packagePath.lastIndexOf("/") < 0 ? packagePath.lastIndexOf("\\") : packagePath.lastIndexOf("/")
171
- )
172
- }
173
-
174
164
  const astroConfig = {
175
165
  server: {
176
166
  host: argv.host,
@@ -184,7 +174,36 @@ const astroConfig = {
184
174
  vue({ appEntrypoint: "/src/app.js" }),
185
175
  ...(configFromFile.integrations ?? []),
186
176
  mdx(),
187
- ...(process.env.VITE_COMPIIILE_SITE_URL ? [sitemap()] : [])
177
+ ...(process.env.VITE_COMPIIILE_SITE_URL ? [sitemap()] : []),
178
+ {
179
+ name: "include-dependencies",
180
+ hooks: {
181
+ "astro:build:setup": ({ vite }) => {
182
+ vite.ssr.noExternal.push(
183
+ "kleur",
184
+ "clsx",
185
+ "vue",
186
+ "@vue/compiler-dom",
187
+ "@vue/compiler-core",
188
+ "@vue/shared",
189
+ "@babel/parser",
190
+ "estree-walker",
191
+ "source-map-js",
192
+ "@vue/runtime-dom",
193
+ "@vue/runtime-core",
194
+ "@vue/reactivity",
195
+ "@vue/server-renderer",
196
+ "@vue/compiler-ssr",
197
+ "html-escaper",
198
+ "@oslojs/encoding",
199
+ "cssesc",
200
+ "fzf",
201
+ "@astrojs/internal-helpers",
202
+ "mrmime"
203
+ )
204
+ }
205
+ }
206
+ }
188
207
  ],
189
208
  ...(process.env.VITE_COMPIIILE_SITE_URL ? { site: process.env.VITE_COMPIIILE_SITE_URL } : {}),
190
209
  vite: {
@@ -192,22 +211,7 @@ const astroConfig = {
192
211
  resolve: {
193
212
  preserveSymlinks: true,
194
213
  alias: {
195
- "@source": source,
196
- // Adding aliases for Compiiile's build command to work when installed globally
197
- vue: resolve("vue"),
198
- "@vue/server-renderer": resolve("@vue/server-renderer"),
199
- "@vue/runtime-dom": resolve("@vue/runtime-dom"),
200
- "@vue/runtime-core": resolve("@vue/runtime-core"),
201
- kleur: resolve("kleur"),
202
- clsx: resolve("clsx"),
203
- "html-escaper": resolve("html-escaper"),
204
- ...(process.env.NODE_ENV === NODE_ENV_PRODUCTION ? { cssesc: resolve("cssesc") } : {}), // Not included in dev because of the 'module is not defined' error otherwise
205
- mrmime: resolve("mrmime"),
206
- "@vue/reactivity": resolve("@vue/reactivity"),
207
- "@vue/shared": resolve("@vue/shared"),
208
- fzf: resolve("fzf"),
209
- "@oslojs/encoding": resolve("@oslojs/encoding"),
210
- "@astrojs/internal-helpers": resolve("@astrojs/internal-helpers") + "/dist"
214
+ "@source": source
211
215
  }
212
216
  },
213
217
  server: {
@@ -99,7 +99,7 @@ export default class {
99
99
  if (isFilePathInIgnoredPatterns) {
100
100
  continue
101
101
  }
102
- } catch (e) {
102
+ } catch (_) {
103
103
  // No .compiiileignore file found at the root
104
104
  }
105
105
 
package/build.js CHANGED
@@ -1,16 +1,16 @@
1
1
  import { build } from "vite"
2
2
  import { unlinkSync } from "node:fs"
3
3
 
4
- const jsFileName = "style.es.js"
4
+ const fileName = "style"
5
5
  await build({
6
6
  build: {
7
7
  lib: {
8
8
  entry: new URL("./.compiiile/src/utils/styles.js", import.meta.url).pathname,
9
9
  name: "style",
10
10
  formats: ["es"],
11
- fileName: (_) => jsFileName
11
+ fileName
12
12
  }
13
13
  }
14
14
  })
15
15
 
16
- await unlinkSync(`./dist/${jsFileName}`)
16
+ await unlinkSync(`./dist/${fileName}.js`)