Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rphillips-cc committed Nov 21, 2022
1 parent d41fbff commit d4c294c
Show file tree
Hide file tree
Showing 11 changed files with 7,645 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .eslintrc.json
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"
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
60 changes: 60 additions & 0 deletions migration-guide.md
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
};
```
Loading

0 comments on commit d4c294c

Please sign in to comment.