diff --git a/src/components/elements/CodeEditor/CodeEditor.stories.js b/src/components/elements/CodeEditor/CodeEditor.stories.js index 3a48658e8..e162326f9 100644 --- a/src/components/elements/CodeEditor/CodeEditor.stories.js +++ b/src/components/elements/CodeEditor/CodeEditor.stories.js @@ -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 = ` diff --git a/src/pages/docs/mql/data/attr.md b/src/pages/docs/mql/data/attr.md index c3fb3076b..0be195991 100644 --- a/src/pages/docs/mql/data/attr.md +++ b/src/pages/docs/mql/data/attr.md @@ -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' } } }) @@ -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' } } }) diff --git a/src/pages/docs/mql/getting-started/overview.md b/src/pages/docs/mql/getting-started/overview.md index 6fbaaf1d8..eb0322e21 100644 --- a/src/pages/docs/mql/getting-started/overview.md +++ b/src/pages/docs/mql/getting-started/overview.md @@ -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' } } }) diff --git a/src/pages/docs/mql/rules/nested.md b/src/pages/docs/mql/rules/nested.md index a88b77546..8e5056784 100644 --- a/src/pages/docs/mql/rules/nested.md +++ b/src/pages/docs/mql/rules/nested.md @@ -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) ```