@compiiile/compiiile 2.5.0 → 2.6.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.
package/README.md
CHANGED
|
@@ -156,7 +156,7 @@ Other frontmatter keys are handled:
|
|
|
156
156
|
|
|
157
157
|
### Routing
|
|
158
158
|
|
|
159
|
-
The home page of Compiiile (`/`) points to a `README.md` file located at the root of your folder.
|
|
159
|
+
The home page of Compiiile (`/`) points to a `README.md` file located at the root of your folder, or fallbacks to an `index.md` file.
|
|
160
160
|
|
|
161
161
|
## Custom configuration
|
|
162
162
|
|
|
@@ -32,14 +32,14 @@ export default class {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
generateRoutePathFromFilePath(filePath, hash = "", asSlides = false) {
|
|
35
|
+
generateRoutePathFromFilePath(filePath, hash = "", asSlides = false, entryFileMatcher) {
|
|
36
36
|
const filePathWithoutExtension = filePath.substring(0, filePath.lastIndexOf("."))
|
|
37
37
|
const sluggifiedPath = filePathWithoutExtension
|
|
38
38
|
.split("/")
|
|
39
39
|
.map((val) => slugify(val, { lower: true }))
|
|
40
40
|
.join("/")
|
|
41
41
|
|
|
42
|
-
if (sluggifiedPath
|
|
42
|
+
if (sluggifiedPath.match(entryFileMatcher)) {
|
|
43
43
|
if (process.env.VITE_COMPIIILE_BASE !== "/") {
|
|
44
44
|
return process.env.VITE_COMPIIILE_BASE
|
|
45
45
|
}
|
|
@@ -63,6 +63,8 @@ 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/
|
|
67
|
+
|
|
66
68
|
for (let file of files) {
|
|
67
69
|
if (
|
|
68
70
|
![
|
|
@@ -81,7 +83,8 @@ export default class {
|
|
|
81
83
|
const isDirectory = fs.statSync(filePath).isDirectory()
|
|
82
84
|
const uuid = uuidv4()
|
|
83
85
|
const fileName = path.parse(filePath).name
|
|
84
|
-
const isReadmeFile = !isDirectory
|
|
86
|
+
const isReadmeFile = !isDirectory
|
|
87
|
+
&& filePath.toLowerCase().match(new RegExp(/^/.source + entryFileMatcher.source + /\.mdx?$/.source))
|
|
85
88
|
|
|
86
89
|
let filesTreeItem = new FilesTreeItem(uuid, fileName)
|
|
87
90
|
|
|
@@ -121,7 +124,7 @@ export default class {
|
|
|
121
124
|
fileListItem.meta.title = fileListItem.meta.title || fileListItem.title
|
|
122
125
|
fileListItem.fullPath = filePath
|
|
123
126
|
|
|
124
|
-
const routePath = this.generateRoutePathFromFilePath(filePath, "", fileListItem.meta.asSlides)
|
|
127
|
+
const routePath = this.generateRoutePathFromFilePath(filePath, "", fileListItem.meta.asSlides, entryFileMatcher)
|
|
125
128
|
|
|
126
129
|
if (isReadmeFile) {
|
|
127
130
|
this.fileList.unshift(fileListItem)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@compiiile/compiiile",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.6.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",
|