@kvihaugen/create-frontend-app 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kvihaugen/create-frontend-app",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "main": "dist/index.js",
5
5
  "type": "module",
6
6
  "bin": {
@@ -0,0 +1,21 @@
1
+ import policy from "@/utils/csp-policy";
2
+
3
+ import { NextConfig } from "next";
4
+
5
+ const nextConfig: NextConfig = {
6
+ async headers() {
7
+ return [
8
+ {
9
+ source: "/(.*)",
10
+ headers: [
11
+ {
12
+ key: "Content-Security-Policy",
13
+ value: policy
14
+ }
15
+ ]
16
+ }
17
+ ];
18
+ }
19
+ };
20
+
21
+ export default nextConfig;
@@ -0,0 +1,18 @@
1
+ const config = {
2
+ plugins: ["@tailwindcss/postcss"],
3
+ plugins: {
4
+ "@tailwindcss/postcss": {},
5
+ "postcss-preset-mantine": {},
6
+ "postcss-simple-vars": {
7
+ variables: {
8
+ "mantine-breakpoint-xs": "36em",
9
+ "mantine-breakpoint-sm": "48em",
10
+ "mantine-breakpoint-md": "62em",
11
+ "mantine-breakpoint-lg": "75em",
12
+ "mantine-breakpoint-xl": "88em"
13
+ }
14
+ }
15
+ }
16
+ };
17
+
18
+ export default config;
@@ -0,0 +1,7 @@
1
+ # https://en.wikipedia.org/wiki/Robots.txt
2
+ # https://www.geeksforgeeks.org/robots-txt-file/
3
+
4
+ User-agent: *
5
+ Disallow:
6
+ Sitemap:
7
+ Crawl-Delay:
@@ -0,0 +1,29 @@
1
+ # https://securitytxt.org/
2
+ # Fields marked with * are required
3
+
4
+ # Contact *
5
+ Contact: mailto:your.email@example.com
6
+
7
+ # Expires *(max 1)
8
+ Expires: YYYY-MM-DDThh:mm:ss.SSSZ
9
+
10
+ # Encryption
11
+ Encryption: https://example.com/encryption
12
+
13
+ # Acknowledgments
14
+ Acknowledgments: https://example.com/acknowledgments
15
+
16
+ # Preferred languages (max 1)
17
+ Preferred-Languages: en,no
18
+
19
+ # Canonical
20
+ Canonical: https://example.com/security.txt
21
+
22
+ # Policy
23
+ Policy: https://example.com/policy
24
+
25
+ # Hiring
26
+ Hiring: https://example.com/hiring
27
+
28
+ # CSAF
29
+ CSAF: https://example.com/csaf-provider-metadata.json
@@ -0,0 +1,87 @@
1
+ import { Metadata } from "next";
2
+ import { ColorSchemeScript, mantineHtmlProps } from "@mantine/core";
3
+
4
+ import ParentProps from "@/types/common/ParentProps";
5
+ import Providers from "@/components/common/Providers";
6
+
7
+ import "@/css/globals.css";
8
+
9
+ // https://seostudio.tools/meta-tag-generator
10
+ // https://www.searchenginejournal.com/important-tags-seo/156440/
11
+
12
+ export const metadata = {
13
+ title: "Frontend template",
14
+ description: "My preferred template for frontend projects - tailored to my needs",
15
+ applicationName: "Frontend template",
16
+ authors: [{
17
+ url: "https://lars.kvihaugen.no",
18
+ name: "Lars Kvihaugen"
19
+ }],
20
+ generator: "Next.js",
21
+ keywords: [
22
+ "next.js",
23
+ "next",
24
+ "react",
25
+ "frontend",
26
+ "development",
27
+ "dev"
28
+ ],
29
+ referrer: "origin",
30
+ creator: "Lars Kvihaugen",
31
+ publisher: "Lars Kvihaugen",
32
+ robots: {
33
+ index: true,
34
+ follow: true
35
+ },
36
+ alternates: {
37
+ canonical: "https://frontend-template.kvihaugen.no",
38
+ languages: {
39
+ en: "https://frontend-template.kvihaugen.no",
40
+ no: "https://no.frontend-template.kvihaugen.no"
41
+ }
42
+ },
43
+ icons: {
44
+ icon: [{
45
+ url: "/icons/icon-128x128.png",
46
+ sizes: "128x128"
47
+ }],
48
+ apple: [{
49
+ url: "/icons/icon-apple/128x128.png",
50
+ sizes: "128x128"
51
+ }]
52
+ },
53
+ manifest: "/.well-known/app.webmanifest",
54
+ openGraph: {
55
+ type: "website",
56
+ title: "Frontend template",
57
+ description: "My preferred template for frontend projects - tailored to my needs",
58
+ emails: ["lars@kvihaugen.no"],
59
+ phoneNumbers: ["+00 000 00 000"],
60
+ siteName: "Frontend template",
61
+ locale: "en",
62
+ alternateLocale: ["no"],
63
+ images: [{
64
+ url: "/images/hero.png",
65
+ alt: "The page hero",
66
+ width: 1920,
67
+ height: 1080
68
+ }],
69
+ url: "https://frontend-template.kvihaugen.no"
70
+ },
71
+ metadataBase: new URL("https://frontend-template.kvihaugen.no")
72
+ } satisfies Metadata as Metadata;
73
+
74
+ const RootLayout = ({ children }: ParentProps) => (
75
+ <html {...mantineHtmlProps}>
76
+ <head>
77
+ <ColorSchemeScript />
78
+ </head>
79
+ <body className="antialiased">
80
+ <Providers>
81
+ {children}
82
+ </Providers>
83
+ </body>
84
+ </html>
85
+ );
86
+
87
+ export default RootLayout;
@@ -0,0 +1,14 @@
1
+ "use client";
2
+
3
+ import { Button } from "@mantine/core";
4
+ import { t } from "i18next";
5
+
6
+ const Page = () => {
7
+ return (
8
+ <Button>
9
+ {t("common.HelloWorld")}
10
+ </Button>
11
+ );
12
+ };
13
+
14
+ export default Page;
@@ -0,0 +1,17 @@
1
+ "use client";
2
+
3
+ import ParentProps from "@/types/common/ParentProps";
4
+
5
+ import { createTheme, MantineProvider } from "@mantine/core";
6
+
7
+ import "@/utils/i18n";
8
+
9
+ const theme = createTheme({});
10
+
11
+ const Providers = ({ children }: ParentProps) => (
12
+ <MantineProvider theme={theme}>
13
+ {children}
14
+ </MantineProvider>
15
+ );
16
+
17
+ export default Providers;
@@ -0,0 +1,4 @@
1
+ @layer theme, base, components, mantine, utilities;
2
+
3
+ @import "tailwindcss";
4
+ @import "@mantine/core/styles.layer.css";
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from "react";
2
+
3
+ type ParentProps<T = ReactNode> = {
4
+ children?: T;
5
+ };
6
+
7
+ export default ParentProps;
@@ -0,0 +1,15 @@
1
+ // https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Security-Policy#fetch_directives
2
+ // https://www.validbot.com/tools/csp-wizard.php
3
+
4
+ const policy = `
5
+
6
+ default-src 'self';
7
+ script-src 'self' 'unsafe-inline' 'unsafe-eval';
8
+ connect-src 'self';
9
+ img-src 'self' data: blob:;
10
+ style-src 'self' 'unsafe-inline';
11
+ frame-src;
12
+
13
+ `.replaceAll("\n", " ").trim();
14
+
15
+ export default policy;
@@ -0,0 +1,30 @@
1
+ import { useMantineColorScheme } from "@mantine/core";
2
+ import { useEffect, useMemo, useState } from "react";
3
+
4
+ const useColorScheme = () => {
5
+ const [isBrowserColorSchemeDark, setIsBrowserColorSchemeDark] = useState<boolean>(false);
6
+
7
+ const { colorScheme } = useMantineColorScheme();
8
+
9
+ useEffect(() => {
10
+ const handleSetAccordingColorScheme = () => setIsBrowserColorSchemeDark(window.matchMedia("(prefers-color-scheme: dark)").matches);
11
+
12
+ handleSetAccordingColorScheme();
13
+
14
+ window.addEventListener("change", handleSetAccordingColorScheme);
15
+
16
+ return () => window.removeEventListener("change", handleSetAccordingColorScheme);
17
+ }, []);
18
+
19
+ const isColorSchemeDark = useMemo(() => (
20
+ (colorScheme === "auto" && isBrowserColorSchemeDark) ||
21
+ colorScheme === "dark"
22
+ ), [isBrowserColorSchemeDark, colorScheme]);
23
+
24
+ return {
25
+ isDark: isColorSchemeDark,
26
+ isLight: !isColorSchemeDark
27
+ };
28
+ };
29
+
30
+ export default useColorScheme;
@@ -0,0 +1,17 @@
1
+ import { useMantineTheme } from "@mantine/core";
2
+
3
+ import useColorScheme from "./useColorScheme";
4
+
5
+ const usePrimaryColorShade = () => {
6
+ const { primaryColor, primaryShade, colors } = useMantineTheme();
7
+ const { isDark: isColorSchemeDark } = useColorScheme();
8
+
9
+ const shadeIndexer =
10
+ typeof primaryShade === "object"
11
+ ? primaryShade[isColorSchemeDark ? "dark" : "light"]
12
+ : primaryShade;
13
+
14
+ return colors[primaryColor][shadeIndexer];
15
+ };
16
+
17
+ export default usePrimaryColorShade;
@@ -0,0 +1,15 @@
1
+ import i18next from "i18next";
2
+ import en from "./resources/en.json";
3
+
4
+ import { initReactI18next } from "react-i18next";
5
+
6
+ i18next
7
+ .use(initReactI18next)
8
+ .init({
9
+ resources: { en },
10
+ lng: "en",
11
+ fallbackLng: "en",
12
+ interpolation: {
13
+ escapeValue: false
14
+ }
15
+ });
@@ -0,0 +1,7 @@
1
+ {
2
+ "translation": {
3
+ "common": {
4
+ "HelloWorld": "Hello world!"
5
+ }
6
+ }
7
+ }