Skip to content

Commit

Permalink
refactor: make removing index.html from URL configurable (#1428)
Browse files Browse the repository at this point in the history
* refactor: providing the configurability for whether to remove index.html from the URL #1427

* docs(configuration): added entry for noIndexHtmlremoval
  • Loading branch information
mfranzke authored Sep 21, 2022
1 parent 749a3e7 commit 7951a41
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions packages/docs/src/docs/advanced-config-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ This replaces the now obsolete `debug` flag.

**default**: `info`

## noIndexHtmlremoval (optional)

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.

To disable this redirect which is similar to how Single Page Applications work, you could set the optional configuration `"noIndexHtmlremoval"` to `true`.

**default**: `false`

## outputFileSuffixes

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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@ class IFrame extends BaseLitComponent {
: window.location.protocol +
'//' +
window.location.host +
window.location.pathname.replace('index.html', '') +
(window.config.noIndexHtmlremoval
? window.location.pathname
: window.location.pathname.replace('index.html', '')) +
'?p=' +
currentPattern;

Expand Down Expand Up @@ -512,7 +514,9 @@ class IFrame extends BaseLitComponent {
: window.location.protocol +
'//' +
window.location.host +
window.location.pathname.replace('index.html', '') +
(window.config.noIndexHtmlremoval
? window.location.pathname
: window.location.pathname.replace('index.html', '')) +
'?p=' +
currentPattern;

Expand Down

0 comments on commit 7951a41

Please sign in to comment.