Gathering detailed insights and metrics for gatsby-source-mozaik
Gathering detailed insights and metrics for gatsby-source-mozaik
Gathering detailed insights and metrics for gatsby-source-mozaik
Gathering detailed insights and metrics for gatsby-source-mozaik
Gatsby source plugin for building static websites using Mozaik CMS as a data source.
npm install gatsby-source-mozaik
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
1 Stars
3 Commits
1 Branches
1 Contributors
Updated on Apr 25, 2019
Latest Version
1.0.0
Package Id
gatsby-source-mozaik@1.0.0
Unpacked Size
9.46 kB
Size
3.63 kB
File Count
5
NPM Version
5.6.0
Node Version
8.9.4
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
Source plugin for pulling data from a Mozaik endpoint into Gatsby.
yarn add gatsby-source-mozaik
or npm i gatsby-source-mozaik
gatsby-source-mozaik
. See example below.gatsby develop
Make sure that gatsby-source-mozaik
plugin is referenced in you gatsby-config.js
:
1plugins: [ 2 { 3 resolve: `gatsby-source-mozaik`, 4 options: { 5 endpoint: `https://api.mozaik.io/[your-project-name]`, 6 accessToken: `your-access-token`, 7 query: ` 8 query documentsQuery($types: [DocumentContentTypeEnum] $pageSize: Int $page: Int) { 9 documents(types: $types pageSize: $pageSize page: $page) { 10 pagination { 11 page 12 pageCount 13 } 14 items { 15 id 16 contentType 17 slug 18 } 19 } 20 } 21 `, 22 variables: { 23 types: [], 24 pageSize: 20, 25 page: 1 26 }, 27 fragments: [] 28 }, 29 } 30],
Key | Value | Required |
---|---|---|
endpoint | Your mozaik api endpoint: https://api.mozaik.io/[your-project-name] | Yes |
accessToken | The access token for authorizing against the api | Yes |
query | The graphql query to execute. You should use the sample documents query and only amend it. | Yes |
variables | Variables to use in the graphql query | Yes |
variables.types | An array of string that defines the content types you want to get from the api | Yes |
variables.pageSize | Number of items to download in one batch | Yes |
variables.page | The page number | Yes |
fragments | An array of string that defines the fields you want to query on each content type | No |
Let's say you have created a blog project using the sample blog template on Mozaik. You will have 3 different content types (the enum name in your GraphQL schema):
And you only implement the homepage and the post page components.
To create the query you have to add the following plugin options:
1variables: { 2 types: ['HOMEPAGE', 'POST'], 3 page: 1, 4 pageSize: 20 5}
In Mozaik each document implements the DocumentInterface
type, and because of this the result of the documents
query returns an array of DocumentInterface
object. To be able to query specific fields on each document, you have to define a fragment
for each content type. Although you can do this by inlining the fragments in the query itself, we highly recommend to add every fragment in the fragments
plugin option in you config. You can read more about interfaces and fragments in the GraphQL documentation
First let's add the fragment definitions:
1fragments: [ 2 `fragment HomepageDetails on HomepageDocument { 3 title 4 tagline 5 headerImage { 6 ...HeaderImageFragment 7 } 8 topPosts { 9 items { 10 ...PostDetails 11 } 12 } 13 }` 14 `fragment PostDetails on PostDocument { 15 title 16 slug 17 date 18 postContent { 19 html 20 } 21 postAuthor { 22 name 23 } 24 headerImage { 25 ...HeaderImageFragment 26 } 27 }`, 28 `fragment HeaderImageFragment on Asset { 29 url 30 thumbnailUrl 31 caption 32 }` 33]
Update the default query to add the fragments above:
1query documentsQuery($types: [DocumentContentTypeEnum] $pageSize: Int $page: Int) { 2 documents(types: $types pageSize: $pageSize page: $page) { 3 pagination { 4 page 5 pageCount 6 } 7 items { 8 id 9 contentType 10 slug 11 ...PostDetails 12 ...HomepageDetails 13 } 14 } 15}
And that's it! You're ready to run gatsby develop
and load all your documents. If you open the graphql ide that comes with Gatsby you can query your Post documents by running the allPosts
query (or the allHomepage
query for the Homepage document).
cd
to the Gatsby project you've set up in which you want to test your changes of the plugin code, or clone mozaikio/mozaik-gatsby-example
yarn
or npm
, run yarn remove gatsby-source-mozaik
or npm r gatsby-source-mozaik
mkdir plugins
if it does not exist in your Gatsby project yet and cd
into it~/projects/mozaik-gatsby-website/plugins/
git clone https://github.com/mozaikio/gatsby-source-mozaik.git
cd gatsby-source-mozaik
yarn
or yarn && yarn watch
in gatsby-source-mozaik
plugin’s folder for auto-rebuilding the plugin after you make changes to it (you need to do this only during development)cd ../.. && yarn && yarn develop
to testNo vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
Found 0/3 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
67 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More