@@ -55,7 +55,7 @@ $manager->addFile('Title of the file', '/path/to/documentation.md');
55
55
->display();
56
56
```
57
57
58
- ## Adding files
58
+ ## Adding single files
59
59
60
60
Single files can be added using ` addFile() ` . This allows specifying the
61
61
name that the file will be listed under in the UI.
@@ -69,6 +69,8 @@ $manager = new DocsManager();
69
69
$manager->addFile('Name of the file', '/path/to/file.md');
70
70
```
71
71
72
+ ## Adding folders
73
+
72
74
To add multiple files, use the ` addFolder() ` method:
73
75
74
76
``` php
@@ -95,6 +97,33 @@ $manager = new DocsManager();
95
97
$manager->addFolder('/path/to/files', false, 'txt');
96
98
```
97
99
100
+ > NOTE: Adding files this way means you cannot specify file IDs (see "Consistent
101
+ file permalinks"). Please double-check that this is okay in your use case.
102
+
103
+ ## Consistent file permalinks
104
+
105
+ By default, the viewer will create an ID for each file based on its absolute
106
+ path on disk. This means that the ID will change if the file is moved at some
107
+ point, or if the viewer is used on different systems. Sharing permalinks risks
108
+ the links being broken at some point.
109
+
110
+ To avoid this issue, specify a unique file ID manually when adding single files:
111
+
112
+ ``` php
113
+ use Mistralys\MarkdownViewer\DocsManager;
114
+
115
+ $manager = new DocsManager();
116
+
117
+ $manager->addFile(
118
+ 'Name of the file',
119
+ '/path/to/file.md',
120
+ '(Unique file ID)'
121
+ );
122
+ ```
123
+
124
+ The ID can be any string; the viewer uses it to create the hash that is used in the UI
125
+ to identify the files. This way, permalinks will always stay consistent.
126
+
98
127
## Dark mode
99
128
100
129
To turn on dark mode, simply use ` makeDarkMode() ` :
0 commit comments