diff --git a/routes/index.js b/routes/index.js index 8199a92..5d23c44 100644 --- a/routes/index.js +++ b/routes/index.js @@ -1,8 +1,47 @@ -const express = require("express"); +const express = require('express'); const router = express.Router(); +const fetch = require('node-fetch'); -router.get("/", function (req, res, next) { - res.render("index", { title: "Fed Pug Boilerplate with Express" }); -}); +const requestOptions = { + method: 'GET', + redirect: 'follow' +} -module.exports = router; +let heroSection = null +let appsSection = null; + +const heroSectionContent = fetch('https://express-api.victorneves.dev/hero_section/read.php', requestOptions) + .then((resp) => resp.json()) + .then((res) => { + return res + }) + .catch((error) => console.log(JSON.stringify(error))); + + heroSectionContent.then(function (res) { + heroSection = res.records[0]; + }); + +const appsSectionContent = fetch('https://express-api.victorneves.dev/apps_section/read.php', requestOptions) + .then((resp) => resp.json()) + .then((res) => { + const obj = { + title: res.records[0].title, + text: { + __class: res.records[0].text_css, + text: res.records[0].text, + }, + } + + return obj + }) + .catch((error) => console.log(JSON.stringify(error))); + + appsSectionContent.then(function (res) { + appsSection = res; + }); + + router.get("/", function (req, res, next) { + res.render("index", { heroSection, appsSection }); + }) + +module.exports = router diff --git a/views/index.pug b/views/index.pug index 0e80872..fb3884e 100644 --- a/views/index.pug +++ b/views/index.pug @@ -12,8 +12,8 @@ block content section.section.section--hero .section__inner.section__inner--row .section__content.section__content--left - +sectionTitle('Track your shows automatically', 'section__title--hero') - +sectionText('With ShowTrackr you can track your favorite TV shows automatically, so you never loose track of your TV shows ever again') + +sectionTitle(heroSection.title, heroSection.modifier_css) + +sectionText(heroSection.text) form.newsletter .newsletter__inner +form({ @@ -62,7 +62,7 @@ block content altText: 'Synology' } ]) - +heroImage('App mockup', 'images/mockup-app-iphone-x.png', 'section__img') + +heroImage(heroSection.alt_text, `images/${heroSection.image}`, heroSection.image_css) section.section.section--features .section__inner.section__inner--features @@ -137,8 +137,8 @@ block content section.section.section--apps .section__inner.section__inner--row .section__content.section__content--left - +sectionTitle('Easy-to-use interfaces on every platform') - +text({__class: 'section__text', text: 'Since most of our features work in a completely automated way, you will mainly use our apps to discover new TV shows recommended for you and discuss the most interesting episodes with like-minded people.'}) + +sectionTitle(appsSection.title) + +text(appsSection.text) +interfaceTabs([ { input: {