Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add analytics to generated urls #65

Merged
merged 4 commits into from
Mar 12, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
refactor: revert secure_url to secureUrl change
  • Loading branch information
raae committed Mar 12, 2023
commit 5f9f78f9a2bb6af88936ccb3d93aafcabf2f8f8a
6 changes: 3 additions & 3 deletions demo/src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function IndexPage({ data }) {
</tr>

{data.allCloudinaryMedia.nodes.map((media) => {
const { secureUrl, context } = media;
const { secure_url, context } = media;
const example1Image = getImage(media.example1ImageData);
const example2Image = getImage(media.example2ImageData);
const example3Image = getImage(media.example3ImageData);
Expand All @@ -49,7 +49,7 @@ export default function IndexPage({ data }) {
<img
width="300"
style={{ maxWidth: '100%', display: 'block' }}
src={secureUrl}
src={secure_url}
alt={alt}
/>
</td>
Expand Down Expand Up @@ -86,7 +86,7 @@ export const query = graphql`
}
allCloudinaryMedia {
nodes {
secureUrl
secure_url
gatsbyImageData(width: 300, placeholder: BLURRED)
example1ImageData: gatsbyImageData(
width: 300
Expand Down
10 changes: 7 additions & 3 deletions plugin/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ const getNodeData = (gatsbyUtils, media, cloudName) => {
});

return {
// Keep all original data around,
// keep for backwards compatability.
// Remove in favour of `cloudinaryData: media`,
// when next breaking change is released
...media,
// ID
id: createNodeId(`cloudinary-media-${media.public_id}`),
// Needed by gatsby-transformer-cloudinary
cloudName: cloudName,
Expand All @@ -46,11 +51,10 @@ const getNodeData = (gatsbyUtils, media, cloudName) => {
originalFormat: media.format,
// Keep all original data around
cloudinaryData: media,
// Generate urls
// Generated urls
url: url,
secureUrl: secureUrl,
// Keep backwards capabilities
secure_url: secureUrl,
// Internal
internal: {
type: NODE_TYPE,
content: JSON.stringify(media),
Expand Down