Skip to content

Commit

Permalink
Merge pull request #997 from dandi/785-history-mode
Browse files Browse the repository at this point in the history
Use history mode instead of hash mode (remove hash from GUI URL)
  • Loading branch information
jjnesbitt authored Apr 8, 2022
2 parents 3b2f0bb + 4876516 commit b47f730
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions web/netlify.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,8 @@ command = "yarn run build"
VUE_APP_DANDI_API_ROOT = "https://api-staging.dandiarchive.org/api/"
VUE_APP_SENTRY_DSN = "https://425b9a012300493d867e97785fae7b88@o308436.ingest.sentry.io/5196549"
VUE_APP_SENTRY_ENVIRONMENT = "staging"

[[redirects]]
from = "/*"
to = "/index.html"
status = 200
2 changes: 1 addition & 1 deletion web/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ const routes: RouteConfig[] = [
},
];

export default new Router({ routes });
export default new Router({ mode: 'history', routes });
21 changes: 20 additions & 1 deletion web/src/views/HomeView/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,30 @@
<script lang="ts">
import StatsBar from '@/views/HomeView/StatsBar.vue';
import DandisetSearchField from '@/components/DandisetSearchField.vue';
import { defineComponent } from '@vue/composition-api';
import { computed, defineComponent, watchEffect } from '@vue/composition-api';
export default defineComponent({
name: 'HomeView',
components: { StatsBar, DandisetSearchField },
setup(props, ctx) {
/**
* Redirect old hash URLS to the correct one. This is only done on
* the home page, since any URL with a hash will default to here.
*/
const currentRoute = computed(() => ctx.root.$route);
watchEffect(() => {
const router = ctx.root.$router;
if (currentRoute.value.hash) {
const trimmed = router.currentRoute.hash.replace('#', '');
router.replace(trimmed);
}
});
return {
// Hack to satisfy template type checker
$vuetify: (ctx.root as any).$vuetify,
};
},
});
</script>

Expand Down
2 changes: 1 addition & 1 deletion web/src/views/HomeView/StatsBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default defineComponent({
name: 'dandisets',
value: dandisets.value,
description: 'A DANDI dataset including files and dataset-level metadata',
href: '/#/dandiset',
href: '/dandiset',
},
{ name: 'users', value: users.value },
{ name: 'total data size', value: filesize(size.value, { round: 0, base: 10, standard: 'iec' }) },
Expand Down

0 comments on commit b47f730

Please sign in to comment.