pexed / gridsome-source-directus Goto Github PK
View Code? Open in Web Editor NEWGridsome Source Plugin to load data from Directus CMS
License: MIT License
Gridsome Source Plugin to load data from Directus CMS
License: MIT License
I've installed the 1.1 version of the plugin and though many things are working well, the gridsome_image field is always null when queried. The files are downloaded in the .cache-directus
folder. Many of the other directus-fed fields are present.
Directus version: 8.6.2
collections: [
{
name: 'rotator',
status: 'published',
fields: '*.*.*',
downloadImages: true,
downloadFiles: true,
}
What else can I share to help diagnose this?
Add option to set protocol, because development mode at localhost && test servers often using http protocol:
const http = require(protocol_option);
Add option to set directory for uploading images
let download = async (url, dest, dir = upload_dir_option) => {
Add option for choosing sanitize item or not:
function sanitizeItem(fields) {
if( sanitize_option ) {
let { id, title, slug, path, date, content, excerpt } = fields;
let _id = id.toString();
delete fields.id;
}
return sanitizeFields(fields);
}
When you create new site it is doesn't matter, but when you change current site you haven't to change existing urls
{
"node": {
"id": "883a7598",
"lang": [
{
"id": 11,
"title": "russian title",
"news_text": "russian text",
"lang": "ru"
},
{
"id": 13,
"title": "english title",
"news_text": "english text",
"lang": "en"
},
{
"id": 12,
"title": "ukrainian title",
"news_text": "ukrainian tezt",
"lang": "ua"
}
]
}
}
I would like fetch data like this:
{
"node": {
"id": "883a7598",
"lang_0_id": 11,
"lang_0_title": "russian title",
"lang_0_news_text": "russian text",
"lang_0_lang": "ru",
"lang_1_id": 13,
"lang_1_title": "english title",
"lang_1_news_text": "english text",
"lang_1_lang": "en",
"lang_2_id": 12,
"lang_2_title": "ukrainian title",
"lang_2_news_text": "ukrainian text",
"lang_2_lang": "ua",
}
}
I get the following error with a directus instance I spun up and double and triple checked the URL and login info for:
DIRECTUS ERROR: Can not login to Directus { code: 3, message: 'Unauthorized request', class: 'Directus\\Exception\\UnauthorizedException', file: '/app/code/src/helpers/app.php', line: 287 }
Is anyone else encountering this issue? To specify, I did make the collection I am attempting to fetch and have done no other configuration. Is there something else I need to be doing on the directus side of things?
After reviewing the readme there is no information on how to use the data retrieved from directus. I assume it is a {{ data.collection.item }} or similar? Would recommend adding it to readme info.
Also is the data available on ALL pages globally?
Hello @peXed ,
In directus, I have a collection with a "multiple files" field (O2M).
But on the gridsome side, I can't create a query to get files details. I only have details from the junction table.
What's the best way to have all details of linked files ?
Hi
I am using this plugin in gridsome app with directus v8. Now Directus is upgrading with v9 so I want to integrate this but it seems not working with directus 9 https://docs.directus.io/reference/sdk-js.html
Can you please tell me when you upgrade this package?
Thanks.
I'd like to use filtering in directus using published_on and expired_on fields to control what content gets build into the site. In the docs, it's suggested that other parameters can be passed to the directus api. Is filter on of them. I've been trying some different options and can't seem to get it to work.
collections: [
{
name: 'rotator',
status: 'published',
fields: '*.*.*',
downloadImages: true,
downloadFiles: true,
//filter: "[published_on][lte]=now"
},
I'm sure it's not a bug, but I'm trying to connect to my new directus DB. I think I'm having trouble figuring out what to put in for the apiUrl since I haven't seen any examples. Perhaps I'm missing some other information as well... This is what I've got (sensitive info obfuscated).
{
use: 'gridsome-source-directus',
options: {
apiUrl: 'http://mysite.com/my-project-key/gql',
project: 'my-project-key',
email: '[email protected]',
password: 'superSecretPassword!',
collections: [
{
name: 'blog',
status: 'published',
fields: '*.*',
downloadImages: true
}
]
}
},
I am able to connect to my directus dashboard at the domain. I have set the Public role to have Read permissions on the blog
collection, though I'm logging in with an Admin user, so it shouldn't matter.
Since this is my first time trying to connect to directus, can you see where I've gone wrong?
Hey!
This is not really an issue, but my desire to understand how do you populate "gridsome_image" with data when enabled of downloading images?
"gridsome_image": {
"type": "image",
"mimeType": "image/jpeg",
"src": "/assets/static/.cache-directus/img-cache/fea8a9db-f976-4c60-af26-7e5ba9005885.jpg?width=2048&fit=cover&blur=20&key=215a2f9",
"size": {
"width": 2048,
"height": 1365
},
"sizes": "(max-width: 2048px) 100vw, 2048px",
"srcset": [
"/assets/static/.cache-directus/img-cache/fea8a9db-f976-4c60-af26-7e5ba9005885.jpg?width=480&fit=cover&blur=20&key=215a2f9 480w",
"/assets/static/.cache-directus/img-cache/fea8a9db-f976-4c60-af26-7e5ba9005885.jpg?width=1024&fit=cover&blur=20&key=215a2f9 1024w",
"/assets/static/.cache-directus/img-cache/fea8a9db-f976-4c60-af26-7e5ba9005885.jpg?width=2048&fit=cover&blur=20&key=215a2f9 2048w"
],
"dataUri": "data:image/svg+xml,%3csvg fill='none' viewBox='0 0 2048 1365' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'%3e%3cdefs%3e%3cfilter id='__svg-blur-4ec14479b512767969be30dd9d849ccd'%3e%3cfeGaussianBlur in='SourceGraphic' stdDeviation='20'/%3e%3c/filter%3e%3c/defs%3e%3cimage x='0' y='0' filter='url(%23__svg-blur-4ec14479b512767969be30dd9d849ccd)' width='2048' height='1365' xlink:href='data:image/jpeg%3bbase64%2c/9j/2wBDAAYEBQYFBAYGBQYHBwYIChAKCgkJChQODwwQFxQYGBcUFhYaHSUfGhsjHBYWICwgIyYnKSopGR8tMC0oMCUoKSj/2wBDAQcHBwoIChMKChMoGhYaKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCgoKCj/wAARCAArAEADASIAAhEBAxEB/8QAGQABAQEBAQEAAAAAAAAAAAAABQQGAwcB/8QALxAAAgEDAwIEBQMFAAAAAAAAAQIDAAQRBRIhBjETIkFRBzJhcZEUgbEVI2Khwf/EABcBAQEBAQAAAAAAAAAAAAAAAAMBAgT/xAAdEQACAgMBAQEAAAAAAAAAAAAAAQIhETFRAxJB/9oADAMBAAIRAxEAPwCO/wDiheagxaOyhGTzvYsT%2bOKoHxE1MW%2bIYbGErgZYMxP1FeMadNMZgiZLYOAPtSj3csRZQ%2bGzyp%2b1Yl5x4L9Pp6za/EfV5r3CGzEW0uwMJwqqCWPfJ4FQXfX/AFJbTWkk0kaLPF%2boSPw1YFGzjdwMH6fzWF0W7Mena/PJ5misGVB35dlUn9hmu/SJ0zVluLHVZ7xb9o1S3uAd0Vsq5Azk5POc545oXBJuqQquOM2xq/8AiL1NOJU37Q6GMtHGqhQT3GOx%2btC33VPUFyqM13MWWA2%2bQcZQ98%2b5%2bvejdbaXTLm5s79LYT2%2bFZckZP0weeOc0BLPDPHJIktys4XIULlc%2b3elj5rhyy9JaYpe9SdSyho5NWu3DY4DkAY7dqz1yb5hiSeRwPdycV8W3uLjJUN9zxXeOzmhjJZxk8YzSVHRLexTTHfwyh8Hcw%2bb2FNJbR3sUamOBdpAaVMh29wfT/VAafcMDkNHnPcinUvYWt5FnmCgjaWjTDLnjjHrRSm9IZJO2cv6taPqzR30czxS4iknKhSq425OO4xz71nLW%2bSzMnjqX4IRg%2bOdwIyPUd/zUF622WRVI2g4Xb2xU3gliuzkkZIHpTpBvhsZbibq3V7uRbKR5JpDPNIEIES47Z5woA7VTfaI7W9vFHdRQiPJVgQCwPPNHdD9Ry9OOz2alZJOJJAfMV9sHj7VoZZNMvXe42ySNIdxOccnk8dh9q5/SThhLRcKVvYDNpMyeU6iXP3zmor3S7gLg3Tds4yOfrT11JppPhhZdwzjzHihri5jG4JIc/KCfapGcmVxQha9G60duLXI/wAXU/8Aaqv%2bmtVgsgxtJ/Idx/tk/wAVqLK5mCjEjfmrv1MzjY0r7W4I3elacXnOTaSPGdQtJInPY7jlQO5z6D3rtFpt7AVlFnM2DjyjcD%2bPStPq9jb299eSwoUlR/KwdsjPf1qSHV74tsefeoGAHVWx%2bRSNv8MY6Bx2rLbu7W8guSd8fpjHzKQfpz%2b9VaLNM9vcGNm2xsGwPXivnU1zKBEyvtMgIbaAM/ilNHRbfSrbwRt8VQz%2buSaz6XEiVkTXGIiWY7jzgj1o%2b6wrEhDsIBBz2NJ30jLOUGNpUZGBzyaPvQDGuR7UcaK%2bH//Z' /%3e%3c/svg%3e"
},
I am asking this because there is a port of your Directus 8 implementation but for Directus 9. Unfortunately, when downloading the images, "gridsome_image" is null.
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.