Skip to content
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

View Medium Button #9

Merged
merged 1 commit into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading