@compiiile/compiiile 2.7.4 → 2.8.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,14 @@
1
+ const robotsTxt = `
2
+ User-agent: *
3
+ ${JSON.parse(process.env.VITE_COMPIIILE_NO_INDEX) ? "Disallow: /" : "Allow: /"}
4
+
5
+ ${import.meta.env.SITE ? `Sitemap: ${new URL("sitemap-index.xml", import.meta.env.SITE).href}` : ""}
6
+ `.trim()
7
+
8
+ export const GET = () => {
9
+ return new Response(robotsTxt, {
10
+ headers: {
11
+ "Content-Type": "text/plain; charset=utf-8"
12
+ }
13
+ })
14
+ }
package/README.md CHANGED
@@ -186,6 +186,7 @@ Here is the list of parameters that you can set to customize Compiiile (none are
186
186
  | `data` | `Object` | An object with data to use in MDX files (check use case below) |
187
187
  | `theme` | `string` | The website theme, value can be : `auto` (default value: adapts to system preferences) \| `light` \| `dark` |
188
188
  | `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` |
189
+ | `noIndex` | `Boolean` | If set to `true`, the `robots.txt` file will disallow all routes, preventing indexation. Defaults to `false` |
189
190
  | `vite.server.fs.allow` | `string[]` | Add local paths to vite's server fs allow list |
190
191
 
191
192
  You can use these parameters in 2 ways:
package/bin/config.js CHANGED
@@ -8,6 +8,7 @@ import { copyFileSync, cpSync } from "node:fs"
8
8
  import markdownConfig from "./vitePluginCompiiile/markdownConfig.js"
9
9
  import resolvePackagePath from "resolve-package-path"
10
10
  import requireg from "requireg"
11
+ import sitemap from "@astrojs/sitemap"
11
12
 
12
13
  const source = process.cwd()
13
14
  process.env.COMPIIILE_SOURCE = source
@@ -46,6 +47,7 @@ const argv = yargs(hideBin(process.argv))
46
47
  .version(packageJSON.version).argv
47
48
 
48
49
  process.env.VITE_COMPIIILE_SITE_URL = argv.siteUrl ?? ""
50
+ process.env.VITE_COMPIIILE_NO_INDEX = /true/i.test(argv.noIndex) // defaults to `false` if not set or not equal to `true`
49
51
 
50
52
  process.env.VITE_COMPIIILE_TITLE = argv.title ?? ""
51
53
  process.env.VITE_COMPIIILE_DESCRIPTION = argv.description ?? ""
@@ -87,7 +89,7 @@ if (packageDir) {
87
89
 
88
90
  const resolve = (mod) => {
89
91
  const resolvedModule = requireg.resolve("vue")
90
- const packagePath = resolvePackagePath(mod,resolvedModule)
92
+ const packagePath = resolvePackagePath(mod, resolvedModule)
91
93
  return packagePath.slice(0, packagePath.lastIndexOf("/"))
92
94
  }
93
95
 
@@ -96,7 +98,13 @@ const astroConfig = {
96
98
  srcDir: new URL("../.compiiile/src", import.meta.url).pathname,
97
99
  outDir: path.join(source, argv.dest || ".compiiile/dist"),
98
100
  ...(argv.logo ? { publicDir } : {}),
99
- integrations: [vue({ appEntrypoint: "/src/app.js" }), ...(configFromFile.integrations ?? []), mdx()],
101
+ integrations: [
102
+ vue({ appEntrypoint: "/src/app.js" }),
103
+ ...(configFromFile.integrations ?? []),
104
+ mdx(),
105
+ ...(process.env.VITE_COMPIIILE_SITE_URL ? [sitemap()] : [])
106
+ ],
107
+ ...(process.env.VITE_COMPIIILE_SITE_URL ? { site: process.env.VITE_COMPIIILE_SITE_URL } : {}),
100
108
  vite: {
101
109
  plugins: [compiiile()],
102
110
  resolve: {
@@ -63,7 +63,7 @@ export default class {
63
63
 
64
64
  const files = fs.readdirSync(directoryPath).sort(collator.compare)
65
65
 
66
- const entryFileMatcher = files.find((file) => file.toLowerCase() === "readme.md") ? /readme/ : /index/
66
+ const entryFileMatcher = files.find((file) => file.toLowerCase().match(/^readme.mdx?$/)) ? /readme/ : /index/
67
67
 
68
68
  for (let file of files) {
69
69
  if (
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@compiiile/compiiile",
3
3
  "private": false,
4
- "version": "2.7.4",
4
+ "version": "2.8.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",
@@ -22,6 +22,7 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@astrojs/mdx": "^2.1.1",
25
+ "@astrojs/sitemap": "^3.1.1",
25
26
  "@astrojs/vue": "^4.0.8",
26
27
  "@babel/core": "^7.0.0-0",
27
28
  "@babel/eslint-parser": "^7.22.15",