mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-19 04:49:37 +02:00
22 lines
665 B
TypeScript
22 lines
665 B
TypeScript
|
import inspirationalQuotes from './json/quotes.json';
|
||
|
|
||
|
export function getRandomQuote() {
|
||
|
const quotes = inspirationalQuotes.quotes;
|
||
|
const randomIndex = Math.floor(Math.random() * quotes.length);
|
||
|
let quoteString = quotes[randomIndex].quote;
|
||
|
let authorString = quotes[randomIndex].author;
|
||
|
return '"' + quoteString + '" - ' + authorString;
|
||
|
}
|
||
|
|
||
|
export function getFlag(size: number, country: string) {
|
||
|
return `https://flagcdn.com/h${size}/${country}.png`;
|
||
|
}
|
||
|
|
||
|
export function checkLink(link: string) {
|
||
|
if (link.startsWith('http://') || (link.startsWith('https://') && link.indexOf('.') !== -1)) {
|
||
|
return link;
|
||
|
} else {
|
||
|
return 'http://' + link + '.com';
|
||
|
}
|
||
|
}
|