Add template for custom 404 page

This commit is contained in:
rylim 2021-10-24 16:58:11 -07:00
parent 44f45af57b
commit e96eda0c91
3 changed files with 162 additions and 1 deletions

View file

@ -220,6 +220,9 @@ async function buildSite() {
}, {
url: copyAssetToBuild( 'companies-table.js' ),
} ];
const notFoundStyles = [ {
url: copyAssetToBuild( '404.css' )
} ];
// Copy favicon files
console.log( 'Copying favicon files' );
@ -282,7 +285,13 @@ async function buildSite() {
// Generate custom 404 page
console.log();
console.log( 'Writing custom 404 page' );
writePage( '404.html', '<html><h1>Test Custom 404</h1></html>' );
const notFoundTemplate = swig.compileFile(
path.join( sitePath, 'templates', '404.html' )
);
// writePage( '404.html', '<html><h1>Test Custom 404</h1></html>' );
writePage( '404.html', notFoundTemplate( {
notFoundStyles
} ) );
console.log();
console.log( 'Site files are ready in "site/build/"' );

111
site/assets/404.css Normal file
View file

@ -0,0 +1,111 @@
* {
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
body {
padding: 0;
margin: 0;
}
#notfound {
position: relative;
height: 100vh;
}
#notfound .notfound {
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.notfound {
max-width: 520px;
width: 100%;
line-height: 1.4;
text-align: center;
}
.notfound .notfound-404 {
position: relative;
height: 200px;
margin: 0px auto 20px;
z-index: -1;
}
.notfound .notfound-404 h1 {
font-family: 'Montserrat', sans-serif;
font-size: 236px;
font-weight: 200;
margin: 0px;
color: #211b19;
text-transform: uppercase;
position: absolute;
left: 50%;
top: 50%;
-webkit-transform: translate(-50%, -50%);
-ms-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
.notfound .notfound-404 h2 {
font-family: 'Montserrat', sans-serif;
font-size: 28px;
font-weight: 400;
text-transform: uppercase;
color: #211b19;
background: #fff;
padding: 10px 5px;
margin: auto;
display: inline-block;
position: absolute;
bottom: 0px;
left: 0;
right: 0;
}
.notfound a {
font-family: 'Montserrat', sans-serif;
display: inline-block;
font-weight: 700;
text-decoration: none;
color: #fff;
text-transform: uppercase;
padding: 13px 23px;
background: #ff6300;
font-size: 18px;
-webkit-transition: 0.2s all;
transition: 0.2s all;
}
.notfound a:hover {
color: #ff6300;
background: #211b19;
}
@media only screen and (max-width: 767px) {
.notfound .notfound-404 h1 {
font-size: 148px;
}
}
@media only screen and (max-width: 480px) {
.notfound .notfound-404 {
height: 148px;
margin: 0px auto 10px;
}
.notfound .notfound-404 h1 {
font-size: 86px;
}
.notfound .notfound-404 h2 {
font-size: 16px;
}
.notfound a {
padding: 7px 15px;
font-size: 14px;
}
}

41
site/templates/404.html Normal file
View file

@ -0,0 +1,41 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
<title>404 HTML Template by Colorlib</title>
<!-- Google font -->
<link href="https://fonts.googleapis.com/css?family=Montserrat:200,400,700" rel="stylesheet">
<!-- Custom stlylesheet -->
<link type="text/css" rel="stylesheet" href="../assets/404.css" />
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<div id="notfound">
<div class="notfound">
<div class="notfound-404">
<h1>Oops!</h1>
<h2>404 - The Page can't be found</h2>
</div>
<a href="#">Go TO Homepage</a>
</div>
</div>
</body><!-- This templates was made by Colorlib (https://colorlib.com) -->
</html>