Netlify build fail for Gatsby site - deployment

I am trying to deploy my first gatsby site, with a blog but it keeps failing. Ive updated all my dependancies but now I cant figure out what exactly is the issue.
I would really appreciate any advice, its been bugging me for days. Before this, I got a bunch of npm errors so I updated all the dependancies which I thought would do the trick.
FYI Im using contentful cms for the blog
It looks like the build failed here:
12:33:55 PM: error A page component must export a React component for it to be valid. Please make sure this file exports a React component:
12:33:55 PM: /opt/build/repo/src/pages/BlogElements.js
12:33:55 PM: not finished createPagesStatefully - 0.064s
12:33:55 PM: npm ERR! code ELIFECYCLE
12:33:55 PM: npm ERR! errno 1
12:33:55 PM: npm ERR! gatsby-starter-hello-world#0.1.0 build: `gatsby build`
12:33:55 PM: npm ERR! Exit status 1
12:33:55 PM: npm ERR!
12:33:55 PM: npm ERR! Failed at the gatsby-starter-hello-world#0.1.0 build script.
12:33:55 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:33:55 PM: npm ERR! A complete log of this run can be found in:
12:33:55 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-01-02T12_33_55_072Z-debug.log
The BlogElements.js file is just a styled component:
import styled from 'styled-components';
export const Styledh2 = styled.h2`
color: purple;
`;
export const StyledBox = styled.li`
width: 500px;
background-color: lightblue;
float: left
`
export const StyledLink = styled.div`
background-color: yellow;
position: relative;
left: 3rem;
justify-content: space-around
`

Your issue comes because BlogElements is stored under /pages folder so Gatsby is trying to create URL paths based on that folder structure. Since you are not returning a valid React component, your code is breaking.
If you are using BlogElements only for styling purpose, move it to another location (for example, under /src/components/styles) and import it wherever you need.
A valid styled-component under /pages should look like this:
import React from "react"
import styled from "styled-components"
const Container = styled.div`
margin: 3rem auto;
max-width: 600px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
`
const UserWrapper = styled.div`
display: flex;
align-items: center;
margin: 0 auto 12px auto;
&:last-child {
margin-bottom: 0;
}
`
const Avatar = styled.img`
flex: 0 0 96px;
width: 96px;
height: 96px;
margin: 0;
`
const Description = styled.div`
flex: 1;
margin-left: 18px;
padding: 12px;
`
const Username = styled.h2`
margin: 0 0 12px 0;
padding: 0;
`
const Excerpt = styled.p`
margin: 0;
`
const User = props => (
<UserWrapper>
<Avatar src={props.avatar} alt="" />
<Description>
<Username>{props.username}</Username>
<Excerpt>{props.excerpt}</Excerpt>
</Description>
</UserWrapper>
)
export default function UsersList() {
return (
<Container>
<h1>About Styled Components</h1>
<p>Styled Components is cool</p>
<User
username="Jane Doe"
avatar="https://s3.amazonaws.com/uifaces/faces/twitter/adellecharles/128.jpg"
excerpt="I'm Jane Doe. Lorem ipsum dolor sit amet, consectetur adipisicing elit."
/>
<User
username="Bob Smith"
avatar="https://s3.amazonaws.com/uifaces/faces/twitter/vladarbatov/128.jpg"
excerpt="I'm Bob smith, a vertically aligned type of guy. Lorem ipsum dolor sit amet, consectetur adipisicing elit."
/>
</Container>
)
}
Note that the sample snippet above is exporting a UsersList as a React component unlike your BlogElements.
Try to build your project locally before pushing it to Netlify to avoid that errors.

Related

Error when compiling Sass in Visual Studio Code

I'm trying to follow some YT tutorial about Bootstrap 5 with the use of some tools like Sass.
Author of this video in his example at the beginning is testing if his script for compiling Sass code is working.
Here's the screenshot of his work:
screenshot 1
I tried to do the same thing and I got an error saying:
Error: Sass variables aren't allowed in plain CSS.
Here's my code:
$primary: #ff0000;
.test-1 {
color: $primary;
}
And the screenshot: screenshot 2
This showed up after compiling my script:
/* Error: Sass variables aren't allowed in plain CSS.
* ,
* 1 | $primary: #ff0000;
* | ^^^^^^^^
* '
* scss/style.css 1:1 root stylesheet */
body::before {
font-family: "Source Code Pro", "SF Mono", Monaco, Inconsolata, "Fira Mono",
"Droid Sans Mono", monospace, monospace;
white-space: pre;
display: block;
padding: 1em;
margin-bottom: 1em;
border-bottom: 2px solid black;
content: "Error: Sass variables aren't allowed in plain CSS.\a \2577 \a 1 \2502 $primary: #ff0000;\a \2502 ^^^^^^^^\a \2575 \a scss/style.css 1:1 root stylesheet";
}
Screenshot of terminal
I think that my code looks the same as his, so where is the problem? Had some rules of Sass had changed since the video was posted?
Here is my info from package.json:
"sass": "^1.45.2"
},
"dependencies": {
"#fortawesome/fontawesome-free": "^5.15.4",
"autoprefixer": "^10.4.1",
"bootstrap": "^5.1.3",
"postcss": "^8.4.5",
"postcss-cli": "^9.1.0"
And his:
"sass": "^1.32.12"
},
"dependencies": {
"#fortawesome/fontawesome-free": "^5.15.3",
"autoprefixer": "^10.2.5",
"bootstrap": "^5.0.0",
"postcss-cli": "^8.3.1"
What is your file extension? It should be .scss. => my-style.scss

How to style a select element generated by simple_form in sass format?

I have this simple_form:
.reveal.doubt id="doubt-material-#{material.id}" data-reveal=true
button.close-button data-close=true aria-label="Close reveal" type="button"
span aria-hidden="false" ×
h5 #{t 'students.materials.index.questions.button'}
p #{t 'students.materials.index.questions.form_explanation'}
= simple_form_for [:student, trail, component, material, material_student, doubt], html: {id: "doubt" }, remote: true do |f|
= f.input :recipient, collection: [['contato#witseed.com','Atendimento a cliente'],['tec#witseed.com','Suporte técnico']],value_method: :first, label_method: :second, label: "#{t 'students.materials.index.questions.form_send_email'}", include_blank: "#{t 'students.materials.index.questions.form_blank_line'}", required: true, input_html: {class: 'custom_select'}
= f.input :question, as: :text, label: true, label: "#{t 'students.materials.index.questions.form_message'}" , input_html: { rows: "2" }
= f.submit "#{t 'students.materials.index.questions.form_send_button'}", class: 'button primary-button-active'
It generates the html below:
Which generates the form below:
Now I want to style the dropdown but I am failing with finding in the code the select element. At inspect it is very clear to me where it is.
I have tried to add:
.input
position: relative
select
background-color: white
&#doubt_recipient
border: 2px solid red
padding: 5px
But failed.
Does anyone have any suggestion ? Thank you very much.
It was actually a matter of just running the line below in terminal:
bundle exec rake assets:precompile
And CSS style rendered.
Finally I have just added style at the id:
#doubt_recipient
border: 2px solid red
padding: 5px
background-color: white

Can not import font into mjml

mj-font does not work in mjml.
Here is what I am trying to do in index.mjml:
<mjml>
<mj-head>
<mj-font name="testFont" href="testFont.ttf"/>
</mj-head>
<mj-body>
<mj-section>
<mj-column>
<mj-text font-family="testFont" align="center" font-size="20px">
Just a text
</mj-text>
</mj-column>
</mj-section>
</mj-body>
</mjml>
Here is the screenshot of the project directory:
Here is what I see in the app:
And here is what the font should look like:
What am I missing here and how could I make my font work?
Thank you.
I have found it difficult to use custom fonts using the mj-font tag. If you use a google font api it seems to work correctly.
Example using Google font
<mj-font name="Raleway" href="https://fonts.googleapis.com/css?family=Raleway" />
Taking that into consideration, I have started to using the following and has worked for me: (it goes between <mj-style></mj-style> tags)
#font-face {
font-family: testFont;
src: url(https://cdn2.hubspot.net/hubfs/199900/fonts/someFontFile.ttf)
format('truetype');
}
I would normally use a .woff file instead of a .ttf file.
Diving deeper into it, if you go to a Google font link such as https://fonts.googleapis.com/css?family=Raleway in your web browser, the contents of the file is this:
/* latin-ext */
#font-face {
font-family: 'Raleway';
font-style: normal;
font-weight: 400;
src: local('Raleway'), local('Raleway-Regular'), url(https://fonts.gstatic.com/s/raleway/v13/1Ptug8zYS_SKggPNyCMIT4ttDfCmxA.woff2) format('woff2');
unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
#font-face {
font-family: 'Raleway';
font-style: normal;
font-weight: 400;
src: local('Raleway'), local('Raleway-Regular'), url(https://fonts.gstatic.com/s/raleway/v13/1Ptug8zYS_SKggPNyC0IT4ttDfA.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
Back to your problem... Since the file that you are loading with the <mj-font> tag is a binary file, I would imagine that mjml doesn't know how to process it. If the file were a .woff font file then it might work. Perhaps they could change this in the near future. After all, it is a very useful tool.

MapBox geojson data not displaying with certain "Styles"

I can get my data from a geojson file in my site's directory to display my data on default Mapbox style (v9 dark etc...) But for some reason it just shows no data on my custom styled maps (only certain ones)...
Confused.
I have the following code:
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title>Major Civil War Battles</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.mapbox.com/mapbox-gl-js/v0.44.1/mapbox-gl.js'></script>
<link href='https://api.mapbox.com/mapbox-gl-js/v0.44.1/mapbox-gl.css' rel='stylesheet' />
<style>
body {
margin: 0;
padding: 0;
font-family: 'Helvetica Neue', Helvetica, Arial, Sans-serif;
}
#map {
position: absolute;
top: 0;
bottom: 0;
width: 100%;
}
h1 {
font-size: 20px;
line-height: 30px;
}
h2 {
font-size: 14px;
line-height: 20px;
margin-bottom: 10px;
}
a {
text-decoration: none;
color: #2dc4b2;
}
#console {
position: absolute;
width: 240px;
margin: 10px;
padding: 10px 20px;
background-color: white;
}
</style>
</head>
<body>
<div id='map'></div>
<div id='console'>
<h1>Major Battles of The Civil War (1861-1865)</h1>
<p></p>
<div class='session' id='sliderbar'>
<h2>Year: <label id='active-year'>1861</label></h2>
<input id='slider' class='row' type='range' min='1861' max='1865' step='1' value='1861' />
</div>
</div>
</body>
<script>
mapboxgl.accessToken = 'pk.eyJ1IjoiY2dyb3RoIiwiYSI6ImNqZzlramN2Mzh0c3Uyd252cWxzYnF3c2UifQ.5lpaHuwMqJ5EsTARqW5kHg';
var map = new mapboxgl.Map({
container: 'map', // container element id
//mapbox://styles/mapbox/light-v9
//mapbox://styles/cgroth/cjgl5x6c400002qnkl94ab1yc
style: 'mapbox://styles/cgroth/cjgl5x6c400002qnkl94ab1yc',
center: [-77.04, 38.907],
zoom: 5
});
map.on('load', function() {
map.addLayer({
id: 'battledata',
type: 'circle',
source: {
type: 'geojson',
data: './CWGG.geojson' // replace this with the url of your own geojson
},
paint: {
'circle-radius': [
'interpolate',
['linear'],
['number', ['get', 'TotalCasualties']],
1, 2,
51000, 40
],
'circle-color':'#AA5E79',
'circle-opacity': 0.8
}
}, 'admin-2-boundaries-dispute');
document.getElementById('slider').addEventListener('input', function(e) {
var year = parseInt(e.target.value);
// update the map
map.setFilter('battledata', ['==', ['number', ['get', 'Year']], year]);
// update text in the UI
document.getElementById('active-year').innerText = year
});
});
</script>
If I run the exact same code with a default Mapbox "Style" my data displays perfectly. I insert my style code and nothing appears.
Here are the console errors when I try to run the HTML:
rror: Layer with id "admin-2-boundaries-dispute" does not exist on this map.
at r.addLayer (style.js:542)
at e.addLayer (map.js:1125)
at e.<anonymous> (AA_WorkingCW.html:85)
at e.Evented.fire (evented.js:93)
at r.Evented.fire (evented.js:103)
at r._load (style.js:226)
at style.js:164
at XMLHttpRequest.r.onload (ajax.js:76)
Evented.fire # evented.js:109
favicon.ico Failed to load resource: the server responded with a status of 404 (Not Found)
a.tiles.mapbox.com/v4/mapbox.terrain-rgb/6/19/25.webp?access_token=pk.eyJ1IjoiY2dyb3RoIiwiYSI6ImNqZ2w4bWY5dTFueG0zM2w0dTNkazI1aWEifQ.55SWFVBYzs08EqJHAa3AsQ Failed to load resource: the server responded with a status of 404 (Not Found)
a.tiles.mapbox.com/v4/mapbox.terrain-rgb/6/20/24.webp?access_token=pk.eyJ1IjoiY2dyb3RoIiwiYSI6ImNqZ2w4bWY5dTFueG0zM2w0dTNkazI1aWEifQ.55SWFVBYzs08EqJHAa3AsQ Failed to load resource: the server responded with a status of 404 (Not Found)
b.tiles.mapbox.com/v4/mapbox.terrain-rgb/6/19/26.webp?access_token=pk.eyJ1IjoiY2dyb3RoIiwiYSI6ImNqZ2w4bWY5dTFueG0zM2w0dTNkazI1aWEifQ.55SWFVBYzs08EqJHAa3AsQ Failed to load resource: the server responded with a status of 404 (Not Found)
a.tiles.mapbox.com/v4/mapbox.terrain-rgb/6/20/26.webp?access_token=pk.eyJ1IjoiY2dyb3RoIiwiYSI6ImNqZ2w4bWY5dTFueG0zM2w0dTNkazI1aWEifQ.55SWFVBYzs08EqJHAa3AsQ Failed to load resource: the server responded with a status of 404 (Not Found)
5evented.js:109 Error: The layer 'battledata' does not exist in the map's style and cannot be filtered.
at r.setFilter (style.js:681)
at e.setFilter (map.js:1185)
at HTMLInputElement.<anonymous> (AA_WorkingCW.html:107)
Evented.fire # evented.js:109
ajax.js:106 GET https://a.tiles.mapbox.com/v4/mapbox.terrain-rgb/6/20/24.webp?access_token=pk.eyJ1IjoiY2dyb3RoIiwiYSI6ImNqZ2w4bWY5dTFueG0zM2w0dTNkazI1aWEifQ.55SWFVBYzs08EqJHAa3AsQ 404 (Not Found)
exports.getArrayBuffer # ajax.js:106
exports.getImage # ajax.js:121
r.loadTile # raster_dem_tile_source.js:37
t._loadTile # source_cache.js:144
t._addTile # source_cache.js:584
t._updateRetainedTiles # source_cache.js:489
t.update # source_cache.js:435
r._updateSources # style.js:943
e._render # map.js:1499
(anonymous) # map.js:1567
requestAnimationFrame (async)
frame # browser.js:30
e._rerender # map.js:1565
e._update # map.js:1450
Evented.fire # evented.js:93
e.resize # map.js:408
e._onWindowResize # map.js:1578
ajax.js:106 GET https://a.tiles.mapbox.com/v4/mapbox.terrain-rgb/6/20/26.webp?access_token=pk.eyJ1IjoiY2dyb3RoIiwiYSI6ImNqZ2w4bWY5dTFueG0zM2w0dTNkazI1aWEifQ.55SWFVBYzs08EqJHAa3AsQ 404 (Not Found)
exports.getArrayBuffer # ajax.js:106
exports.getImage # ajax.js:121
r.loadTile # raster_dem_tile_source.js:37
t._loadTile # source_cache.js:144
t._addTile # source_cache.js:584
t._updateRetainedTiles # source_cache.js:489
t.update # source_cache.js:435
r._updateSources # style.js:943
e._render # map.js:1499
(anonymous) # map.js:1567
requestAnimationFrame (async)
frame # browser.js:30
e._rerender # map.js:1565
e._update # map.js:1450
Evented.fire # evented.js:93
e.resize # map.js:408
e._onWindowResize # map.js:1578
ajax.js:106 GET https://b.tiles.mapbox.com/v4/mapbox.terrain-rgb/6/21/26.webp?access_token=pk.eyJ1IjoiY2dyb3RoIiwiYSI6ImNqZ2w4bWY5dTFueG0zM2w0dTNkazI1aWEifQ.55SWFVBYzs08EqJHAa3AsQ 404 (Not Found)
exports.getArrayBuffer # ajax.js:106
exports.getImage # ajax.js:121
r.loadTile # raster_dem_tile_source.js:37
t._loadTile # source_cache.js:144
t._addTile # source_cache.js:584
t._updateRetainedTiles # source_cache.js:489
t.update # source_cache.js:435
r._updateSources # style.js:943
e._render # map.js:1499
(anonymous) # map.js:1567
requestAnimationFrame (async)
frame # browser.js:30
e._rerender # map.js:1565
e._update # map.js:1450
Evented.fire # evented.js:93
e.resize # map.js:408
e._onWindowResize # map.js:1578
ajax.js:106 GET https://a.tiles.mapbox.com/v4/mapbox.terrain-rgb/6/21/25.webp?access_token=pk.eyJ1IjoiY2dyb3RoIiwiYSI6ImNqZ2w4bWY5dTFueG0zM2w0dTNkazI1aWEifQ.55SWFVBYzs08EqJHAa3AsQ 404 (Not Found)
exports.getArrayBuffer # ajax.js:106
exports.getImage # ajax.js:121
r.loadTile # raster_dem_tile_source.js:37
t._loadTile # source_cache.js:144
t._addTile # source_cache.js:584
t._updateRetainedTiles # source_cache.js:489
t.update # source_cache.js:435
r._updateSources # style.js:943
e._render # map.js:1499
(anonymous) # map.js:1567
requestAnimationFrame (async)
frame # browser.js:30
e._rerender # map.js:1565
e._update # map.js:1450
Evented.fire # evented.js:93
e.resize # map.js:408
e._onWindowResize # map.js:1578
ajax.js:106 GET https://b.tiles.mapbox.com/v4/mapbox.terrain-rgb/6/21/24.webp?access_token=pk.eyJ1IjoiY2dyb3RoIiwiYSI6ImNqZ2w4bWY5dTFueG0zM2w0dTNkazI1aWEifQ.55SWFVBYzs08EqJHAa3AsQ 404 (Not Found)
Layer with id "admin-2-boundaries-dispute" does not exist on this map.
This error is telling you that you're trying to insert your new layer before a layer which doesn't exist. Presumably it exists in the dark layer, but not in your custom layer. Mapbox-GL-JS recently changed so that inserting a layer before a non-existent layer fails completely - it does not get added.

Polymer 1.0 Is there any ready made chart element?

I want to add a pie chart in my Polymer 1.0 application. I used chart-elements with Polymer 0.5, but when migrated to 1.0 it stopped working!
I did not find anything for 1.0 yet. Does 1.0 at all has a ready made chart element? Seeking for expert help.
Thanks in advance.
EDIT
According to Ben's suggestion I tried with google-chart component and this is what I did. But the chart is not rendering.
Step 1: I installed google-chart by using bower install --save GoogleWebComponents/google-chart
Step 2: Created a custom element using yo polymer:el custom-pie-chart which looks like this:
<dom-module id="custom-pie-chart">
<style>
:host
{
display: -webkit-flex;
display: -ms-flex;
display: flex;
margin: 0;
padding: 0;
width: 400px;
height: 300px;
}
#chartdiv
{
width: 100%;
}
google-chart
{
height: 300px;
width: 50em;
}
</style>
<template>
<link rel="stylesheet" href="custom-pie-chart.css">
<div id="chartdiv">
<google-chart
type='pie'
options='{"title": "Distribution of days in 2001Q1"}'
cols='[{"label":"Month", "type":"string"}, {"label":"Days", "type":"number"}]'
rows='[["Jan", 31],["Feb", 28],["Mar", 31]]'>
</google-chart>
</div>
</template>
</dom-module>
<script>
(function () {
Polymer({
is: 'custom-pie-chart',
ready: function () {
}
});
})();
</script>
Step 3: Added references of google-chart and my custom element custom-pie-chart in elements.html
Step 4: Added custom-pie-chart in my index.html as follows:
<post-card id="sales-info" title="Points from customer">
<custom-pie-chart></custom-pie-chart>
</post-card>
But chart is not rendering. Area comes blank like this:
NB: I am also getting the following error on console (Chrome)
Uncaught (in promise) TypeError: Request method 'POST' is unsupported
at TypeError (native)
at http://localhost:3000/bower_components/sw-toolbox/sw-toolbox.js:20:430
I removed all references of google-chart to check whether this is responsible. But it still comes up.
What wrong I am doing? Please help!
This causes the error:
rows='[["Jan", 31],["Feb", 28],["Mar", 31]]'
because Polymer only recognizes rows='[[...]]' and thinks it is a data binding. Two spaces should solve the problem:
rows='[ ["Jan", 31],["Feb", 28],["Mar", 31] ]'