Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
add navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Jelle Schutter committed Aug 1, 2020
1 parent b6154d2 commit dec3dc7
Show file tree
Hide file tree
Showing 5 changed files with 143 additions and 205 deletions.
136 changes: 64 additions & 72 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 38 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,45 @@
<template>
<div id="app">
<div id="nav">
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
<NavItem
v-for="item in nav"
v-bind:key="item.id"
:name="item.name"
:link="item.link"
></NavItem>
</div>
<router-view />
</div>
</template>

<script>
import { ref } from "vue";
import axios from "axios";
import NavItem from "./components/NavItem";
const nav = ref([]);
export default {
setup() {
return {
nav
};
},
mounted() {
const path = this.$root.$route.fullPath.substr(1);
axios
.get(
`http://redaxo.localhost/?rex-api-call=headless_nav&path=${path}&levels=1`
)
.then(response => (nav.value = response.data));
},
components: {
NavItem
}
};
</script>

<style>
#app {
font-family: Avenir, Helvetica, Arial, sans-serif;
Expand All @@ -26,6 +58,10 @@
color: #2c3e50;
}
#nav a:not(:last-child) {
margin-right: 10px;
}
#nav a.router-link-exact-active {
color: #42b983;
}
Expand Down
122 changes: 0 additions & 122 deletions src/components/HelloWorld.vue

This file was deleted.

29 changes: 29 additions & 0 deletions src/components/NavItem.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<template>
<router-link :to="link">{{ name }}</router-link>
</template>

<script>
export default {
props: {
name: {
type: String,
required: true,
default: ""
},
link: {
type: String,
required: true,
default: ""
},
active: {
type: Boolean,
required: true,
default: false
},
children: {
required: true,
default: []
}
}
};
</script>
Loading

0 comments on commit dec3dc7

Please sign in to comment.