{"id":16551172,"url":"https://github.com/michaelcurrin/static-site-api-request-demo","last_synced_at":"2026-05-13T02:02:27.459Z","repository":{"id":93180003,"uuid":"236155056","full_name":"MichaelCurrin/static-site-api-request-demo","owner":"MichaelCurrin","description":"Demo static site which serves data fetched from an API at build time","archived":false,"fork":false,"pushed_at":"2020-10-23T10:13:38.000Z","size":22,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-14T20:52:16.484Z","etag":null,"topics":["api","demo","netlify","request","ruby","static-site"],"latest_commit_sha":null,"homepage":"https://static-site-api-request-demo.netlify.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MichaelCurrin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-01-25T10:25:54.000Z","updated_at":"2020-10-23T10:13:40.000Z","dependencies_parsed_at":"2023-05-02T07:47:01.007Z","dependency_job_id":null,"html_url":"https://github.com/MichaelCurrin/static-site-api-request-demo","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelCurrin%2Fstatic-site-api-request-demo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelCurrin%2Fstatic-site-api-request-demo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelCurrin%2Fstatic-site-api-request-demo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MichaelCurrin%2Fstatic-site-api-request-demo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MichaelCurrin","download_url":"https://codeload.github.com/MichaelCurrin/static-site-api-request-demo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241876002,"owners_count":20035368,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","demo","netlify","request","ruby","static-site"],"created_at":"2024-10-11T19:36:32.095Z","updated_at":"2025-12-03T03:01:46.988Z","avatar_url":"https://github.com/MichaelCurrin.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Static Site API Request Demo\n\u003e Demo static site which serves data fetched from an API at build time\n\n[![Netlify Status](https://api.netlify.com/api/v1/badges/399e649a-072b-4747-9dc2-c9e5cf0e071e/deploy-status)](https://app.netlify.com/sites/static-site-api-request-demo/deploys)\n[![Made with Jekyll](https://img.shields.io/badge/Made%20with-Jekyll-blue.svg)](https://jekyllrb.com)\n[![Made with Ruby](https://img.shields.io/badge/Made%20with-Ruby-blue.svg)](https://www.ruby-lang.org)\n[![MIT license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/MichaelCurrin/static-site-api-request-demo/blob/master/LICENSE)\n\nThe API request is done during a remote build or locally. The data is written to a file in the served directory.\n\nThis works on Netlify as it allows custom build commands. This will not work on Github Pages though.\n\nRuby requests are based on tutorials:\n\n- https://lostisland.github.io/faraday/usage/\n- http://zetcode.com/web/rubyfaraday/\n\n**Table of contents**\n\n- [Deploy to Netlify](#deploy-to-netlify)\n- [Install](#install)\n    - [System dependencies](#system-dependencies)\n    - [Project dependencies.](#project-dependencies)\n- [Run](#run)\n- [Development](#development)\n\n\n## Deploy to Netlify\n\n1. Login to [app.netlify.com](https://app.netlify.com)\n1. Create a new site.\n1. Point it at this repo on Github.\n1. Optionally rename the site.\n1. Wait for the site to build.\n1. View the URL.\n\nIf you want to use the a secret token in your build, set the following in the Environment section of your Netlify site.\n\n| Key   | Value     |\n| ----- | --------- |\n| TOKEN | secret123 |\n\nWhen you view the `api_data.json` file on the website, the Secret value will be set.\n\n## Install\n\nSetup this project locally - instructions are for Unix-like (_Linux_ or _macOS_) systems.\n\n### System dependencies\n\nInstall [Ruby](https://www.ruby-lang.org/en/documentation/installation/#package-management-systems) using a command appropriate for your OS.\n\nInstall the [Jekyll](https://jekyllrb.com/) and [Bundler](https://bundler.io/) globally using the command below.\n\n```bash\n$ gem install jekyll bundler\n```\n\n_Jekyll_ is used to build static sites. _Bundler_ is used to manage Ruby gem dependencies in an isolated directory, to preserve your global gems.\n\n### Project dependencies.\n\nInstall gems.\n\n```bash\n$ make install\n```\n\nin future, run this command to upgrade to the latest gems.\n\n```bash\n$ make upgrade\n```\n\nWhen you upgrade, the [Gemfile.lock](/Gemfile.lock) file will be updated, if there are any changes. You can commit this to your own repo. This file is optional for _Github Pages_ but required if you want to deploy to _Netlify_.\n\n\n## Run\n\n```sh\n$ make serve-all\n```\n\nThat will command will:\n1. Clear the public `_site` directory (or create it if it does not exist).\n2. Build the Jekyll site.\n3. Fetch API data and store create new data files in the public directory.\n4. Start a web serve in the public directory.\n\n\nOpen in the browser:\n\n- http://localhost:4000/\n\n\nIf you make any changes to the project, you need to stop and start the server.\n\n### Use token\n\nPart of this project includes a demo of using a secret token value, such as one for doing API requests.\n\nSet the token using the command below. When you view the `api_data.json` file, you should see the secret value set with the value.\n\n```sh\n$ TOKEN=secret123 make serve-all\n```\n\n## Development\n\nSee the [Makefile](/Makefile) commands:\n\n```sh\n$ make help\n```\n\nNote that for commands that start as `bundle exec ruby`, this was recommended to avoid errors on Netlify when running ruby. Also, when running locally, ruby can only local gems in the vendor directory if this command is used.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelcurrin%2Fstatic-site-api-request-demo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelcurrin%2Fstatic-site-api-request-demo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelcurrin%2Fstatic-site-api-request-demo/lists"}