├── bin ├── getposts.sh ├── getallposts.sh ├── getpost.sh ├── getpost.js └── getposts.js ├── gitmark.json ├── package.json ├── LICENSE ├── README.md ├── .gitignore ├── index.html └── posts ├── 909993.json ├── index.json ├── 421262.json └── 910633.json /bin/getposts.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | curl https://dev.to/api/articles?username=melvincarvalho 4 | 5 | -------------------------------------------------------------------------------- /bin/getallposts.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | POSTS=$(cat posts.json | jq | grep '"id"' | sed 's/[^0-9]//g') 4 | 5 | for i in ${POSTS} 6 | do 7 | bin/getpost.js "$i" 8 | sleep 1 9 | done 10 | -------------------------------------------------------------------------------- /gitmark.json: -------------------------------------------------------------------------------- 1 | { 2 | "@id": "gitmark:f06d2e68884713ce7927dbf42246f8c6962c4f0e2d10dc998115a4bcfeb25a6b:0", 3 | "genesis": "gitmark:f06d2e68884713ce7927dbf42246f8c6962c4f0e2d10dc998115a4bcfeb25a6b:0", 4 | "nick": "gitmark", 5 | "package": "./package.json", 6 | "repository": "./" 7 | } 8 | 9 | -------------------------------------------------------------------------------- /bin/getpost.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | POST=${1} 4 | API_URI="https://dev.to/api/articles/" 5 | 6 | JQ_EXE="/usr/bin/jq" 7 | CURL_EXE="/usr/bin/curl" 8 | 9 | POSTS_DIR="./posts" 10 | EXT=".json" 11 | 12 | if [ -z "${POST}" ] 13 | then 14 | echo "usage: getpost.sh " 15 | exit 16 | fi 17 | 18 | "${CURL_EXE}" "${API_URI}""${POST}" | "${JQ_EXE}" > "${POSTS_DIR}"/"${POST}""${EXT}" 19 | 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "devtoposts", 3 | "version": "0.0.3", 4 | "description": "get your dev to posts", 5 | "main": "index.js", 6 | "bin": { 7 | "devtoposts": "getpost.js" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "git+https://github.com/melvincarvalho/dev.to.git" 15 | }, 16 | "keywords": [ 17 | "dev.to", 18 | "blog", 19 | "posts" 20 | ], 21 | "author": "Melvin Carvalho", 22 | "license": "MIT", 23 | "bugs": { 24 | "url": "https://github.com/melvincarvalho/dev.to/issues" 25 | }, 26 | "homepage": "https://github.com/melvincarvalho/dev.to#readme" 27 | } 28 | -------------------------------------------------------------------------------- /bin/getpost.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // requires 4 | const argv = require('minimist')(process.argv.slice(2)) 5 | const $ = require('child_process').execSync 6 | const fs = require('fs') 7 | 8 | // data 9 | globalThis.data = { 10 | post: null, 11 | api: 'https://dev.to/api/articles/', 12 | datadir: './posts' 13 | } 14 | 15 | // init 16 | data.post = argv._[0] || data.post 17 | data.api = argv.api || data.api 18 | data.datadir = argv.datadir || data.datadir 19 | console.log('data', data) 20 | 21 | // main 22 | const posturi = `${data.api}${data.post}` 23 | const cmd = `curl ${posturi}` 24 | console.log('cmd', cmd) 25 | 26 | const json = JSON.parse($(cmd).toString()) 27 | const output = JSON.stringify(json, null, 2) 28 | const outfile = `${data.datadir}/${data.post}.json` 29 | console.log('output', output) 30 | 31 | fs.writeFileSync(outfile, output) 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Melvin Carvalho 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /bin/getposts.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // requires 4 | const argv = require('minimist')(process.argv.slice(2)) 5 | const fs = require('fs') 6 | const path = require('path') 7 | const $ = require('child_process').execSync 8 | 9 | // data 10 | globalThis.data = { 11 | api: 'https://dev.to/api/articles/latest', 12 | dataDir: path.join(__dirname, '..', 'posts'), 13 | filename: 'index.json', 14 | perPage: 1000, 15 | user: 'melvincarvalho' 16 | } 17 | 18 | // init 19 | data.api = argv.api || data.api 20 | data.dataDir = argv.dataDir || data.dataDir 21 | data.filename = argv.filename || data.filename 22 | data.perPage = argv.perPage || data.perPage 23 | data.user = argv._[0] || data.user 24 | console.log('data', data) 25 | 26 | // main 27 | let postsUri = `${data.api}` 28 | postsUri += `?per_page=${data.perPage}` 29 | postsUri += `&username=${data.user}` 30 | const cmd = `curl '${postsUri}'` 31 | console.log('cmd', cmd) 32 | const json = JSON.parse($(cmd).toString()) 33 | 34 | // output 35 | if (!fs.existsSync(data.dataDir)) { 36 | fs.mkdirSync(data.dataDir, { recursive: true }) 37 | } 38 | const output = JSON.stringify(json, null, 2) 39 | const outFile = path.join(data.dataDir, data.filename) 40 | console.log('output', output) 41 | fs.writeFileSync(outFile, output) 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 |

dev.to posts

3 |
4 | 5 |
6 | Get your dev.to posts 7 |
8 | 9 | --- 10 | 11 |
12 |

Getting Started

13 |
14 | 15 | --- 16 | 17 | 18 | [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/melvincarvalho/dev.to/blob/gh-pages/LICENSE) 19 | [![npm](https://img.shields.io/npm/v/devtoposts)](https://npmjs.com/package/devtoposts) 20 | [![npm](https://img.shields.io/npm/dw/devtoposts.svg)](https://npmjs.com/package/devtoposts) 21 | [![Github Stars](https://img.shields.io/github/stars/melvincarvalho/dev.to.svg)](https://github.com/melvincarvalho/dev.to/) 22 | 23 | ## Introduction 24 | 25 | The aim of this project is to get your dev.to posts and put them in git 26 | 27 | ## Docs 28 | 29 | [How to Get a List of dev.to Posts From the API](https://dev.to/melvincarvalho/how-to-get-devto-posts-for-the-api-552g) 30 | 31 | ## Installation 32 | 33 | ```sh 34 | npm init 35 | ``` 36 | 37 | ## Usage 38 | 39 | ```sh 40 | bin/getposts.js [username] 41 | ``` 42 | Will get your latest posts and put then in `posts/index.json` 43 | 44 | ## Demo 45 | 46 | [Demo](https://melvincarvalho.github.io/dev.to/) 47 | 48 | ## License 49 | 50 | - MIT 51 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | lerna-debug.log* 8 | 9 | # Diagnostic reports (https://nodejs.org/api/report.html) 10 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 11 | 12 | # Runtime data 13 | pids 14 | *.pid 15 | *.seed 16 | *.pid.lock 17 | 18 | # Directory for instrumented libs generated by jscoverage/JSCover 19 | lib-cov 20 | 21 | # Coverage directory used by tools like istanbul 22 | coverage 23 | *.lcov 24 | 25 | # nyc test coverage 26 | .nyc_output 27 | 28 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 29 | .grunt 30 | 31 | # Bower dependency directory (https://bower.io/) 32 | bower_components 33 | 34 | # node-waf configuration 35 | .lock-wscript 36 | 37 | # Compiled binary addons (https://nodejs.org/api/addons.html) 38 | build/Release 39 | 40 | # Dependency directories 41 | node_modules/ 42 | jspm_packages/ 43 | 44 | # TypeScript v1 declaration files 45 | typings/ 46 | 47 | # TypeScript cache 48 | *.tsbuildinfo 49 | 50 | # Optional npm cache directory 51 | .npm 52 | 53 | # Optional eslint cache 54 | .eslintcache 55 | 56 | # Microbundle cache 57 | .rpt2_cache/ 58 | .rts2_cache_cjs/ 59 | .rts2_cache_es/ 60 | .rts2_cache_umd/ 61 | 62 | # Optional REPL history 63 | .node_repl_history 64 | 65 | # Output of 'npm pack' 66 | *.tgz 67 | 68 | # Yarn Integrity file 69 | .yarn-integrity 70 | 71 | # dotenv environment variables file 72 | .env 73 | .env.test 74 | 75 | # parcel-bundler cache (https://parceljs.org/) 76 | .cache 77 | 78 | # Next.js build output 79 | .next 80 | 81 | # Nuxt.js build / generate output 82 | .nuxt 83 | dist 84 | 85 | # Gatsby files 86 | .cache/ 87 | # Comment in the public line in if your project uses Gatsby and *not* Next.js 88 | # https://nextjs.org/blog/next-9-1#public-directory-support 89 | # public 90 | 91 | # vuepress build output 92 | .vuepress/dist 93 | 94 | # Serverless directories 95 | .serverless/ 96 | 97 | # FuseBox cache 98 | .fusebox/ 99 | 100 | # DynamoDB Local files 101 | .dynamodb/ 102 | 103 | # TernJS port file 104 | .tern-port 105 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 11 | Posts 12 | 13 | 14 |

15 | Posts 16 |

17 | 18 |
19 | 20 |
21 | 22 | 23 | 24 | 25 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /posts/909993.json: -------------------------------------------------------------------------------- 1 | { 2 | "type_of": "article", 3 | "id": 909993, 4 | "title": "Adding Gitmark to lazygit", 5 | "description": "Gitmark is a way to mark your git commits to achieve finalization Lazygit is a useful tool for those...", 6 | "readable_publish_date": "Nov 26", 7 | "slug": "adding-gitmark-to-lazygit-dmc", 8 | "path": "/melvincarvalho/adding-gitmark-to-lazygit-dmc", 9 | "url": "https://dev.to/melvincarvalho/adding-gitmark-to-lazygit-dmc", 10 | "comments_count": 0, 11 | "public_reactions_count": 2, 12 | "collection_id": null, 13 | "published_timestamp": "2021-11-26T15:52:03Z", 14 | "positive_reactions_count": 2, 15 | "cover_image": null, 16 | "social_image": "https://dev.to/social_previews/article/909993.png", 17 | "canonical_url": "https://dev.to/melvincarvalho/adding-gitmark-to-lazygit-dmc", 18 | "created_at": "2021-11-26T15:52:03Z", 19 | "edited_at": "2021-11-26T16:07:39Z", 20 | "crossposted_at": null, 21 | "published_at": "2021-11-26T15:52:03Z", 22 | "last_comment_at": "2021-11-26T15:52:03Z", 23 | "reading_time_minutes": 1, 24 | "tag_list": "gitmark, git, lazygit, config", 25 | "tags": [ 26 | "gitmark", 27 | "git", 28 | "lazygit", 29 | "config" 30 | ], 31 | "body_html": "

Gitmark is a way to mark your git commits to achieve finalization

\n\n

Lazygit is a useful tool for those running git on the command line

\n\n

Lazygit has an interesting feature which lets you add commands to key bindings. Here's how I added a gitmark workflow to lazygit
\n

\n\n
\n
customCommands:\n  - key: 'm'\n    context: 'global'\n    subprocess: true\n    prompts:\n      - type: 'menu'\n        title: 'Git Mark?'\n        options:\n          - name: 'trial'\n            description: 'trial run'\n          - name: 'commit'\n            description: 'commit'\n            value: '--tag --send --commit'\n          - name: 'init'\n            description: 'init'\n            value: 'init'\n    command: 'git mark {{index .PromptResponses 0}}'\n
\n
\n
\n Enter fullscreen mode\n \n\n\n Exit fullscreen mode\n \n\n\n
\n
\n
\n\n\n\n", 32 | "body_markdown": "[Gitmark](https://git-mark.com/) is a way to mark your git commits to achieve finalization\n\n[Lazygit](https://github.com/jesseduffield/lazygit) is a useful tool for those running git on the command line\n\nLazygit has an interesting feature which lets you add commands to key bindings. Here's how I added a gitmark workflow to lazygit\n\n```yaml\ncustomCommands:\n - key: 'm'\n context: 'global'\n subprocess: true\n prompts:\n - type: 'menu'\n title: 'Git Mark?'\n options:\n - name: 'trial'\n description: 'trial run'\n - name: 'commit'\n description: 'commit'\n value: '--tag --send --commit'\n - name: 'init'\n description: 'init'\n value: 'init'\n command: 'git mark {{index .PromptResponses 0}}'\n```\n\n", 33 | "user": { 34 | "name": "Melvin Carvalho", 35 | "username": "melvincarvalho", 36 | "twitter_username": "melvincarvalho", 37 | "github_username": "melvincarvalho", 38 | "website_url": "https://melvincarvalho.com/#me", 39 | "profile_image": "https://res.cloudinary.com/practicaldev/image/fetch/s--WfdMiDbQ--/c_fill,f_auto,fl_progressive,h_640,q_auto,w_640/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg", 40 | "profile_image_90": "https://res.cloudinary.com/practicaldev/image/fetch/s--RdzOJxSE--/c_fill,f_auto,fl_progressive,h_90,q_auto,w_90/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg" 41 | } 42 | } -------------------------------------------------------------------------------- /posts/index.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "type_of": "article", 4 | "id": 910633, 5 | "title": "How to Get a List of dev.to Posts From the API", 6 | "description": "Overview I've decided to download my dev.to posts so that I can store them in git. That...", 7 | "readable_publish_date": "Nov 27", 8 | "slug": "how-to-get-devto-posts-for-the-api-552g", 9 | "path": "/melvincarvalho/how-to-get-devto-posts-for-the-api-552g", 10 | "url": "https://dev.to/melvincarvalho/how-to-get-devto-posts-for-the-api-552g", 11 | "comments_count": 0, 12 | "public_reactions_count": 31, 13 | "collection_id": null, 14 | "published_timestamp": "2021-11-27T11:43:17Z", 15 | "positive_reactions_count": 31, 16 | "cover_image": null, 17 | "social_image": "https://dev.to/social_previews/article/910633.png", 18 | "canonical_url": "https://dev.to/melvincarvalho/how-to-get-devto-posts-for-the-api-552g", 19 | "created_at": "2021-11-27T11:43:17Z", 20 | "edited_at": "2021-11-28T12:30:28Z", 21 | "crossposted_at": null, 22 | "published_at": "2021-11-27T11:43:17Z", 23 | "last_comment_at": "2021-11-27T11:43:17Z", 24 | "reading_time_minutes": 2, 25 | "tag_list": [ 26 | "devto", 27 | "api", 28 | "javascript", 29 | "beginners" 30 | ], 31 | "tags": "devto, api, javascript, beginners", 32 | "user": { 33 | "name": "Melvin Carvalho", 34 | "username": "melvincarvalho", 35 | "twitter_username": "melvincarvalho", 36 | "github_username": "melvincarvalho", 37 | "website_url": "https://melvincarvalho.com/#me", 38 | "profile_image": "https://res.cloudinary.com/practicaldev/image/fetch/s--WfdMiDbQ--/c_fill,f_auto,fl_progressive,h_640,q_auto,w_640/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg", 39 | "profile_image_90": "https://res.cloudinary.com/practicaldev/image/fetch/s--RdzOJxSE--/c_fill,f_auto,fl_progressive,h_90,q_auto,w_90/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg" 40 | } 41 | }, 42 | { 43 | "type_of": "article", 44 | "id": 909993, 45 | "title": "Adding Gitmark to lazygit", 46 | "description": "Gitmark is a way to mark your git commits to achieve finalization Lazygit is a useful tool for those...", 47 | "readable_publish_date": "Nov 26", 48 | "slug": "adding-gitmark-to-lazygit-dmc", 49 | "path": "/melvincarvalho/adding-gitmark-to-lazygit-dmc", 50 | "url": "https://dev.to/melvincarvalho/adding-gitmark-to-lazygit-dmc", 51 | "comments_count": 0, 52 | "public_reactions_count": 2, 53 | "collection_id": null, 54 | "published_timestamp": "2021-11-26T15:52:03Z", 55 | "positive_reactions_count": 2, 56 | "cover_image": null, 57 | "social_image": "https://dev.to/social_previews/article/909993.png", 58 | "canonical_url": "https://dev.to/melvincarvalho/adding-gitmark-to-lazygit-dmc", 59 | "created_at": "2021-11-26T15:52:03Z", 60 | "edited_at": "2021-11-26T16:07:39Z", 61 | "crossposted_at": null, 62 | "published_at": "2021-11-26T15:52:03Z", 63 | "last_comment_at": "2021-11-26T15:52:03Z", 64 | "reading_time_minutes": 1, 65 | "tag_list": [ 66 | "gitmark", 67 | "git", 68 | "lazygit", 69 | "config" 70 | ], 71 | "tags": "gitmark, git, lazygit, config", 72 | "user": { 73 | "name": "Melvin Carvalho", 74 | "username": "melvincarvalho", 75 | "twitter_username": "melvincarvalho", 76 | "github_username": "melvincarvalho", 77 | "website_url": "https://melvincarvalho.com/#me", 78 | "profile_image": "https://res.cloudinary.com/practicaldev/image/fetch/s--WfdMiDbQ--/c_fill,f_auto,fl_progressive,h_640,q_auto,w_640/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg", 79 | "profile_image_90": "https://res.cloudinary.com/practicaldev/image/fetch/s--RdzOJxSE--/c_fill,f_auto,fl_progressive,h_90,q_auto,w_90/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg" 80 | } 81 | }, 82 | { 83 | "type_of": "article", 84 | "id": 421262, 85 | "title": "Introducing Linked Objects", 86 | "description": "What is a Linked Object? A linked object is is an object which you get from an URL, the...", 87 | "readable_publish_date": "Aug 7 '20", 88 | "slug": "introducting-linked-objects-314h", 89 | "path": "/melvincarvalho/introducting-linked-objects-314h", 90 | "url": "https://dev.to/melvincarvalho/introducting-linked-objects-314h", 91 | "comments_count": 0, 92 | "public_reactions_count": 5, 93 | "collection_id": null, 94 | "published_timestamp": "2020-08-07T12:36:39Z", 95 | "positive_reactions_count": 5, 96 | "cover_image": "https://res.cloudinary.com/practicaldev/image/fetch/s--Abg-Q62g--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/qfa6pdpwn7qxvqn4pho5.png", 97 | "social_image": "https://res.cloudinary.com/practicaldev/image/fetch/s--PUVqQ3k1--/c_imagga_scale,f_auto,fl_progressive,h_500,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/qfa6pdpwn7qxvqn4pho5.png", 98 | "canonical_url": "https://dev.to/melvincarvalho/introducting-linked-objects-314h", 99 | "created_at": "2020-08-07T10:49:49Z", 100 | "edited_at": "2021-11-28T14:14:57Z", 101 | "crossposted_at": null, 102 | "published_at": "2020-08-07T12:36:39Z", 103 | "last_comment_at": "2020-08-07T12:36:39Z", 104 | "reading_time_minutes": 2, 105 | "tag_list": [ 106 | "linkedobjects", 107 | "linkeddata", 108 | "jsonld", 109 | "json" 110 | ], 111 | "tags": "linkedobjects, linkeddata, jsonld, json", 112 | "user": { 113 | "name": "Melvin Carvalho", 114 | "username": "melvincarvalho", 115 | "twitter_username": "melvincarvalho", 116 | "github_username": "melvincarvalho", 117 | "website_url": "https://melvincarvalho.com/#me", 118 | "profile_image": "https://res.cloudinary.com/practicaldev/image/fetch/s--WfdMiDbQ--/c_fill,f_auto,fl_progressive,h_640,q_auto,w_640/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg", 119 | "profile_image_90": "https://res.cloudinary.com/practicaldev/image/fetch/s--RdzOJxSE--/c_fill,f_auto,fl_progressive,h_90,q_auto,w_90/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg" 120 | } 121 | } 122 | ] -------------------------------------------------------------------------------- /posts/421262.json: -------------------------------------------------------------------------------- 1 | { 2 | "type_of": "article", 3 | "id": 421262, 4 | "title": "Introducting Linked Objects", 5 | "description": "What is a Linked Object? A linked object is is an object which you get from an URL, the UR...", 6 | "readable_publish_date": "Aug 7 '20", 7 | "slug": "introducting-linked-objects-314h", 8 | "path": "/melvincarvalho/introducting-linked-objects-314h", 9 | "url": "https://dev.to/melvincarvalho/introducting-linked-objects-314h", 10 | "comments_count": 0, 11 | "public_reactions_count": 5, 12 | "collection_id": null, 13 | "published_timestamp": "2020-08-07T12:36:39Z", 14 | "positive_reactions_count": 5, 15 | "cover_image": "https://res.cloudinary.com/practicaldev/image/fetch/s--Abg-Q62g--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/qfa6pdpwn7qxvqn4pho5.png", 16 | "social_image": "https://res.cloudinary.com/practicaldev/image/fetch/s--PUVqQ3k1--/c_imagga_scale,f_auto,fl_progressive,h_500,q_auto,w_1000/https://dev-to-uploads.s3.amazonaws.com/i/qfa6pdpwn7qxvqn4pho5.png", 17 | "canonical_url": "https://dev.to/melvincarvalho/introducting-linked-objects-314h", 18 | "created_at": "2020-08-07T10:49:49Z", 19 | "edited_at": "2020-08-12T15:50:27Z", 20 | "crossposted_at": null, 21 | "published_at": "2020-08-07T12:36:39Z", 22 | "last_comment_at": "2020-08-07T12:36:39Z", 23 | "reading_time_minutes": 2, 24 | "tag_list": "linkedobjects, linkeddata, jsonld, json", 25 | "tags": [ 26 | "linkedobjects", 27 | "linkeddata", 28 | "jsonld", 29 | "json" 30 | ], 31 | "body_html": "

\n \n \n What is a Linked Object?\n

\n\n

A linked object is is an object which you get from an URL, the URL is its id.

\n\n

\n \n \n What are the Benefits?\n

\n\n

It allows you to update nested objects independently of each other and reference them within multiple different objects since they are by reference.

\n\n

\n \n \n Linked Object Notation (LION)\n

\n\n

The Linked Objects Notation (LION) is a simple subset of JSON-LD. It aims to avoid most of the complexity, and enables getting started quickly, using a familiar notation. LION is compatible with JSON-LD and offers a full upgrade path.

\n\n

\n \n \n A Simple Example\n

\n\n\n\n
<script type=\"application/ld+json\">\n{\n  \"@id\": \"http://dbpedia.org/resource/John_Lennon\",\n  \"name\": \"John Lennon\",\n  \"born\": \"1940-10-09\",\n  \"spouse\": \"http://dbpedia.org/resource/Cynthia_Lennon\"\n}\n</script>\n
\n\n\n\n

\n \n \n @id\n\n

\n\n

@id\n is the URL of the object. It can also be written \"id\". The @id\n can be absolute or relative. @id\n is optional but recommended, and makes an object into an Linked Object.

\n\n

\n \n \n @type\n

\n\n

@type is the type of for that object. It can also be written \"type\". @type normally maps to a URL. Type is optional.

\n\n

\n \n \n @context\n

\n\n

@context is optional. It provides full compatibility with JSON-LD and and maps various items in the object to URLs in a more readable way.

\n\n

\n \n \n Spec\n

\n\n

Full details on @id\n, @type and @context can be found in here

\n\n

\n \n \n References\n

\n\n\n\n

\n \n \n Linked Objects is Open Source\n

\n\n

Linked Objects is open source under the MIT license. Please visit our repository or raise an issue

\n\n", 32 | "body_markdown": "# What is a Linked Object?\n\nA [linked object](https://linkedobjects.org/) is is an object which you get from an URL, the URL is its id.\n\n# What are the Benefits?\n\nIt allows you to update nested objects independently of each other and reference them within multiple different objects since they are by reference.\n\n# Linked Object Notation (LION)\n\nThe Linked Objects Notation (LION) is a simple subset of [JSON-LD](https://json-ld.org/). It aims to avoid most of the complexity, and enables getting started quickly, using a familiar notation. LION is compatible with JSON-LD and offers a full upgrade path.\n\n# A Simple Example\n\n```html\n\n```\n\n## @id\n\n@id is the URL of the object. It can also be written \"id\". The @id can be absolute or relative. @id is optional but recommended, and makes an object into an Linked Object.\n\n## @type\n\n@type is the type of for that object. It can also be written \"type\". @type normally maps to a URL. Type is optional.\n\n## @context\n\n@context is optional. It provides full compatibility with JSON-LD and and maps various items in the object to URLs in a more readable way.\n\n## Spec\n\nFull details on @id, @type and @context can be found in [here](https://w3c.github.io/json-ld-syntax/#syntax-tokens-and-keywords)\n\n## References\n\n- [JSON-LD 1.1](https://w3c.github.io/json-ld-syntax/)\n- [JSON Tiny Proposal](https://lists.w3.org/Archives/Public/public-rdf-wg/2011Mar/0565.html)\n\n# Linked Objects is Open Source\n\nLinked Objects is open source under the MIT license. Please visit our [repository](https://github.com/linkedobjects/linkedobjects) or raise an [issue](https://github.com/linkedobjects/linkedobjects/issues)\n", 33 | "user": { 34 | "name": "Melvin Carvalho", 35 | "username": "melvincarvalho", 36 | "twitter_username": "melvincarvalho", 37 | "github_username": "melvincarvalho", 38 | "website_url": "https://melvincarvalho.com/#me", 39 | "profile_image": "https://res.cloudinary.com/practicaldev/image/fetch/s--WfdMiDbQ--/c_fill,f_auto,fl_progressive,h_640,q_auto,w_640/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg", 40 | "profile_image_90": "https://res.cloudinary.com/practicaldev/image/fetch/s--RdzOJxSE--/c_fill,f_auto,fl_progressive,h_90,q_auto,w_90/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg" 41 | } 42 | } -------------------------------------------------------------------------------- /posts/910633.json: -------------------------------------------------------------------------------- 1 | { 2 | "type_of": "article", 3 | "id": 910633, 4 | "title": "How to get dev.to posts from the API", 5 | "description": "I've decided to download my dev.to posts so that I can store them in git. That means that if the...", 6 | "readable_publish_date": "Nov 27", 7 | "slug": "how-to-get-devto-posts-for-the-api-552g", 8 | "path": "/melvincarvalho/how-to-get-devto-posts-for-the-api-552g", 9 | "url": "https://dev.to/melvincarvalho/how-to-get-devto-posts-for-the-api-552g", 10 | "comments_count": 0, 11 | "public_reactions_count": 8, 12 | "collection_id": null, 13 | "published_timestamp": "2021-11-27T11:43:17Z", 14 | "positive_reactions_count": 8, 15 | "cover_image": null, 16 | "social_image": "https://dev.to/social_previews/article/910633.png", 17 | "canonical_url": "https://dev.to/melvincarvalho/how-to-get-devto-posts-for-the-api-552g", 18 | "created_at": "2021-11-27T11:43:17Z", 19 | "edited_at": "2021-11-27T18:37:27Z", 20 | "crossposted_at": null, 21 | "published_at": "2021-11-27T11:43:17Z", 22 | "last_comment_at": "2021-11-27T11:43:17Z", 23 | "reading_time_minutes": 2, 24 | "tag_list": "devto, api, javascript, beginners", 25 | "tags": [ 26 | "devto", 27 | "api", 28 | "javascript", 29 | "beginners" 30 | ], 31 | "body_html": "

I've decided to download my dev.to posts so that I can store them in git. That means that if the site ever goes down, I have a copy of my blog content. The API is documented here.

\n\n

The following endpoint will give a list of articles: https://dev.to/api/articles?username=melvincarvalho

\n\n

It supports pagination, each page will contain 30 articles by default.

\n\n

Replace melvincarvalho with your own username

\n\n

So I wrote a JavaScript script that will pull out my articles.
\n

\n\n
\n
#!/usr/bin/env node\n\n// requires\nconst argv = require('minimist')(process.argv.slice(2))\nconst $ = require('child_process').execSync\nconst fs = require('fs')\n\n// data\nglobalThis.data = {\n  user: 'melvincarvalho',\n  api: 'https://dev.to/api/articles/',\n  datadir: '.'\n}\n\n// init\ndata.user = argv._[0] || data.user\ndata.api = argv.api || data.api\ndata.datadir = argv.datadir || data.datadir\nconsole.log('data', data)\n\n// main\nconst useruri = `${data.api}?username=${data.user}`\nconst cmd = `curl ${useruri}`\nconsole.log('cmd', cmd)\n\nconst json = JSON.parse($(cmd).toString())\nconst output = JSON.stringify(json, null, 2)\nconst outfile = `${data.datadir}/posts.json`\nconsole.log('output', output)\n\nfs.writeFileSync(outfile, output)\n
\n
\n
\n Enter fullscreen mode\n \n\n\n Exit fullscreen mode\n \n\n\n
\n
\n
\n\n\n\n

Usage: ./getposts.js [username]

\n\n

First we initialize the endpoint and username. Then we run some curl to get the result, and finally we format it and write it to a file.

\n\n

The JSON output can be seen here and the current script is here

\n\n

Now that I have a list of articles, it should be possible to download the markdown from individual articles too. I will hopefully cover that in a future post.

\n\n", 32 | "body_markdown": "I've decided to download my [dev.to](https://dev.to/) posts so that I can store them in git. That means that if the site ever goes down, I have a copy of my blog content. The API is documented [here](https://developers.forem.com/api/).\n\nThe following endpoint will give a list of articles: https://dev.to/api/articles?username=melvincarvalho\n\nIt supports pagination, each page will contain 30 articles by default.\n\nReplace `melvincarvalho` with your own username\n\nSo I wrote a JavaScript script that will pull out my articles.\n\n```JavaScript\n#!/usr/bin/env node\n\n// requires\nconst argv = require('minimist')(process.argv.slice(2))\nconst $ = require('child_process').execSync\nconst fs = require('fs')\n\n// data\nglobalThis.data = {\n user: 'melvincarvalho',\n api: 'https://dev.to/api/articles/',\n datadir: '.'\n}\n\n// init\ndata.user = argv._[0] || data.user\ndata.api = argv.api || data.api\ndata.datadir = argv.datadir || data.datadir\nconsole.log('data', data)\n\n// main\nconst useruri = `${data.api}?username=${data.user}`\nconst cmd = `curl ${useruri}`\nconsole.log('cmd', cmd)\n\nconst json = JSON.parse($(cmd).toString())\nconst output = JSON.stringify(json, null, 2)\nconst outfile = `${data.datadir}/posts.json`\nconsole.log('output', output)\n\nfs.writeFileSync(outfile, output)\n```\n\n`Usage: ./getposts.js [username]`\n\nFirst we initialize the endpoint and username. Then we run some curl to get the result, and finally we format it and write it to a file.\n\nThe JSON output can be seen [here](https://melvincarvalho.github.io/dev.to/posts.json) and the current script is [here](https://github.com/melvincarvalho/dev.to/blob/gh-pages/bin/getposts.js)\n\nNow that I have a list of articles, it should be possible to download the markdown from individual articles too. I will hopefully cover that in a future post.", 33 | "user": { 34 | "name": "Melvin Carvalho", 35 | "username": "melvincarvalho", 36 | "twitter_username": "melvincarvalho", 37 | "github_username": "melvincarvalho", 38 | "website_url": "https://melvincarvalho.com/#me", 39 | "profile_image": "https://res.cloudinary.com/practicaldev/image/fetch/s--WfdMiDbQ--/c_fill,f_auto,fl_progressive,h_640,q_auto,w_640/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg", 40 | "profile_image_90": "https://res.cloudinary.com/practicaldev/image/fetch/s--RdzOJxSE--/c_fill,f_auto,fl_progressive,h_90,q_auto,w_90/https://dev-to-uploads.s3.amazonaws.com/uploads/user/profile_image/448014/8c938ffb-fe97-4763-a32c-acb329fb32d1.jpg" 41 | } 42 | } --------------------------------------------------------------------------------