Skip to content

Commit

Permalink
chore(#179): update module section structure
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher committed Sep 1, 2021
1 parent 504b7cd commit aa65c99
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 12 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
11 changes: 6 additions & 5 deletions docs/pages/modules/_.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@ export default {
name: "AppGuideDocument",
async asyncData({ $content, error, params, store, route }) {
const path = params.pathMatch || "README";
const path = params.pathMatch
? params.pathMatch.includes("/")
? params.pathMatch
: params.pathMatch + "/README"
: "README";
let response;
try {
response = await $content(
"modules/",
params.pathMatch || "README"
).fetch();
response = await $content("modules/", path).fetch();
} catch (e) {
return error({ message: "Document not found" });
}
Expand Down
2 changes: 1 addition & 1 deletion docs/pages/modules/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
/>

<div
v-for="module of modules"
v-for="module of $store.state.modules"
:key="module.title"
class="card mb-5 shadow-lg hover:shadow-2xl"
>
Expand Down
22 changes: 16 additions & 6 deletions docs/store/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,27 @@
export const actions = {
async nuxtServerInit({ commit }, { $content }) {
try {
// Add Druxt modules to Vuex store.
const modulesIndex = await $content("api/README").only("toc").fetch()
const modules = await Promise.all(modulesIndex.toc
.filter((o) => o.id !== 'druxt')
.map((o) =>
$content(`modules/${o.id.split("-")[1]}/README`)
.only(["description", "dir", "title"])
.fetch()
)
)
console.log(modules)
commit("setModules", modules);

// Add Modules menu children to the vuex store.
const moduleIndex = await $content("modules").sortBy("title").only(["path", "title"]).fetch();
const modules = moduleIndex
.filter((o) => !o.path.endsWith("/README"))
const moduleChildren = modules
.map((o) => ({
component: "NuxtLink",
text: o.title,
props: { to: o.path },
props: { to: o.dir },
}));
commit("addMenuChildren", { children: modules, parent: "/modules" });
commit("addMenuChildren", { children: moduleChildren, parent: "/modules" });

// Add Guide menu children to the vuex store.
const guideIndex = await $content("guide").only(["path", "title"]).fetch();
Expand All @@ -29,7 +40,6 @@ export const actions = {
props: { to: o.path.replace("/README", "") },
}));
commit("addMenuChildren", { children: apiChildren, parent: "/api" });

} catch (err) {
console.log(err)
}
Expand Down
10 changes: 10 additions & 0 deletions docs/store/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,15 @@ export default {

// Return only the last 5 items.
state.recent = recent.filter((o, index) => index < 5)
},

/**
* Set the Druxt modules list.
*
* @param {Object} state
* @param {Array} modules
*/
setModules(state, modules) {
state.modules = modules
}
}
3 changes: 3 additions & 0 deletions docs/store/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export default () => ({
children: [],
}],

// Druxt modules.
modules: [],

// Recently opened documents.
recent: [],
})

0 comments on commit aa65c99

Please sign in to comment.