Skip to content

Commit

Permalink
Merge pull request #9 from zfir-dev/view-medium-button
Browse files Browse the repository at this point in the history
View Medium Button
  • Loading branch information
zfir authored Dec 28, 2023
2 parents 111382d + 560b52b commit c6b0f1e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
5 changes: 3 additions & 2 deletions app/components/header.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
</button>
<a href={{this.link}} target="_blank" class="btn btn-primary" rel="noopener noreferrer">View on Medium</a>
{{else}}
{{#if this.icon}}
<img src={{this.icon}} alt="Icon" class="icon rounded-circle">
{{#if this.iconUrl}}
<img src={{this.iconUrl}} alt="Icon" class="icon rounded-circle">
{{else}}
<h3 class="mb-0">{{@pageTitle}}</h3>
{{/if}}
<a href={{this.mediumUrl}} target="_blank" class="btn btn-primary" rel="noopener noreferrer">View Medium</a>
{{/if}}
</header>
3 changes: 2 additions & 1 deletion app/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { tracked } from '@glimmer/tracking';
import ENV from 'rss-medium-blog-viewer/config/environment';

export default class HeaderComponent extends Component {
@tracked icon = ENV.icon_url;
@tracked iconUrl = ENV.icon_url;
@tracked mediumUrl = ENV.medium_url;

get link() {
return this.args.items[this.args.selected].link;
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ export default class ApplicationController extends Controller {

@action
async load() {
const medium_url = ENV.medium_url;
const rss_2_json_api_key = ENV.rss_2_json_api_key;
const mediumFeedUrl = ENV.medium_feed_url;
const rss2JsonApiKey = ENV.rss_2_json_api_key;
try {
const response = await fetch(
`https://api.rss2json.com/v1/api.json?rss_url=${medium_url}&api_key=${rss_2_json_api_key}`,
`https://api.rss2json.com/v1/api.json?rss_url=${mediumFeedUrl}&api_key=${rss2JsonApiKey}`,
);
const data = await response.json();
this.items = data.items;
Expand Down
1 change: 1 addition & 0 deletions config/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = function (environment) {
page_title: process.env.PAGE_TITLE,
icon_url: process.env.ICON_URL,
medium_url: process.env.MEDIUM_URL,
medium_feed_url: process.env.MEDIUM_FEED_URL,
rss_2_json_api_key: process.env.RSS_2_JSON_API_KEY,
};

Expand Down
1 change: 1 addition & 0 deletions ember-cli-build.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = function (defaults) {
'PAGE_TITLE',
'ICON_URL',
'MEDIUM_URL',
'MEDIUM_FEED_URL',
'RSS_2_JSON_API_KEY',
],
},
Expand Down

0 comments on commit c6b0f1e

Please sign in to comment.