404 page, robots- and security.txt

This commit is contained in:
Martin Berg Alstad 2022-12-23 14:57:53 +01:00
parent 91efb8e14e
commit 79887d55ba
11 changed files with 93 additions and 3 deletions

1
.htaccess Normal file
View File

@ -0,0 +1 @@
ErrorDocument 404 /404.html

12
.idea/runConfigurations/serve.xml generated Normal file
View File

@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="serve" type="js.build_tools.npm" nameIsGenerated="true">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="serve" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>

18
404.html Normal file
View File

@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="nb">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#181a1b" />
<title>Siden ble ikke funnet | Martials.no</title>
<meta name="description" content="Hjemmeside for API og diverse">
<link rel="icon" type="image/x-icon" href="resources/code.svg">
<link rel="stylesheet" href="src/index.css">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="/src/404.tsx" type="module"></script>
</body>
</html>

26
build_extra.sh Normal file
View File

@ -0,0 +1,26 @@
#!/bin/sh
if [ ! -e dist ]; then
echo "dist directory not found, running 'vite bulid'"
vite build
fi
if [ -e robots.txt ]; then
cp robots.txt dist
else
echo "robots.txt not found"
fi
mkdir -p "dist/.well-known"
if [ -e "dist/.well-known" ]; then
if [ -e security.txt ]; then
cp security.txt dist/.well-known
else
echo "security.txt not found"
fi
fi
if [ -e .htaccess ]; then
cp .htaccess dist
fi

View File

@ -4,7 +4,7 @@
"description": "",
"scripts": {
"dev": "vite",
"build": "vite build",
"build": "vite build && sh build_extra.sh",
"serve": "vite preview"
},
"license": "MIT",

View File

@ -1,5 +1,5 @@
module.exports = {
purge: ['./index.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
purge: ['./*.html', './src/**/*.{vue,js,ts,jsx,tsx}'],
plugins: {
tailwindcss: {},
autoprefixer: {},

2
robots.txt Normal file
View File

@ -0,0 +1,2 @@
User-agent: *
Allow: /

3
security.txt Normal file
View File

@ -0,0 +1,3 @@
Contact: mailto:me@martials.no
Expires: 2030-12-31
Preferred-Languages: no

22
src/404.tsx Normal file
View File

@ -0,0 +1,22 @@
/* @refresh reload */
import { type Component } from "solid-js";
import { render } from "solid-js/web";
import Layout from "./components/layout";
import { Link } from "./components/link";
const PageNotFound: Component = () => {
return (
<Layout title={ "Siden ble ikke funnet" }>
<div class={ "text-center" }>
<h4>Error 404 - Siden ble ikke funnet</h4>
<p>
<Link to={ "/" } newTab={ false } className={ "mx-auto relative w-max" }>
tilbake til forsiden
</Link>
</p>
</div>
</Layout>
);
};
render(() => <PageNotFound />, document.getElementById("root") as HTMLElement);

View File

@ -1,7 +1,7 @@
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
'./index.html',
'./index.html', "./404.html",
'./src/**/*.{js,ts,jsx,tsx,css,md,mdx,html,json,scss}',
],
darkMode: 'class',

View File

@ -8,5 +8,11 @@ export default defineConfig({
},
build: {
target: 'esnext',
rollupOptions: {
input: {
main: "index.html",
"404": "404.html",
}
}
},
});