-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Static Medium feed #276
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
"webpack-cli": "^3.3.5" | ||
}, | ||
"scripts": { | ||
"data-medium": "mkdir -p data && node tools/rss-to-json.js https://medium.com/feed/nav-coin ./data/medium.json", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Download into Hugo's data directory |
||
"start": "hugo server", | ||
"sass": "gulp sass:watch", | ||
"build": "webpack --mode production", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,13 +14,13 @@ <h2>Community News and Articles</h2> | |
<span class="fa fa-chevron-right"></span> | ||
</a> | ||
</div> | ||
<div id="react-latest-news"> | ||
<div class="status-container"> | ||
<h3>Loading...</h3> | ||
</div> | ||
<div id="latest-news" class="card-container"> | ||
{{ range first 8 .Site.Data.medium.items }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Limit 8 from Hugo data |
||
{{ partial "news/news_card.html" . }} | ||
{{ end }} | ||
</div> | ||
</div> | ||
|
||
{{ partial "home/projects_section.html" . }} | ||
|
||
{{ partial "home/events_section.html" . }} | ||
|
@@ -31,9 +31,5 @@ <h3>Loading...</h3> | |
|
||
{{ partial "footer.html" . }} | ||
|
||
<!-- React components. --> | ||
<script src="/js/react/vendor.bundle.js"></script> | ||
<script src="/js/react/latest-news.js"></script> | ||
|
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<div class="homepage-news-card"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just ported from the React js. |
||
<a href="{{ .link }}}" target="_blank"> | ||
<div class="title-container"><h1>{{ .title }}</h1></div> | ||
<div class="lower-section"> | ||
<div class="project-author"> | ||
<span class="fa fa-user-circle-o"></span> | ||
{{ .creator }} | ||
</div> | ||
<div class="project-date"> | ||
<span class="fa fa-calendar"></span> | ||
<span>{{ dateFormat "2 January 2006" .pubDate }} </span> | ||
</div> | ||
</div> | ||
</a> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
|
||
Download an RSS feed, parse, and save it to a file. | ||
|
||
Usage: | ||
node rss-to-json url-to-rss output.json | ||
|
||
*/ | ||
|
||
|
||
const fs = require("fs"); | ||
const path = require("path"); | ||
const Parser = require("rss-parser"); | ||
const parser = new Parser(); | ||
const [ url, outputPath ] = process.argv.slice(2); | ||
|
||
function save(err, feed) { | ||
if (err !== null) { | ||
const { message, stack, status } = err; | ||
console.log("error parsing", url, message, stack, status) | ||
return | ||
} | ||
|
||
const outputSource = JSON.stringify(feed, null, " "); | ||
fs.writeFile(outputPath, outputSource, function (err) { | ||
if (err !== null) { | ||
const { message, stack } = err; | ||
console.log("error saving", outputPath, message, stack, status) | ||
return | ||
} | ||
console.log("saved", outputPath) | ||
}) | ||
} | ||
|
||
parser.parseURL(url, save); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Netlify will download the feed. You can do it manually with
npm run data-medium
. This should probably go into the readme or combined into package.json scripts.