Skip to content

Commit

Permalink
Fix routing
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Jan 4, 2021
1 parent c0b3b0d commit aee76d7
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 24 deletions.
14 changes: 7 additions & 7 deletions src/components/Nav.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<nav class="navbar navbar-expand-lg navbar-dark fixed-top">
<NavLink class="navbar-brand" href="/">rdmo-terms</NavLink>
<NavLink class="navbar-brand" href="">rdmo-terms</NavLink>

<button class="navbar-toggler" type="button"
data-toggle="collapse" data-target="#navbarContent"
Expand All @@ -11,22 +11,22 @@
<div class="collapse navbar-collapse" id="navbarContent">
<ul class="navbar-nav">
<li class="nav-item">
<NavLink class="nav-link" href="/questions">Questions</NavLink>
<NavLink class="nav-link" href="questions">Questions</NavLink>
</li>
<li class="nav-item">
<NavLink class="nav-link" href="/domain">Domain</NavLink>
<NavLink class="nav-link" href="domain">Domain</NavLink>
</li>
<li class="nav-item">
<NavLink class="nav-link" href="/options">Options</NavLink>
<NavLink class="nav-link" href="options">Options</NavLink>
</li>
<li class="nav-item">
<NavLink class="nav-link" href="/conditions">Conditions</NavLink>
<NavLink class="nav-link" href="conditions">Conditions</NavLink>
</li>
<li class="nav-item">
<NavLink class="nav-link" href="/tasks">Tasks</NavLink>
<NavLink class="nav-link" href="tasks">Tasks</NavLink>
</li>
<li class="nav-item">
<NavLink class="nav-link" href="/views">Views</NavLink>
<NavLink class="nav-link" href="views">Views</NavLink>
</li>
</ul>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/NavLink.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
methods: {
go (event) {
event.preventDefault()
this.$root.route = this.href
this.$root.pathname = this.href
window.history.pushState(
null,
routes[this.href],
Expand Down
12 changes: 9 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Home from './pages/Home'
import Main from './pages/Main'
import NotFound from './pages/NotFound'


Vue.mixin({
methods: {
capitalize (string) {
Expand All @@ -21,11 +20,18 @@ Vue.mixin({
new Vue({
el: '#app',
data: {
route: window.location.pathname
pathname: window.location.pathname
},
computed: {
route () {
if (Vue.config.devtools) {
return this.pathname.replace(/^(\/)/, '')
} else {
return this.pathname.replace(/^(\/terms\/)/, '')
}
},
ViewComponent () {
if (this.route == '/') {
if (this.route == '') {
return Home
} else if (Object.keys(routes).includes(this.route)) {
return Main
Expand Down
12 changes: 6 additions & 6 deletions src/pages/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</ul>
</div>
<div class="card-footer">
<NavLink href="/questions">Go to questions</NavLink>
<NavLink href="./questions">Go to questions</NavLink>
</div>
</div>

Expand All @@ -39,7 +39,7 @@
</ul>
</div>
<div class="card-footer">
<NavLink href="/domain">Go to domain</NavLink>
<NavLink href="./domain">Go to domain</NavLink>
</div>
</div>

Expand All @@ -55,7 +55,7 @@
</ul>
</div>
<div class="card-footer">
<NavLink href="/domain">Go to domain</NavLink>
<NavLink href="./domain">Go to domain</NavLink>
</div>
</div>

Expand All @@ -70,7 +70,7 @@
</ul>
</div>
<div class="card-footer">
<NavLink href="/questions">Go to conditions</NavLink>
<NavLink href="./questions">Go to conditions</NavLink>
</div>
</div>

Expand All @@ -85,7 +85,7 @@
</ul>
</div>
<div class="card-footer">
<NavLink href="/tasks">Go to tasks</NavLink>
<NavLink href="./tasks">Go to tasks</NavLink>
</div>
</div>

Expand All @@ -100,7 +100,7 @@
</ul>
</div>
<div class="card-footer">
<NavLink href="/views">Go to views</NavLink>
<NavLink href="./views">Go to views</NavLink>
</div>
</div>
</div>
Expand Down
14 changes: 7 additions & 7 deletions src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,42 @@ import views from './data/views.json'
import tasks from './data/tasks.json'

export default {
'/': {},
'/questions': {
'': {},
'questions': {
title: 'Questions',
keys: ['uri_prefix', 'comment',
'title_en', 'title_de', 'title_fr',
'text_en', 'text_de', 'text_fr'],
filterKeys: ['uri', 'comment'],
elements: questions
},
'/domain': {
'domain': {
title: 'Domain',
keys: ['uri_prefix', 'comment',
'parent'],
filterKeys: ['uri'],
elements: domain
},
'/options': {
'options': {
title: 'Options',
keys: ['uri_prefix', 'comment', 'text_en', 'text_de', 'text_fr'],
filterKeys: ['uri', 'comment', 'text_en', 'text_de', 'text_fr'],
elements: options
},
'/conditions': {
'conditions': {
title: 'Conditions',
keys: ['uri_prefix', 'comment'],
filterKeys: ['uri'],
elements: conditions
},
'/tasks': {
'tasks': {
title: 'Tasks',
keys: ['uri_prefix', 'comment',
'text_en', 'text_de', 'text_fr'],
filterKeys: ['uri'],
elements: tasks
},
'/views': {
'views': {
title: 'Views',
keys: ['uri_prefix', 'comment',
'title_en', 'title_de', 'title_fr'],
Expand Down
3 changes: 3 additions & 0 deletions vue.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ? '/terms/' : '/'
}

0 comments on commit aee76d7

Please sign in to comment.