web/src/utils/fetch-data.ts

17 lines · 552 bytes

 1
 2import yaml from 'js-yaml';
 3
 4import type { AwesomePrivacy } from '../types/Service';
 5
 6const awesomePrivacyData = 'https://raw.githubusercontent.com/Lissy93/awesome-privacy/main/awesome-privacy.yml';
 7
 8export const fetchData = async (): Promise<AwesomePrivacy> => {
 9  return await fetch(awesomePrivacyData)
10    .then((res) => res.text())
11    .then((data) => yaml.load(data))
12    .catch((err) => console.error('ah crap', err)) as AwesomePrivacy;
13}
14
15export const slugify = (title: string) => {
16  return (title || '').toLowerCase().replace(/\s/g, '-');
17};