1.4.0 • Published 2 years ago

vue-contentful-hook v1.4.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Vue Contentful Hook

A hook to call the contentful API using GraphQl

Usage

Ideally you should pass env variables as token and spaceId

export interface Dummy<T, U> {
  readonly dummyCollection: {
    readonly total: number;
    readonly skip: number;
    readonly limit: number;
    readonly items: readonly T[];
  };

  readonly someOtherDummyCollection: {
    readonly total: number;
    readonly skip: number;
    readonly limit: number;
    readonly items: readonly U[];
  };
}

const query = `
  {
    dummyCollection {
      items {
        name
      }
    }
    someOtherDummyCollection {
      items {
        name
      }
    }
  }
`;
const { data } = useContentful<Dummy<string, number>>(query, {
  token: "myToken",
  spaceId: "mySpaceId",
});

// an array of strings
console.log("data", data.value?.dummyCollection.items);
// an array of numbers
console.log("data", data.value?.dummyCollection.items);

This project follows the all-contributors specification. Contributions of any kind welcome!

1.4.0

2 years ago

1.3.4

2 years ago

1.3.3

2 years ago

1.3.2

2 years ago

1.2.0

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.1.0

2 years ago