Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@cmpsr/contentful-core
Advanced tools
Base Composer components for standing up a React/NextJS app that can dynamically render components based on Contentful Model types mapped to components and queries.
Base Composer components for standing up a React/NextJS app that can dynamically render components based on Contentful Model types mapped to components and queries.
Via npm:
npm i --save @cmpsr/contentful-core
Via Yarn:
yarn add @cmpsr/contentful-core
.env
variablesCONTENTFUL_PREVIEW={true|false}
CONTENTFUL_SPACE_ID={Contentful space ID}
CONTENTFUL_ENVIRONMENT={Contentful environment} (defaults to `master`)
CONTENTFUL_ACCESS_TOKEN_DELIVERY={Contentful Delivery Token}
CONTENTFUL_ACCESS_TOKEN_PREVIEW={Contentful Preview Token}
CONTENTFUL_ACCESS_TOKEN={Contentful token used to generate schema/types}
ContentfulProvider
ComponentRenderer
The utility scripts make it easy to generate GraphQL schemas and the associated Typescript definitions for your Contentful setup.
Required script environment variables
CONTENTFUL_SPACE_ID
- The Contentful Space ID.
CONTENTFUL_ACCESS_TOKEN
- The Contentful API access token. This could be the Delivery or Preview API access token, depending on your needs.
Within your project directory, run the following command to generate the fragmentTypes.json
based on your Contentful models.
node ./node_modules/@cmpsr/contentful-core/scripts/graphql-schema.js
Environment Variables
SCHEMA_DIR
- Directory to write the fragmentsTypes.json
to. Defaults to: ./src/schema
Within your project directory, run the following command to generate the fragmentTypes.json
based on your Contentful models.
node ./node_modules/@cmpsr/contentful-core/scripts/graphql-types.js
Environment Variables
TYPES_DIR
- Directory to write the types
files to. Defaults to: ./src/types
GLOBAL_TYPES_FILE
- Path and name for the global types files. Defaults to: ./src/types/global.ts
Add to package.json
{ "scripts": { ... "graphql:schema": "./node_modules/@cmpsr/contentful-core/scripts/graphql-schema.js", "graphql:types": "./node_modules/@cmpsr/contentful-core/scripts/graphql-types.js" } }
lib/apollo.js
import { withApollo } from 'next-apollo';
import ApolloClient from 'apollo-client';
import { InMemoryCache, IntrospectionFragmentMatcher } from 'apollo-cache-inmemory';
import { createContentfulLink } from '@cmpsr/contentful-core/lib/client';
import introspectionQueryResultData from '../../schema/fragmentTypes.json';
const fragmentMatcher = new IntrospectionFragmentMatcher({
introspectionQueryResultData,
});
const apolloClient = new ApolloClient({
link: createContentfulLink({
space: process.env.CONTENTFUL_SPACE_ID,
accessToken: process.env.CONTENTFUL_ACCESS_TOKEN_DELIVERY,
}),
cache: new InMemoryCache({ fragmentMatcher }),
});
export default withApollo(apolloClient);
pages/_app.js
import React from 'react'
import withApollo from '../lib/apollo'
const MyApp = ({ Component, pageProps }) => <Component {...pageProps} />;
export default withApollo({ ssr: true })(MyApp);
pages/index.js
import React from 'react'
import withApollo from '../lib/apollo'
const Home = props => {
...
};
export default withApollo({ ssr: true })(Home);
Coming soon...
FAQs
Base Composer components for standing up a React/NextJS app that can dynamically render components based on Contentful Model types mapped to components and queries.
The npm package @cmpsr/contentful-core receives a total of 760 weekly downloads. As such, @cmpsr/contentful-core popularity was classified as not popular.
We found that @cmpsr/contentful-core demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.