Skip to content

Commit

Permalink
fix: bug in import constants
Browse files Browse the repository at this point in the history
  • Loading branch information
Maya Shavin committed Oct 27, 2020
1 parent d4a8185 commit 10e6711
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 20 deletions.
2 changes: 2 additions & 0 deletions packages/demo/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ node_modules
dist
.env
.env.*

.vercel
3 changes: 2 additions & 1 deletion packages/demo/gridsome.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ module.exports = {
apiSecret: process.env.API_SECRET,
resourceOptions: {
type: "upload",
prefix: 'examples'
prefix: 'examples',
max_results: 30
},
transformations: {
width: 300,
Expand Down
1 change: 0 additions & 1 deletion packages/demo/src/pages/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ query {
images: allCldMedia {
edges {
node {
public_id
format
url
}
Expand Down
10 changes: 4 additions & 6 deletions packages/gs-cld-source/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# `gs-cld-source`
# `@mayas/gridsome-source-cld`

> TODO: description
## Usage
## Installation

```
const gsCldSource = require('gs-cld-source');
// TODO: DEMONSTRATE API
```bash
yarn add @mayas/gridsome-source-cld
```
15 changes: 11 additions & 4 deletions packages/gs-cld-source/lib/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
const CloudinaryApi = require('@mayas/cld-api')
const CONSTANTS = require('@mayas/cld-api').CONSTANTS
const { DEFAULT_TRANS, RESOURCE_TYPES } = require('@mayas/cld-api').CONSTANTS

// TODO
/**
* 1. Export some functionalities for manual usage.
* 2. Documentation
* 3. Tests
*/

class CldImagesSource {
static defaultOptions () {
Expand All @@ -18,7 +25,7 @@ class CldImagesSource {
this._cld = $cloudinary
this._options = options.resourceOptions || {}
this._transformations = {
...CONSTANTS.DEFAULT_TRANS,
...DEFAULT_TRANS,
...(options.transformations || {})
}

Expand All @@ -34,8 +41,8 @@ class CldImagesSource {

try {
const { resources } = await this._cld.resources(this._options)
const resourceType = this._options.resourceType === CONSTANTS.VIDEO ? CONSTANTS.VIDEO : CONSTANTS.IMAGE
const resourceType = this._options.resourceType === RESOURCE_TYPES.VIDEO ? RESOURCE_TYPES.VIDEO : RESOURCE_TYPES.IMAGE

if (!resources || !resources.length) {
console.warn('\n ~Yikes! No nodes created because no Cloudinary resources found. Try a different query?');
return;
Expand Down
7 changes: 0 additions & 7 deletions packages/gs-cld-transformer/lib/gs-cld-transformer.js

This file was deleted.

23 changes: 23 additions & 0 deletions packages/gs-cld-transformer/lib/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"use strict";

//TODO
/**
* 1. Upload files to Cloudinary
* 2. Upload remote(?) to Cloudinary
* 3. Retrieve and create image node for uploaded assets
*/
class CldTransformer {
static mimeTypes() {
return []
}

parse(source) {

}

extendNodeType({ graphql }) {

}
}

module.exports = Transformer
2 changes: 1 addition & 1 deletion packages/gs-cld-transformer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Maya Shavin <maya@cloudinary.com>",
"homepage": "https://github.com/mayashavin/gridsome-plugin-cloudinary/tree/master/packages/gs-cld-transformer#readme",
"license": "MIT",
"main": "lib/gs-cld-transformer.js",
"main": "lib/index.js",
"directories": {
"lib": "lib",
"test": "__tests__"
Expand Down

0 comments on commit 10e6711

Please sign in to comment.