@compiiile/compiiile 2.10.2 → 2.11.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.
@@ -0,0 +1,5 @@
1
+ {
2
+ "_variables": {
3
+ "lastUpdateCheck": 1718726455618
4
+ }
5
+ }
package/README.md CHANGED
@@ -207,6 +207,7 @@ Here is the list of parameters that you can set to customize Compiiile (none are
207
207
  | `theme` | `string` | The website theme, value can be : `auto` (default value: adapts to system preferences) \| `light` \| `dark` |
208
208
  | `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` |
209
209
  | `noIndex` | `Boolean` | If set to `true`, the `robots.txt` file will disallow all routes, preventing indexation. Defaults to `false` |
210
+ | `publicDir` | `string` | The folder name in which you can serve public files, defaults to `public` |
210
211
  | `vite.server.fs.allow` | `string[]` | Add local paths to vite's server fs allow list |
211
212
 
212
213
  You can use these parameters in 2 ways:
@@ -238,6 +239,17 @@ export default {
238
239
 
239
240
  > ⚠️ You should bear in mind that script arguments have priority over config file parameters.
240
241
 
242
+ ## Public files
243
+
244
+ If you want some files to be public, just create a folder named `public` at the root of your Compiiile folder.
245
+
246
+ For example, if you want to link to a local PDF in your Markdown file, you can put your PDF in your local public directory, in `public/my-pdf.pdf`.
247
+ Then, all you have to do is creating a link in Markdown with an absolute path like so :
248
+
249
+ ```markdown
250
+ [Check the PDF](/my-pdf.pdf)
251
+ ```
252
+
241
253
  ## Use MDX
242
254
 
243
255
  v2 of Compiiile allows you to use MDX files with Vue components.
package/bin/config.js CHANGED
@@ -4,7 +4,7 @@ import { passthroughImageService } from "astro/config"
4
4
  import compiiile from "./vitePluginCompiiile/index.js"
5
5
  import mdx from "@astrojs/mdx"
6
6
  import path from "node:path"
7
- import { copyFileSync, cpSync } from "node:fs"
7
+ import { copyFileSync, cpSync, existsSync } from "node:fs"
8
8
  import { fileURLToPath } from "node:url"
9
9
  import markdownConfig from "./vitePluginCompiiile/markdownConfig.js"
10
10
  import resolvePackagePath from "resolve-package-path"
@@ -88,6 +88,9 @@ const argv = yargs(hideBin(process.argv))
88
88
  describe:
89
89
  "If set to `true`, the `robots.txt` file will disallow all routes, preventing indexation. Defaults to `false`"
90
90
  })
91
+ .option("publicDir", {
92
+ describe: "The folder name in which you can serve public files, defaults to `public`"
93
+ })
91
94
  .option("vite.server.fs.allow", {
92
95
  describe: "Add local paths to vite's server fs allow list"
93
96
  })
@@ -112,9 +115,21 @@ process.env.VITE_COMPIIILE_LOGO = null
112
115
 
113
116
  const publicDir = path.resolve(source, "./.compiiile/public")
114
117
 
118
+ const localPublicDirName = argv.publicDir ?? "public"
119
+ const localPublicDir = path.resolve(source, localPublicDirName)
120
+ const localPublicDirExists = existsSync(localPublicDir)
121
+
122
+ const hasPublicFiles = localPublicDirExists || argv.logo
123
+ if (hasPublicFiles) {
124
+ cpSync(fileURLToPath(new URL("../.compiiile/public", import.meta.url)), publicDir, { recursive: true })
125
+ }
126
+
127
+ if (localPublicDirExists) {
128
+ cpSync(localPublicDir, publicDir, { recursive: true })
129
+ }
130
+
115
131
  if (argv.logo) {
116
132
  try {
117
- cpSync(fileURLToPath(new URL("../.compiiile/public", import.meta.url)), publicDir, { recursive: true })
118
133
  copyFileSync(path.resolve(source, argv.logo), path.resolve(publicDir, "favicon.png"))
119
134
  // Set the logo to be displayed on the top bar if we were able to copy
120
135
  process.env.VITE_COMPIIILE_LOGO = argv.logo
@@ -139,7 +154,10 @@ const resolve = (mod) => {
139
154
  const resolvedModule = requireg.resolve("vue")
140
155
  const packagePath = resolvePackagePath(mod, resolvedModule)
141
156
  // Check to work on both Windows (using `\`) and UNIX systems (using `/`)
142
- return packagePath.slice(0, packagePath.lastIndexOf("/") < 0 ? packagePath.lastIndexOf("\\") : packagePath.lastIndexOf("/"))
157
+ return packagePath.slice(
158
+ 0,
159
+ packagePath.lastIndexOf("/") < 0 ? packagePath.lastIndexOf("\\") : packagePath.lastIndexOf("/")
160
+ )
143
161
  }
144
162
 
145
163
  const astroConfig = {
@@ -150,7 +168,7 @@ const astroConfig = {
150
168
  root: fileURLToPath(new URL("../.compiiile", import.meta.url)),
151
169
  srcDir: fileURLToPath(new URL("../.compiiile/src", import.meta.url)),
152
170
  outDir: path.join(source, argv.dest || ".compiiile/dist"),
153
- ...(argv.logo ? { publicDir } : {}),
171
+ ...(hasPublicFiles ? { publicDir } : {}),
154
172
  integrations: [
155
173
  vue({ appEntrypoint: "/src/app.js" }),
156
174
  ...(configFromFile.integrations ?? []),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@compiiile/compiiile",
3
3
  "private": false,
4
- "version": "2.10.2",
4
+ "version": "2.11.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",