-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15c4413
commit a783581
Showing
4 changed files
with
18 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
/* eslint-disable mdx/no-unused-expressions */ | ||
import { createHash } from 'crypto'; | ||
|
||
module.exports = function(content: string) { | ||
//@ts-ignore | ||
this.cacheable && this.cacheable(); | ||
//@ts-ignore | ||
const params = JSON.parse(this.query.slice(1)); | ||
content = content.replace(/__STORIES_HASH__/g, params.compilationHash); | ||
return content; | ||
const hash = createHash('md5') | ||
.update(new Date().getTime().toString()) | ||
.digest('hex'); | ||
|
||
return ` | ||
module.exports.hash = "${hash}"; | ||
${content} | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
import { StoryStore } from './types'; | ||
|
||
const injectedStories = '__STORIES_HASH__INJECTED_STORIES__'; | ||
|
||
type StringifyFunction = () => StoryStore | undefined; | ||
|
||
const storyStore: StringifyFunction = () => { | ||
const storyStore = () => { | ||
if (injectedStories) { | ||
const store = JSON.parse(injectedStories); | ||
return store; | ||
} | ||
return undefined; | ||
}; | ||
|
||
export default storyStore; | ||
export default storyStore(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters