You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

40 lines
1.2 KiB

import { getMoscowTime, getRandomItem, getRandomNumber } from './utils';
import taglines from './taglines.json';
import { UserService } from './services';
const getCurrentUsername = () =>
typeof UserService.Instance.user !== 'undefined'
? UserService.Instance.user.name
: 'Someone'; // Default if the user is not logged in.
/**
* Special functionality is wrapped in brackets.
* A full list of tagline codes:
*
* <MOSCOW_TIME> - The current time in the capital city of Russia.
* <RANDOM:20:100> - A random number between 20 and 100, inclusive.
* <USERNAME> - The current user.
*/
/**
* Produces a tagline for the subtitle of the page.
* @param {string} tagline The raw tagline to modify.
* @returns {string} The tagline as a modified markdown string.
*/
export const generateFullTagline = (tagline: string): string =>
tagline
/*
.replace(
/<COMM:(.+?)>/,
(_value, comm) => `[/c/${comm}](/c/${comm})`
)
*/
.replace('<MOSCOW_TIME>', getMoscowTime())
.replace('<CURRENT_USER>', getCurrentUsername())
.replace(
/<RANDOM:(\d+):(\d+)>/,
(_value, min, max) => `${getRandomNumber(min, max)}`
);
export const getRandomRawTagline = (): string => getRandomItem(taglines);