Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
article-utils.js 460 B
Newer Older
peter_rabbit's avatar
peter_rabbit committed
"use strict";

Pierre Jarriges's avatar
Pierre Jarriges committed
const { fetch_json_or_error_text } = require("./fetch");
peter_rabbit's avatar
peter_rabbit committed

function getArticleBody(text) {
    return text.replaceAll("\n", "<br/>");
peter_rabbit's avatar
peter_rabbit committed
}

function getArticleDate(date) {
    return `${date.getDate()}-${date.getMonth() + 1}-${date.getFullYear()}`;
}

Pierre Jarriges's avatar
Pierre Jarriges committed
function loadArticles(category, locale) {
    return fetch_json_or_error_text(`/articles/${category}/${locale}`);
peter_rabbit's avatar
peter_rabbit committed
}

module.exports = {
    loadArticles,
    getArticleBody,
    getArticleDate,
};