Loading sub-directory content as categories
See original GitHub issueHi, I’m trying to write help articles based on a series of folders and content files within them, for example:
content/
├─ help/
│ ├─ account/
│ │ ├─ introduction.md
│ │ ├─ all-about-accounts.md
│ ├─ domains/
│ │ ├─ introduction.md
│ │ ├─ all-about-domains.md
│ ├─ monitors/
│ │ ├─ introduction.md
│ │ ├─ all-about-monitors.md
My sub-folders are my categories, and each introduction.md
file is it’s meta details which can then be displayed on some blog page showing all the categories. All the other files in those folders are the individual posts.
I want my URLs for instance to be: /help/account/all-about-introduction
but I’m having trouble displaying and obtaining the content for each of those using the fetch()
method.
I’ve got a page and folder set up like this:
pages/
├─ help/
│ ├─ index.vue
│ ├─ _slug/
│ │ ├─ _slug.vue
And my async function to try and get data from my category folders within /_slug/_slug.vue
is:
async asyncData ({ $content, params }) {
const guide = await $content('help/account', params.slug)
.fetch()
return {
guide
}
}
How can I achieve this?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Loading files from multiple subfolders with in same folder
Hi With in working directory I have a main folder folder called 'monthyr', with in main folder I have sub folders for each...
Read more >Jekyll: View all Folders & Subfolders as Category and Sub ...
I am lookin for a way to display: comic->subcomics->episode->.jpg files . Currently the theme supports only viewing of episode->.jpg files .
Read more >Selecting and loading files from multiple subfolders using ...
I would like to select the Donor folder using uigetdir, then it goes through ROI1, separates Channel 2 from Channel 3, then add...
Read more >Can't load lists or singles in a sub directory - HUGO
I have 'content/media/blogs' and inside those I have an _index.md. Then I created a layout with and singles / list html in both...
Read more >Subdomain or Subdirectory? What They Are & How They ...
Subdirectory. A subdomain compartmentalizes your website so you can establish specific content types that are distinct from your root domain. On ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sts-ryan-holton
If I understand what you mean correctly, you want to show like this, don’t you?
If so, taking a look at how Theme Docs renders its left sidebar will be helpful.
First, Theme Docs fetches all the pages and group them by
category
property defined in the front matter (code). Second, Theme Docs iterates the object, where key iscategory
and value is an array of documents, with nestedv-for
(code).Here is a simplified demo (CodeSandbox).
Note that Theme Docs guarantees the order of categories and pages by defining
position
in each document and setting asortBy()
query when fetching.By the way, you might want to refer to Fetching content page of the official site, so that you will come up with a variety of ways of fetching as you want.
@NozomuIkuta I’ve implemented a strategy into my website to achieve the above as per your suggestions and it seems to work! You can check out the Help section of my website if you’re interested 😃 https://domain-monitor.io/