Add support for multiple sources
See original GitHub issueCurrently, Contentlayer looks for a single exported method that is pulled from one particular source. We’ve received requests to support more than one source within the same configuration. I’m working to get more information on specific use cases.
Considerations
What are the challenges with this approach?
Design
What would the API for this look like? Perhaps you could define sources separately and then reference the source at the document level? And include the option for a default source.
Napkin sketch:
const ctfl = makeSource({ type: 'contentful', accessToken: /* ... */ })
const local = makeSource({ type: 'local', path: /* ... */ })
const Page = defineDocumentType({ source: ctfl })
const Post = defineDocumentType({})
export default {
defaultSource: local,
documentTypes: [Page, Post]
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:7
- Comments:7
Top Results From Across the Web
Support for multiple Source Systems | Voters - HelloID - Canny
Allow adding multiple source systems. Import should only insert, update, delete identity from a single source system. Each source system has its own...
Read more >APA Citations (7th ed.): Citing Multiple Works - LibGuides
This guide will help you learn how to properly cite sources in APA style ... Only include citations needed to support your immediate...
Read more >How can I add multiple sources to an HTML5 audio tag ...
I failed to find how to add multiple sources in an audio element through JavaScript, something similar to source tags shown in the...
Read more >Create a multiple source automation - NationBuilder HOWTOs
Step 1: Start a multiple source automation · Step 2: Set up emails and time delays within automation · Step 3. Run your...
Read more >Consolidate multiple worksheets into one PivotTable
Consolidating data is a useful way to combine data from different sources into one report.
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
@684efs3 We’re not actively working on this feature at this time, though still considering it and looking for more use cases to determine how to shape the API.
In this case, “multiple sources” means that your collection of data is coming from multiple sources (local, headless CMS, API, etc.).
In your case, it sounds like all your data is local, but spread across multiple files. This is what Contentlayer is designed to solve today. You can create an individual document type for content in each directory. You can even process some content types as MDX and others as plain markdown.
Ah I see! Apologies! Your comment is very helpful. I’m looking forward to testing it! Thank you very much! 😃