Skip to content

Commit

Permalink
feat(#150): add subnavigation
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Aug 28, 2021
1 parent 44223fa commit fdb24df
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
15 changes: 15 additions & 0 deletions docs/store/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export const actions = {
async nuxtServerInit ({ commit }, { $content }) {
try {
const index = await $content("guide").only(["title"]).fetch();
const children = index.map((o) => ({
component: "NuxtLink",
text: o.title,
props: { to: o.path },
}));
commit("addMenuChildren", { children, parent: "/guide" });
} catch (err) {
console.log(err)
}
}
}
5 changes: 5 additions & 0 deletions docs/store/mutations.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
export default {
addMenuChildren(state, { children, parent }) {
const index = state.menu.findIndex((o) => o.props.to === parent)
state.menu[index].children = children
},

// TODO: add ability to pin items
// TODO: add support for page titles
addRecent(state, link) {
Expand Down
4 changes: 4 additions & 0 deletions docs/store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ export default () => ({
component: "NuxtLink",
text: "Home",
props: { to: "/" },
children: [],
},
{
component: "NuxtLink",
text: "API",
props: { to: "/api" },
children: [],
},
{
component: "NuxtLink",
text: "Guide",
props: { to: "/guide" },
children: [],
},
{
component: "a",
Expand All @@ -23,6 +26,7 @@ export default () => ({
href: "https://github.com/druxt/druxt.js",
target: "_blank",
},
children: [],
}],

// Package list.
Expand Down

0 comments on commit fdb24df

Please sign in to comment.