Skip to content

Commit 5d3d9be

Browse files
fix(website): fix reading local storage on old version and default to components
1 parent 4b97af7 commit 5d3d9be

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

packages/overmind-website/backend/index.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,12 @@ app.get('/backend/search', (req, res) => {
136136
res.send(hits.slice(0, 5))
137137
})
138138

139-
let indexHtml = fs.readFileSync(path.join(__dirname, 'index.html')).toString()
139+
let indexHtml
140140

141141
if (IS_PRODUCTION) {
142+
indexHtml = fs
143+
.readFileSync(path.join(__dirname, '..', 'dist', 'index.html'))
144+
.toString()
142145
indexHtml = indexHtml.replace(
143146
'</body>',
144147
`
@@ -153,6 +156,8 @@ if (IS_PRODUCTION) {
153156
</body>
154157
`
155158
)
159+
} else {
160+
indexHtml = fs.readFileSync(path.join(__dirname, 'index.html')).toString()
156161
}
157162

158163
app.get('/*', (_, res) => res.send(indexHtml))

packages/overmind-website/src/app/effects.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@ export const request = (url: string) =>
1515
export const storage = {
1616
get(key: string) {
1717
const value = localStorage.getItem(key)
18-
return value ? JSON.parse(value) : null
18+
let returnValue = null
19+
try {
20+
returnValue = value ? JSON.parse(value) : null
21+
} catch (e) {}
22+
23+
return returnValue
1924
},
2025
set(key: string, value: any) {
2126
localStorage.setItem(key, JSON.stringify(value))

packages/overmind-website/src/app/onInitialize.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const onInitialize: OnInitialize = ({
88
css,
99
}) => {
1010
state.typescript = storage.get('typescript') || false
11-
state.theme = storage.get('theme') || 'react'
11+
state.theme = storage.get('theme') || 'components'
1212
css.changePrimary(state.theme)
1313

1414
router.route('/', app.actions.openHome)

0 commit comments

Comments
 (0)