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
game-article.js 2.73 KiB
Newer Older
peter_rabbit's avatar
peter_rabbit committed
"use strict";

Pierre Jarriges's avatar
Pierre Jarriges committed
const { images_url } = require("../../../../../admin-frontend/src/constants");
peter_rabbit's avatar
peter_rabbit committed
const ImageCarousel = require("../../../generic-components/image-carousel");
peter_rabbit's avatar
peter_rabbit committed
const { getArticleBody } = require("../../../lib/article-utils");
peter_rabbit's avatar
peter_rabbit committed

class GameArticle {
    constructor(props) {
        this.props = props;
    }

    render() {
peter_rabbit's avatar
peter_rabbit committed
        const {
            title,
            subtitle,
Pierre Jarriges's avatar
Pierre Jarriges committed
            body,
peter_rabbit's avatar
peter_rabbit committed
            images,
Pierre Jarriges's avatar
Pierre Jarriges committed
            details,
peter_rabbit's avatar
peter_rabbit committed
        } = this.props;
peter_rabbit's avatar
peter_rabbit committed
        return {
            tag: "article",
            typeof: "VideoGame",
            additionalType: "Article",
peter_rabbit's avatar
peter_rabbit committed
            class: "game-article",
            contents: [
                {
                    tag: "h2",
                    property: "name",
peter_rabbit's avatar
peter_rabbit committed
                    class: "game-title",
                    contents: title,
                },
peter_rabbit's avatar
peter_rabbit committed
                {
                    tag: "div",
                    class: "game-banner",
                    contents: [
Pierre Jarriges's avatar
Pierre Jarriges committed
                        { tag: "img", class: "pixelated", src: `${images_url}/${images[0]}` },
peter_rabbit's avatar
peter_rabbit committed
                    ],
                },
peter_rabbit's avatar
peter_rabbit committed
                {
                    tag: "h3",
                    class: "game-subtitle",
                    contents: subtitle,
                    property: "alternativeHeadline",
peter_rabbit's avatar
peter_rabbit committed
                },
                {
                    tag: "div",
                    class: "game-description",
                    property: "description",
peter_rabbit's avatar
peter_rabbit committed
                    contents: getArticleBody(body),
                },
Pierre Jarriges's avatar
Pierre Jarriges committed
                new ImageCarousel({ images: images.map(img => `${images_url}/${img}`) }).render(),
                details.length > 0 && {
peter_rabbit's avatar
peter_rabbit committed
                    tag: "div",
Pierre Jarriges's avatar
Pierre Jarriges committed
                    class: "article-details",
peter_rabbit's avatar
peter_rabbit committed
                    contents: [
                        {
                            tag: "h2",
Pierre Jarriges's avatar
Pierre Jarriges committed
                            contents: "Details",
peter_rabbit's avatar
peter_rabbit committed
                        },
                        {
Pierre Jarriges's avatar
Pierre Jarriges committed
                            tag: "ul",
                            class: "details-list",
                            contents: details.map(detail => {
                                return {
                                    tag: "li",
                                    class: "detail",
                                    contents: [
                                        { tag: "label", contents: detail.label },
                                        {
                                            tag: "div",
                                            contents: detail.value
                                        },
                                    ],
                                };
                            }),
peter_rabbit's avatar
peter_rabbit committed
                        },
                    ],
                },
            ],
        };
    }
}

module.exports = GameArticle;