Skip to content

Commit

Permalink
feat: support link jump and sync docs theme (#265)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea committed May 1, 2024
1 parent 1e9b701 commit c242bb0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ const previewOptions = {
const initialUserOptions: UserOptions = {}
const dark = useDark()
const theme = new URLSearchParams(location.search).get('theme')
if (theme === 'dark') {
dark.value = true
}
const pr = new URLSearchParams(location.search).get('pr')
if (pr) {
initialUserOptions.showHidden = true
Expand All @@ -48,6 +55,9 @@ if (pr) {
},
}
store.state.files[IMPORT_MAP].code = JSON.stringify(map, undefined, 2)
}
if (pr || dark.value) {
const url = `${location.origin}${location.pathname}#${store.serialize()}`
history.replaceState({}, '', url)
}
Expand All @@ -72,8 +82,6 @@ const handleKeydown = (evt: KeyboardEvent) => {
}
}
const dark = useDark()
// persist state
watchEffect(() => history.replaceState({}, '', `#${store.serialize()}`))
Expand Down

0 comments on commit c242bb0

Please sign in to comment.