Skip to content

Commit 7951a41

Browse files
authored
refactor: make removing index.html from URL configurable (#1428)
* refactor: providing the configurability for whether to remove index.html from the URL #1427 * docs(configuration): added entry for noIndexHtmlremoval
1 parent 749a3e7 commit 7951a41

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

packages/docs/src/docs/advanced-config-options.md

+8
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,14 @@ This replaces the now obsolete `debug` flag.
113113

114114
**default**: `info`
115115

116+
## noIndexHtmlremoval (optional)
117+
118+
You might host your pattern lab in an environment that doesn't acknowledge the default file to be `index.html` in case that none is provided – Gitlab Pages is an example for this, where you might publish your preview builds to during development. So in case that you get a URL like `<PATH>/index.html`, it will redirect to `<PATH>/?p=all`. You might not be able to share this resulting URL or even do a refresh of the page, as the server would respond with a 404 error.
119+
120+
To disable this redirect which is similar to how Single Page Applications work, you could set the optional configuration `"noIndexHtmlremoval"` to `true`.
121+
122+
**default**: `false`
123+
116124
## outputFileSuffixes
117125

118126
Sets the naming of output pattern files. Suffixes are defined for 'rendered', 'rawTemplate', and 'markupOnly' files. This configuration is needed for some PatternEngines that use the same input and output file extensions. Most users will not have to change this.

packages/uikit-workshop/src/scripts/lit-components/pl-viewport/pl-viewport.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ class IFrame extends BaseLitComponent {
152152
: window.location.protocol +
153153
'//' +
154154
window.location.host +
155-
window.location.pathname.replace('index.html', '') +
155+
(window.config.noIndexHtmlremoval
156+
? window.location.pathname
157+
: window.location.pathname.replace('index.html', '')) +
156158
'?p=' +
157159
currentPattern;
158160

@@ -512,7 +514,9 @@ class IFrame extends BaseLitComponent {
512514
: window.location.protocol +
513515
'//' +
514516
window.location.host +
515-
window.location.pathname.replace('index.html', '') +
517+
(window.config.noIndexHtmlremoval
518+
? window.location.pathname
519+
: window.location.pathname.replace('index.html', '')) +
516520
'?p=' +
517521
currentPattern;
518522

0 commit comments

Comments
 (0)