From 818f84faa637382ea9375c5770b2952e152d855e Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Sat, 28 Apr 2018 19:09:15 -0700 Subject: [PATCH] Update README Fixes #91 --- README.md | 62 ++++++++++++++++-- client/About.js | 9 +-- client/Home.js | 9 +-- client/About.md => docs/about.md | 8 +-- .../cloudflare-logo.png | Bin client/HerokuLogo.png => docs/heroku-logo.png | Bin client/Home.md => docs/home.md | 0 7 files changed, 64 insertions(+), 24 deletions(-) rename client/About.md => docs/about.md (76%) rename client/CloudflareLogo.png => docs/cloudflare-logo.png (100%) rename client/HerokuLogo.png => docs/heroku-logo.png (100%) rename client/Home.md => docs/home.md (100%) diff --git a/README.md b/README.md index fd5ae1e..b531b95 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,59 @@ -# unpkg +# unpkg [![Travis][build-badge]][build] -[unpkg](https://unpkg.com) is a fast, global CDN for everything on [npm](https://www.npmjs.com/). +[build-badge]: https://img.shields.io/travis/unpkg/unpkg/master.svg?style=flat-square +[build]: https://travis-ci.org/unpkg/unpkg + +unpkg is a fast, global [content delivery network](https://en.wikipedia.org/wiki/Content_delivery_network) for everything on [npm](https://www.npmjs.com/). Use it to quickly and easily load any file from any package using a URL like: + +
+ unpkg.com/:package@:version/:file +
+ +### Examples + +Using a fixed version: + +* [unpkg.com/react@16.0.0/umd/react.production.min.js](/react@16.0.0/umd/react.production.min.js) +* [unpkg.com/react-dom@16.0.0/umd/react-dom.production.min.js](/react-dom@16.0.0/umd/react-dom.production.min.js) + +You may also use a [semver range](https://docs.npmjs.com/misc/semver) or a [tag](https://docs.npmjs.com/cli/dist-tag) instead of a fixed version number, or omit the version/tag entirely to use the `latest` tag. + +* [unpkg.com/react@^16/umd/react.production.min.js](/react@^16/umd/react.production.min.js) +* [unpkg.com/react/umd/react.production.min.js](/react/umd/react.production.min.js) + +If you omit the file path (i.e. use a "bare" URL), unpkg will serve the file specified by the `unpkg` field in `package.json`, or fall back to `main`. + +* [unpkg.com/d3](/d3) +* [unpkg.com/jquery](/jquery) +* [unpkg.com/three](/three) + +Append a `/` at the end of a URL to view a listing of all the files in a package. + +* [unpkg.com/react/](/react/) +* [unpkg.com/lodash/](/lodash/) + +### Query Parameters + +
+
`?meta`
+
Return metadata about any file in a package as JSON (e.g. `/any/file?meta`)
+ +
`?module`
+
Expands all ["bare" `import` specifiers](https://html.spec.whatwg.org/multipage/webappapis.html#resolve-a-module-specifier) in JavaScript modules to unpkg URLs. This feature is *very experimental*
+
+ +### Cache Behavior + +The CDN caches files based on their permanent URL, which includes the npm package version. This works because npm does not allow package authors to overwrite a package that has already been published with a different one at the same version number. + +URLs that do not specify a package version number redirect to one that does. This is the `latest` version when no version is specified, or the `maxSatisfying` version when a [semver version](https://github.com/npm/node-semver) is given. Redirects are cached for 5 minutes. + +Browsers are instructed (via the `Cache-Control` header) to cache assets for 4 hours. + +### Feedback + +If you think this is useful, we'd love to hear from you. Please reach out to [@unpkg](https://twitter.com/unpkg) with any questions or concerns. + +### Sponsors The project is sponsored by [Cloudflare](https://cloudflare.com) and [Heroku](https://heroku.com). - -## Development - -To start the server, use `yarn dev`. This will start the backend so the website (which is really just a static HTML file) can serve as a proxy for package requests. Then, start the app in another shell with `yarn start`. diff --git a/client/About.js b/client/About.js index b963ab6..219d7c2 100644 --- a/client/About.js +++ b/client/About.js @@ -2,15 +2,10 @@ import "./About.css"; import React from "react"; -import contentHTML from "./About.md"; +import html from "../docs/about.md"; function About() { - return ( -
- ); + return
; } export default About; diff --git a/client/Home.js b/client/Home.js index 2722e5b..9984c60 100644 --- a/client/Home.js +++ b/client/Home.js @@ -2,15 +2,10 @@ import "./Home.css"; import React from "react"; -import contentHTML from "./Home.md"; +import html from "../docs/home.md"; function Home() { - return ( -
- ); + return
; } export default Home; diff --git a/client/About.md b/docs/about.md similarity index 76% rename from client/About.md rename to docs/about.md index 504d87f..b5f2e8b 100644 --- a/client/About.md +++ b/docs/about.md @@ -6,16 +6,16 @@ The fast, global infrastructure that powers unpkg is generously donated by [Clou
### Cache Behavior -The CDN caches all files based on their permanent URL, which includes the npm package version. This works because npm does not allow package authors to overwrite a package that has already been published with a different one at the same version number. +The CDN caches files based on their permanent URL, which includes the npm package version. This works because npm does not allow package authors to overwrite a package that has already been published with a different one at the same version number. URLs that do not specify a package version number redirect to one that does. This is the `latest` version when no version is specified, or the `maxSatisfying` version when a [semver version](https://github.com/npm/node-semver) is given. Redirects are cached for 5 minutes. @@ -37,4 +37,4 @@ unpkg maintains a list of packages that are known to be malicious. If you find s ### Feedback -If you think this is useful, I'd love to hear from you. Please reach out to [@mjackson](https://twitter.com/mjackson) with any questions/concerns. +If you think this is useful, we'd love to hear from you. Please reach out to [@unpkg](https://twitter.com/unpkg) with any questions or concerns. diff --git a/client/CloudflareLogo.png b/docs/cloudflare-logo.png similarity index 100% rename from client/CloudflareLogo.png rename to docs/cloudflare-logo.png diff --git a/client/HerokuLogo.png b/docs/heroku-logo.png similarity index 100% rename from client/HerokuLogo.png rename to docs/heroku-logo.png diff --git a/client/Home.md b/docs/home.md similarity index 100% rename from client/Home.md rename to docs/home.md