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 3.88 KiB
Newer Older
  • Learn to ignore specific revisions
  • peter_rabbit's avatar
    peter_rabbit committed
    "use strict";
    
    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 TeamMember {
        constructor(props) {
            this.props = props;
        }
    
        render() {
            const { title, subtitle, body, images, path } = this.props;
            return {
                tag: "div",
                class: "team-member",
    
                typeof: "Person",
                property: "author",
    
    peter_rabbit's avatar
    peter_rabbit committed
                contents: [
                    {
                        tag: "div",
                        class: "team-member-img",
    
    peter_rabbit's avatar
    peter_rabbit committed
                        contents: [
                            {
                                tag: "img",
                                alt: `ìmage team member ${title}`,
                                src: images.map(im => `${path}/images/${im}`)[0],
    
                                property: "image",
    
    peter_rabbit's avatar
    peter_rabbit committed
                            },
                        ],
    
    peter_rabbit's avatar
    peter_rabbit committed
                    },
                    {
                        tag: "h3",
                        class: "team-member-title",
                        contents: title,
    
                        property: "name",
    
    peter_rabbit's avatar
    peter_rabbit committed
                    },
                    {
                        tag: "strong",
                        class: "team-member-subtitle",
                        contents: subtitle,
    
                        property: "jobTitle",
    
    peter_rabbit's avatar
    peter_rabbit committed
                    },
                    {
                        tag: "p",
                        class: "team-member-body",
                        contents: getArticleBody(body),
    
                        property: "description",
    
    peter_rabbit's avatar
    peter_rabbit committed
                    },
                ],
            };
        }
    }
    
    class GameArticle {
        constructor(props) {
            this.props = props;
        }
    
        render() {
    
    peter_rabbit's avatar
    peter_rabbit committed
            const {
                title,
                tags,
                body,
                subtitle,
                images,
                path,
                team_subarticles,
                image_banner,
            } = 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: [
                            { tag: "img", class: "pixelated", src: `${path}/images/${image_banner}` },
                        ],
                    },
    
    peter_rabbit's avatar
    peter_rabbit committed
                    {
                        tag: "div",
    
    peter_rabbit's avatar
    peter_rabbit committed
                        class: "game-tags",
                        contents: tags.map(tag => {
    
                            return { tag: "span", contents: tag, property: "about" };
    
    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),
                    },
                    new ImageCarousel({ images: images.map(img => `${path}/images/${img}`) }).render(),
                    {
                        tag: "div",
                        class: "game-team",
                        contents: [
                            {
                                tag: "h2",
                                contents: "L'équipe",
                            },
                            {
                                tag: "div",
                                class: "team-members",
                                contents: team_subarticles.map(tsa =>
                                    new TeamMember({ ...tsa }).render()
                                ),
                            },
                        ],
                    },
                ],
            };
        }
    }
    
    module.exports = GameArticle;