-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d41fbff
commit d4c294c
Showing
11 changed files
with
7,645 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"extends": [ | ||
"eslint:recommended" | ||
], | ||
"rules": { | ||
"indent": ["warn", "tab"], | ||
"no-else-return": ["warn"], | ||
"guard-for-in": ["warn"], | ||
"eqeqeq": ["warn"], | ||
"no-self-compare": ["warn"], | ||
"no-duplicate-imports": ["warn"], | ||
"no-lonely-if": ["warn"], | ||
"quotes": ["warn", "single"], | ||
"semi": ["warn", "always"] | ||
}, | ||
"env": { | ||
"es6": true, | ||
"node": true | ||
}, | ||
"parserOptions": { | ||
"sourceType": "module", | ||
"ecmaVersion": "latest" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Migration from collections.js to Filer | ||
|
||
## Initialising | ||
|
||
New | ||
``` | ||
import Filer from '@cloudcannon/filer'; | ||
const filer = new Filer({ path: 'content' }); | ||
``` | ||
|
||
## Getting slugs for Next.js | ||
|
||
Old | ||
``` | ||
getCollectionSlugs(); | ||
``` | ||
|
||
New | ||
``` | ||
filer.listItemSlugs('posts').map((slug) => ({ params: { slug } })); | ||
``` | ||
|
||
|
||
## Getting all parsed items in collection | ||
|
||
Old | ||
``` | ||
getCollection('posts'); | ||
getCollection('posts', { sortKey: 'date' }); | ||
``` | ||
|
||
New | ||
``` | ||
filer.getItems('posts'); | ||
filer.getItems('posts', { sortKey: 'date' }); | ||
``` | ||
|
||
|
||
## Getting one parsed item in collection | ||
|
||
Old | ||
``` | ||
// Assumes slug ends with .md | ||
getCollectionItem('posts', 'my-example-post'); | ||
getCollectionItem('posts', 'my-example-post', { excerpt: true }); | ||
``` | ||
|
||
New | ||
``` | ||
filer.getItem('my-example-post.md', { folder: 'posts' }); | ||
const item = filer.getItem('my-example-post.md', { | ||
folder: 'posts', | ||
excerpt: true | ||
}); | ||
const oldItem = { // The return result has changed - front matter now in data | ||
...item.data, | ||
slug: item.slug | ||
}; | ||
``` |
Oops, something went wrong.