Skip to content

Commit

Permalink
[dashboard] Getting tutorials feed from proxy (#1251)
Browse files Browse the repository at this point in the history
* [dashboard] Getting tutorials feed from proxy

* [dashboard] Use correct url to guide
  • Loading branch information
Kristoffer J. Sivertsen committed Mar 27, 2019
1 parent 0e63be0 commit 95380a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import dataAdapter from './dataAdapter'
const {urlBuilder, getFeed} = dataAdapter

function createUrl(slug) {
return `https://www.sanity.io/guide/${slug.current}`
return `https://www.sanity.io/docs/guides/${slug.current}`
}

class SanityTutorials extends React.Component {
Expand All @@ -17,24 +17,13 @@ class SanityTutorials extends React.Component {
}

componentDidMount() {
this.unsubscribe()
this.subscription = getFeed().subscribe(response => {
getFeed().then(response => {
this.setState({
feedItems: response.items
})
})
}

componentWillUnmount() {
this.unsubscribe()
}

unsubscribe() {
if (this.subscription) {
this.subscription.unsubscribe()
}
}

render() {
const {feedItems} = this.state
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
import client from 'part:@sanity/base/client'
import sanityClient from '@sanity/client'
import imageUrlBuilder from '@sanity/image-url'

// We're connecting to
const client = sanityClient({
const configuredClient = sanityClient({
projectId: '3do82whm',
dataset: 'production',
useCdn: true
})

const query = `
*[_id == 'dashboardFeed-v1'] {
items[]-> {
_id,
title,
poster,
youtubeURL,
"presenter": authors[0]-> {name, mugshot, bio},
guideOrTutorial-> {
title,
slug,
"presenter": authors[0]-> {name, mugshot, bio},
_createdAt
}
}
}[0]
`

export default {
getFeed: () => client.observable.fetch(query),
urlBuilder: imageUrlBuilder(client)
getFeed: () => client.request({uri: '/addons/dashboard', withCredentials: false}),
urlBuilder: imageUrlBuilder(configuredClient)
}

0 comments on commit 95380a5

Please sign in to comment.