@compiiile/compiiile 2.17.0 → 2.18.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.
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  import WorkspaceLayout from "../layouts/WorkspaceLayout.astro"
3
3
  import ContentWrapper from "../components/ContentWrapper.vue"
4
- import {routeList} from "virtual:compiiile"
4
+ import {routeList, site} from "virtual:compiiile"
5
5
  import SlidesLayout from "../layouts/SlidesLayout.astro"
6
6
  import path from "node:path"
7
7
 
@@ -31,7 +31,8 @@ export async function getStaticPaths() {
31
31
  uuid: route.name,
32
32
  title: route.meta.title,
33
33
  description: route.meta.description || "",
34
- textAlign: route.meta.textAlign
34
+ textAlign: route.meta.textAlign,
35
+ meta: route.meta
35
36
  }
36
37
  }
37
38
  })
@@ -39,11 +40,13 @@ export async function getStaticPaths() {
39
40
 
40
41
  let {path} = Astro.params;
41
42
 
42
- const {name, title, description, asSlides, textAlign} = Astro.props
43
+ const {name, title, description, asSlides, textAlign, meta} = Astro.props
44
+ site.pageFrontmatter = meta
43
45
 
44
- const {Content} = Astro.props.md
46
+ const {Content, getHeadings} = Astro.props.md
45
47
 
46
- const tableOfContent = Astro.props.md.getHeadings()
48
+
49
+ const tableOfContent = getHeadings()
47
50
  ---
48
51
 
49
52
  {asSlides ?
package/README.md CHANGED
@@ -99,11 +99,16 @@ To make yourself an idea and quickly get started using Compiiile, here are some
99
99
  terminal to get Compiiile running with a couple of markdown files as tests:
100
100
 
101
101
  ```bash
102
- mkdir test-compiiile && cd test-compiiile # creating a new folder and go into this folder
103
- yarn global add @compiiile/compiiile # installing compiiile as global dependency using yarn
104
- echo '# Test Compiiile\n\n> Here is a blockquote for you\n\n## Your markdown awaits below' > README.md # a first test file
105
- echo '---\nasSlides: true\n---\n\n# Slide 1\n\n---\n\n# And this is slide 2' > slides.md # a second test file as slides
106
- compiiile --title="📚 Compiiile" # running Compiiile for these 2 files
102
+ # creating a new folder and go into this folder
103
+ mkdir test-compiiile && cd test-compiiile
104
+ # installing compiiile as global dependency using npm
105
+ npm i -g @compiiile/compiiile
106
+ # a first test file
107
+ echo '# Test Compiiile\n\n> Here is a blockquote for you\n\n## Your markdown awaits below' > README.md
108
+ # a second test file as slides
109
+ echo '---\nasSlides: true\n---\n\n# Slide 1\n\n---\n\n# And this is slide 2' > slides.md
110
+ # running Compiiile for these 2 files
111
+ compiiile --title="📚 Compiiile"
107
112
  ```
108
113
 
109
114
  Et voilà, you should be able to preview your files in your browser :tada:.
@@ -196,23 +201,24 @@ The home page of Compiiile (`/`) points to a `README.md` file located at the roo
196
201
 
197
202
  Here is the list of parameters that you can set to customize Compiiile (none are required):
198
203
 
199
- | Parameter | Type | Description |
200
- | ---------------------- | ---------- | -------------------------------------------------------------------------------------------------------------------- |
201
- | `title` | `string` | The title to display on the top-left of the User Interface |
202
- | `description` | `string` | The description that is rendered by default for the SEO |
203
- | `logo` | `string` | The relative path of the logo to display in the TopBar and as favicon |
204
- | `logoUrl` | `string` | The url to go to when clicking on the logo, defaults to the home page if not set |
205
- | `dest` | `string` | The folder in which to build files, defaults to `./.compiiile/dist` |
206
- | `siteUrl` | `string` | The url of the website in production (without trailing slash), used for the SEO tag `og:image` |
207
- | `astroConfig` | `Object` | Override [default Astro config](https://docs.astro.build/en/reference/configuration-reference/) |
208
- | `data` | `Object` | An object with data to use in MDX files (check use case below) |
209
- | `theme` | `string` | The website theme, value can be : `auto` (default value: adapts to system preferences) \| `light` \| `dark` |
210
- | `useAutoTitles` | `Boolean` | If set to `true`, use the first file heading as title to be displayed in the navbar and for SEO. Defaults to `false` |
211
- | `noIndex` | `Boolean` | If set to `true`, the `robots.txt` file will disallow all routes, preventing indexation. Defaults to `false` |
212
- | `publicDir` | `string` | The folder name in which you can serve public files, defaults to `public` |
213
- | `vite.server.fs.allow` | `string[]` | Add local paths to vite's server fs allow list |
214
- | `printReady` | `Boolean` | Add a `/print` page to display a full ready-to-print content (uses `@compiiile/compiiile-print`) |
215
- | `css` | `string` | A relative path to a custom CSS file to customize the style <br/>:warning: Requires `compiiile-pro` |
204
+ | Parameter | Type | Description |
205
+ |------------------------| ---------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
206
+ | `title` | `string` | The title to display on the top-left of the User Interface |
207
+ | `description` | `string` | The description that is rendered by default for the SEO |
208
+ | `logo` | `string` | The relative path of the logo to display in the TopBar and as favicon |
209
+ | `logoUrl` | `string` | The url to go to when clicking on the logo, defaults to the home page if not set |
210
+ | `dest` | `string` | The folder in which to build files, defaults to `./.compiiile/dist` |
211
+ | `siteUrl` | `string` | The url of the website in production (without trailing slash), used for the SEO tag `og:image` |
212
+ | `astroConfig` | `Object` | Override [default Astro config](https://docs.astro.build/en/reference/configuration-reference/) |
213
+ | `data` | `Object` | An object with data to use in MDX files (check use case below) |
214
+ | `theme` | `string` | The website theme, value can be : `auto` (default value: adapts to system preferences) \| `light` \| `dark` |
215
+ | `useAutoTitles` | `Boolean` | If set to `true`, use the first file heading as title to be displayed in the navbar and for SEO. Defaults to `false` |
216
+ | `noIndex` | `Boolean` | If set to `true`, the `robots.txt` file will disallow all routes, preventing indexation. Defaults to `false` |
217
+ | `publicDir` | `string` | The folder name in which you can serve public files, defaults to `public` |
218
+ | `vite.server.fs.allow` | `string[]` | Add local paths to vite's server fs allow list |
219
+ | `printReady` | `Boolean` | Add a `/print` page to display a full ready-to-print content (uses `@compiiile/compiiile-print`) |
220
+ | `css` | `string` | A relative path to a custom CSS file to customize the style <br/>:warning: Requires `compiiile-pro` |
221
+ | `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 |
216
222
 
217
223
  You can use these parameters in 2 ways:
218
224
 
@@ -311,11 +317,9 @@ import Test from "./Test.vue"
311
317
  <Test client:load />
312
318
  ```
313
319
 
314
- You should
315
- use [Astro's client directives](https://docs.astro.build/en/reference/directives-reference/#client-directives) to load
316
- your component's script.
320
+ You should use [Astro's client directives](https://docs.astro.build/en/reference/directives-reference/#client-directives) to load your component's script (`client:load` is not necessary on all your components).
317
321
 
318
- ### Use config data values
322
+ ### Using config data values
319
323
 
320
324
  To use config values, you can access it by importing the `site` variable in your MDX file and then access the `data`
321
325
  key:
@@ -326,6 +330,42 @@ import { site } from "virtual:compiiile"
326
330
  # {site.data.someProperty}
327
331
  ```
328
332
 
333
+ ### Using frontmatter variables
334
+
335
+ In your MDX files, all frontmatter variables are available via the `frontmatter` variable:
336
+
337
+ ```mdx
338
+ ---
339
+ description: some description
340
+ ---
341
+
342
+ { frontmatter.description }
343
+ ```
344
+
345
+ > :books: More info in the [dedicated Astro documentation](https://docs.astro.build/en/guides/integrations-guide/mdx/#using-frontmatter-variables-in-mdx).
346
+
347
+ In your custom components, you can access the current page's frontmatter by using the `pageFrontmatter` property from Compiiile's Vite plugin:
348
+
349
+ ```vue
350
+ <template>
351
+ <p>{{ frontmatter.description }}</p>
352
+ </template>
353
+
354
+ <script>
355
+ import { site } from "virtual:compiiile"
356
+
357
+ export default {
358
+ name: "CustomComponent",
359
+ computed: {
360
+ frontmatter(){
361
+ return site.pageFrontmatter
362
+ }
363
+ }
364
+ }
365
+ </script>
366
+ ```
367
+
368
+
329
369
  ## Ignoring files and folders
330
370
 
331
371
  To ignore a whole folder or some files matching a certain pattern, you can add a `.compiiileignore` at the root of the folder where you run Compiiile.
package/bin/loadConfig.js CHANGED
@@ -25,7 +25,7 @@ export const loadConfig = async () => {
25
25
  name: process.env.COMPIIILE_TEMP_CONFIG_NAME || "compiiile",
26
26
  cwd: process.env.COMPIIILE_TEMP_DIR || source
27
27
  })
28
- configFromFile = JSON.parse(JSON.stringify(compiiileConfig.config))
28
+ configFromFile = {...compiiileConfig.config}
29
29
  if (!process.env.COMPIIILE_CONFIG_FILE) {
30
30
  process.env.COMPIIILE_CONFIG_FILE = compiiileConfig.configFile
31
31
  }
@@ -1,4 +1,4 @@
1
- import emoji from "remark-emoji"
1
+ import remarkEmoji from "remark-emoji"
2
2
  import rehypeImagePlugin from "./rehypeImagePlugin.js"
3
3
  import rehypeLinkPlugin from "./rehypeLinkPlugin.js"
4
4
  import rehypeSlug from "rehype-slug"
@@ -7,7 +7,7 @@ import { h } from "hastscript"
7
7
  import rehypeHandleYamlMatterPlugin from "./rehypeHandleYamlMatterPlugin.js"
8
8
 
9
9
  export default {
10
- remarkPlugins: [emoji],
10
+ remarkPlugins: [remarkEmoji],
11
11
  rehypePlugins: [
12
12
  rehypeImagePlugin,
13
13
  rehypeLinkPlugin,
@@ -3,6 +3,9 @@ import { matter } from "vfile-matter"
3
3
  export default function rehypeHandleYamlMatterPlugin() {
4
4
  return function (_, file) {
5
5
  matter(file)
6
- file.data.astro.frontmatter = file.data.matter
6
+ file.data.astro.frontmatter = {
7
+ ...file.data.astro.frontmatter,
8
+ ...file.data.matter
9
+ }
7
10
  }
8
11
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@compiiile/compiiile",
3
3
  "private": false,
4
- "version": "2.17.0",
4
+ "version": "2.18.0",
5
5
  "description": "The most convenient way to render a folder containing markdown files. Previewing and searching markdown files has never been that easy.",
6
6
  "author": "AlbanCrepel <alban.crepel@gmail.com>",
7
7
  "license": "GPL-3.0-only",