Skip to content

Commit

Permalink
Merge pull request #407 from systemli/add-links-to-feeds
Browse files Browse the repository at this point in the history
✨ Add Links to Atom & RSS Feeds
  • Loading branch information
0x46616c6b authored Oct 6, 2022
2 parents 2ea1688 + c52f927 commit 072b848
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
8 changes: 8 additions & 0 deletions src/components/About.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Button, Card, Icon, List, Modal } from 'semantic-ui-react'
import Credits from './Credits'
import DescriptionItem from './DescriptionItem'
import { DescriptionTypes, Ticker } from '../lib/types'
import { getAtomFeedUrl, getRssFeedUrl } from '../lib/api'

interface Props {
ticker: Ticker
Expand Down Expand Up @@ -49,6 +50,13 @@ const About: FC<Props> = props => {
type={DescriptionTypes.Telegram}
/>
)}
<List.Item>
<List.Icon name="feed" />
<List.Content>
<a href={getAtomFeedUrl()}>Atom</a> |{' '}
<a href={getRssFeedUrl()}>RSS</a>
</List.Content>
</List.Item>
</List>
)

Expand Down
18 changes: 13 additions & 5 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Message, Settings, Ticker } from './types'

const apiUrl = process.env.REACT_APP_API_URL
export const ApiUrl = process.env.REACT_APP_API_URL

type InitResponseData = {
settings: Settings
Expand Down Expand Up @@ -32,7 +32,7 @@ async function get<T>(path: string): Promise<T> {
}

export async function getInit(): Promise<InitResponse> {
return get(`${apiUrl}/init`)
return get(`${ApiUrl}/init`)
}

export type TimelineOpts = {
Expand All @@ -44,12 +44,20 @@ export async function getTimeline(
opts: TimelineOpts
): Promise<TimelineResponse> {
if (opts.after != null) {
return get(`${apiUrl}/timeline?after=${opts.after}`)
return get(`${ApiUrl}/timeline?after=${opts.after}`)
}

if (opts.before != null) {
return get(`${apiUrl}/timeline?before=${opts.before}`)
return get(`${ApiUrl}/timeline?before=${opts.before}`)
}

return get(`${apiUrl}/timeline`)
return get(`${ApiUrl}/timeline`)
}

export function getAtomFeedUrl(): string {
return `${ApiUrl}/feed?origin=${window.location.hostname}&format=atom`
}

export function getRssFeedUrl(): string {
return `${ApiUrl}/feed?origin=${window.location.hostname}&format=rss`
}

0 comments on commit 072b848

Please sign in to comment.