-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into use-cases/data-registry
- Loading branch information
Showing
58 changed files
with
2,748 additions
and
1,518 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
**IMPORTANT NOTES** (please read, then delete): | ||
Disregard the recommendations below if you use **Edit on Github** button to improve the docs in place. | ||
|
||
- Have you followed the guidelines in | ||
[Contributing Documentation](https://dvc.org/doc/user-guide/contributing/docs)? | ||
❗ Please read the guidelines in the [Contributing to the Documentation](https://dvc.org/doc/user-guide/contributing/docs) list if you make any substantial changes to the documentation or JS engine. | ||
|
||
- Please use the title to provide a clear one-line present-tense summary of the | ||
changes introduced in the PR. For example: "Introduce the first version of the | ||
collection editor.". | ||
🐛 Please make sure to mention `Fix #issue` (if applicable) in the description of the PR. This enables GitHub to link the PR to the corresponding bug and close it automatically when PR is merged. | ||
|
||
- Please make sure to mention "Fix #bugnum" (if applicable) in the description | ||
of the PR. This enables GitHub to link the PR to the corresponding bug. | ||
Thank you for the contribution - we'll try to review and merge it as soon as possible. 🙏 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,6 +85,23 @@ export default class Page extends Document { | |
type="text/css" | ||
href="/static/fonts/fonts.css" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
type="text/css" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/3.0.1/github-markdown.min.css" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/docsearch.min.css" | ||
/> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/npm/[email protected]/css/perfect-scrollbar.min.css" | ||
/> | ||
<script | ||
type="text/javascript" | ||
src="https://cdn.jsdelivr.net/npm/[email protected]/dist/cdn/docsearch.min.js" | ||
/> | ||
{this.props.styleTags} | ||
</Head> | ||
<body> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* This API endpoint is used by https://blog.dvc.org | ||
* to get comments count for the post, it gets | ||
* discuss.dvc.org topic url as a param and returns | ||
* comments count or error. | ||
* | ||
* It made this way to configure CORS, reduce user's payload | ||
* and to add potential ability to cache comments count | ||
* in the future. | ||
*/ | ||
|
||
import Cors from 'micro-cors' | ||
import request from 'request' | ||
|
||
import { BLOG_URL, FORUM_URL } from '../../src/consts' | ||
|
||
const cors = Cors({ | ||
allowedMethods: ['GET', 'HEAD'], | ||
origin: BLOG_URL | ||
}) | ||
|
||
const getCommentCount = (req, res) => { | ||
const { | ||
query: { url } | ||
} = req | ||
|
||
if (!url.startsWith(FORUM_URL)) { | ||
res.status(400) | ||
|
||
return | ||
} | ||
|
||
request(`${url}.json`, (error, response, body) => { | ||
if (error || response.statusCode !== 200) { | ||
res.status(502).json({ error: 'Unexpected response from Forum' }) | ||
|
||
return | ||
} | ||
|
||
const json = JSON.parse(body) | ||
|
||
if (!json.posts_count) { | ||
res.status(502).json({ error: 'Unexpected payload from Forum' }) | ||
|
||
return | ||
} | ||
|
||
// post_count return all posts including topic itself | ||
const count = json.posts_count - 1 | ||
|
||
res.status(200).json({ count }) | ||
}) | ||
} | ||
|
||
export default cors(getCommentCount) |
Oops, something went wrong.