Skip to content

Commit

Permalink
docs: update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jun 4, 2020
1 parent 9cd9d3b commit e295e2e
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 41 deletions.
37 changes: 21 additions & 16 deletions src/components/elements/CodeEditor/CodeEditor.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,33 @@ import { Story } from 'story'
const jsCode = `
const mql = require('@microlink/mql')
const twitter = (username) =>
mql(\`https://twitter.com/\${username}\`, {
const github = (username) =>
mql(\`https://github.com/\${username}\`, {
data: {
stats: {
selector: '.ProfileNav-list',
selector: '.user-profile-nav nav',
attr: {
tweets: {
selector: '.ProfileNav-item--tweets .ProfileNav-value',
attr: 'data-count',
repositories: {
selector: 'a:nth-child(2) > span',
type: 'number'
},
followings: {
selector: '.ProfileNav-item--following .ProfileNav-value',
attr: 'data-count',
},
favorites: {
selector: '.ProfileNav-item--favorites .ProfileNav-value',
attr: 'data-count',
followers: {
selector: 'a:nth-child(4) > span',
type: 'number'
},
},
},
},
followings: {
selector: 'a:nth-child(5) > span',
type: 'number'
}
}
}
}
})
const username = 'kikobeats'
const { response, data } = await github(username)
console.log(\`GitHub stats for @\${username}:\`, data.stats)
`

const jsxCode = `
Expand Down
12 changes: 6 additions & 6 deletions src/pages/docs/mql/data/attr.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const instagram = username =>
mql(`https://www.instagram.com/${username}`, {
data: {
avatar: {
selector: 'header img',
type: 'image',
attr: 'src'
selector: 'meta[property="og:image"]',
attr: 'content',
type: 'image'
}
}
})
Expand All @@ -43,9 +43,9 @@ const instagram = username =>
mql(`https://www.instagram.com/${username}`, {
data: {
avatar: {
selector: 'header img',
type: 'image',
attr: ['data-load', 'srcset', 'src']
selector: 'meta[property="og:image"]',
attr: ['value', 'content'],
type: 'image'
}
}
})
Expand Down
6 changes: 3 additions & 3 deletions src/pages/docs/mql/getting-started/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ const instagram = username =>
mql(`https://www.instagram.com/${username}`, {
data: {
avatar: {
selector: 'header img',
type: 'image',
attr: 'src'
selector: 'meta[property="og:image"]',
attr: 'content',
type: 'image'
}
}
})
Expand Down
32 changes: 16 additions & 16 deletions src/pages/docs/mql/rules/nested.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ In case you need, you can use [attr](/docs/mql/data/attr) for mapping data struc

```js
const mql = require('@microlink/mql')
const twitter = username =>
mql(`https://twitter.com/${username}`, {

const github = (username) =>
mql(`https://github.com/${username}`, {
data: {
stats: {
selector: ".ProfileNav-list",
selector: '.user-profile-nav nav',
attr: {
tweets: {
selector: ".ProfileNav-item--tweets .ProfileNav-value",
attr: "data-count",
},
followings: {
selector: ".ProfileNav-item--following .ProfileNav-value",
attr: "data-count",
repositories: {
selector: 'a:nth-child(2) > span',
type: 'number'
},
followers: {
selector: ".ProfileNav-item--followers .ProfileNav-value",
attr: "data-count",
selector: 'a:nth-child(4) > span',
type: 'number'
},
followings: {
selector: 'a:nth-child(5) > span',
type: 'number'
}
}
}
}
})

const username = 'microlinkhq'
const { data } = await twitter(username)
const username = 'kikobeats'
const { response, data } = await github(username)

console.log(`stats for @${username}:`, data.stats)
console.log(`GitHub stats for @${username}:`, data.stats)
```

0 comments on commit e295e2e

Please sign in to comment.