From 79887d55bad8e4f785e3419f68b5f91ac2299b4e Mon Sep 17 00:00:00 2001
From: Martin Berg Alstad <600878@stud.hvl.no>
Date: Fri, 23 Dec 2022 14:57:53 +0100
Subject: [PATCH] 404 page, robots- and security.txt
---
.htaccess | 1 +
.idea/runConfigurations/serve.xml | 12 ++++++++++++
404.html | 18 ++++++++++++++++++
build_extra.sh | 26 ++++++++++++++++++++++++++
package.json | 2 +-
postcss.config.js | 2 +-
robots.txt | 2 ++
security.txt | 3 +++
src/404.tsx | 22 ++++++++++++++++++++++
tailwind.config.js | 2 +-
vite.config.ts | 6 ++++++
11 files changed, 93 insertions(+), 3 deletions(-)
create mode 100644 .htaccess
create mode 100644 .idea/runConfigurations/serve.xml
create mode 100644 404.html
create mode 100644 build_extra.sh
create mode 100644 robots.txt
create mode 100644 security.txt
create mode 100644 src/404.tsx
diff --git a/.htaccess b/.htaccess
new file mode 100644
index 0000000..9fded1e
--- /dev/null
+++ b/.htaccess
@@ -0,0 +1 @@
+ErrorDocument 404 /404.html
\ No newline at end of file
diff --git a/.idea/runConfigurations/serve.xml b/.idea/runConfigurations/serve.xml
new file mode 100644
index 0000000..a24edbd
--- /dev/null
+++ b/.idea/runConfigurations/serve.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/404.html b/404.html
new file mode 100644
index 0000000..6be1525
--- /dev/null
+++ b/404.html
@@ -0,0 +1,18 @@
+
+
+
+
+
+
+ Siden ble ikke funnet | Martials.no
+
+
+
+
+
+
+
+
+
+
+
diff --git a/build_extra.sh b/build_extra.sh
new file mode 100644
index 0000000..7323a94
--- /dev/null
+++ b/build_extra.sh
@@ -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
diff --git a/package.json b/package.json
index 7aa299a..0c91e72 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
"description": "",
"scripts": {
"dev": "vite",
- "build": "vite build",
+ "build": "vite build && sh build_extra.sh",
"serve": "vite preview"
},
"license": "MIT",
diff --git a/postcss.config.js b/postcss.config.js
index 7904127..824f185 100644
--- a/postcss.config.js
+++ b/postcss.config.js
@@ -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: {},
diff --git a/robots.txt b/robots.txt
new file mode 100644
index 0000000..14267e9
--- /dev/null
+++ b/robots.txt
@@ -0,0 +1,2 @@
+User-agent: *
+Allow: /
\ No newline at end of file
diff --git a/security.txt b/security.txt
new file mode 100644
index 0000000..99fe47c
--- /dev/null
+++ b/security.txt
@@ -0,0 +1,3 @@
+Contact: mailto:me@martials.no
+Expires: 2030-12-31
+Preferred-Languages: no
\ No newline at end of file
diff --git a/src/404.tsx b/src/404.tsx
new file mode 100644
index 0000000..0a6089b
--- /dev/null
+++ b/src/404.tsx
@@ -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 (
+
+
+
Error 404 - Siden ble ikke funnet
+
+
+ Gå tilbake til forsiden
+
+
+
+
+ );
+};
+
+render(() => , document.getElementById("root") as HTMLElement);
diff --git a/tailwind.config.js b/tailwind.config.js
index c538530..9ac63e9 100644
--- a/tailwind.config.js
+++ b/tailwind.config.js
@@ -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',
diff --git a/vite.config.ts b/vite.config.ts
index 3d8b8d5..bd7292d 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -8,5 +8,11 @@ export default defineConfig({
},
build: {
target: 'esnext',
+ rollupOptions: {
+ input: {
+ main: "index.html",
+ "404": "404.html",
+ }
+ }
},
});