apps/web: add favicons & metadata

This commit is contained in:
vchikalkin 2023-11-09 20:59:20 +03:00
parent 83493d07f3
commit debc9b35f0
21 changed files with 166 additions and 2 deletions

View File

@ -17,3 +17,9 @@ export async function getMetaData(params: t.Request) {
return api.get(url).then((res) => res as t.ResponseMetaData); return api.get(url).then((res) => res as t.ResponseMetaData);
} }
export async function getConfig(params: t.Request) {
const url = `/${params.slug}/config`;
return api.get(url).then((res) => res as t.ResponseConfig);
}

View File

@ -12,3 +12,4 @@ export type MetaObject = {
export type Request = { searchParams: any; slug: string }; export type Request = { searchParams: any; slug: string };
export type ResponseGetData = Record<string, any>; export type ResponseGetData = Record<string, any>;
export type ResponseMetaData = Record<string, MetaObject>; export type ResponseMetaData = Record<string, MetaObject>;
export type ResponseConfig = { title: string };

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

View File

@ -1,12 +1,27 @@
import * as apiIUS from '@/api/ius/query'; import * as apiIUS from '@/api/ius/query';
import type { Request } from '@/api/ius/types'; import type { Request } from '@/api/ius/types';
import { Form } from '@/components/Form'; import { Form } from '@/components/Form';
import type { Metadata } from 'next';
type Props = { type Props = {
params: { slug: string }; params: { slug: string };
searchParams: { [key: string]: string | string[] | undefined }; searchParams: { [key: string]: string | string[] | undefined };
}; };
export async function generateMetadata({ params, searchParams }: Props): Promise<Metadata> {
const { title } = await apiIUS.getConfig({ searchParams, ...params });
const text = `${title} | Эволюция`;
return {
description: text,
openGraph: {
description: text,
title: text,
},
title: text,
};
}
export default async function Page(props: Props) { export default async function Page(props: Props) {
const data = await getData({ const data = await getData({
searchParams: props.searchParams, searchParams: props.searchParams,

View File

@ -7,13 +7,39 @@ import { Content, Header } from 'ui';
const inter = Inter({ subsets: ['latin'] }); const inter = Inter({ subsets: ['latin'] });
export const metadata: Metadata = { export const metadata: Metadata = {
description: 'Generated by create next app', description: 'External | Эволюция',
title: 'Create Next App', icons: {
apple: '/apple-touch-icon.png',
icon: '/favicon.ico',
other: [
{
rel: 'icon',
sizes: '32x32',
type: 'image/png',
url: '/favicon-32x32.png',
},
{
rel: 'icon',
sizes: '16x16',
type: 'image/png',
url: '/favicon-16x16.png',
},
{
rel: 'mask-icon',
url: '/safari-pinned-tab.svg',
},
],
},
title: 'External | Эволюция',
}; };
export default function RootLayout({ children }: { readonly children: React.ReactNode }) { export default function RootLayout({ children }: { readonly children: React.ReactNode }) {
return ( return (
<html lang="ru" translate="no"> <html lang="ru" translate="no">
<head>
<meta charSet="utf-8" />
<meta name="theme-color" content="#000000" />
</head>
<body className={inter.className}> <body className={inter.className}>
<Header> <Header>
<Logo /> <Logo />

25
apps/web/app/manifest.ts Normal file
View File

@ -0,0 +1,25 @@
import type { MetadataRoute } from 'next';
export default function manifest(): MetadataRoute.Manifest {
return {
background_color: '#fff',
description: 'External | Эволюция',
display: 'standalone',
icons: [
{
sizes: '192x192',
src: '/android-chrome-192x192.png',
type: 'image/png',
},
{
sizes: '512x512',
src: '/android-chrome-512x512.png',
type: 'image/png',
},
],
name: 'External | Эволюция',
short_name: 'External | Эволюция',
start_url: '/',
theme_color: '#fff',
};
}

View File

@ -1,8 +1,18 @@
const fs = require('fs');
const envSchema = require('./config/schema/env'); const envSchema = require('./config/schema/env');
const urls = require('./constants/urls'); const urls = require('./constants/urls');
const env = envSchema.parse(process.env); const env = envSchema.parse(process.env);
const favicons = fs.readdirSync('./public/favicon/prod');
const faviconSubPath = env.USE_DEV_COLORS ? '/favicon/dev' : '/favicon/prod';
function buildFaviconRewrite(source) {
return {
destination: String.prototype.concat(faviconSubPath, source),
source,
};
}
/** @type {import('next').NextConfig} */ /** @type {import('next').NextConfig} */
const nextConfig = { const nextConfig = {
reactStrictMode: true, reactStrictMode: true,
@ -13,6 +23,7 @@ const nextConfig = {
destination: env.URL_IUS_DIRECT + '/:path', destination: env.URL_IUS_DIRECT + '/:path',
source: urls.URL_IUS_PROXY + '/:path', source: urls.URL_IUS_PROXY + '/:path',
}, },
...favicons.map((fileName) => buildFaviconRewrite(`/${fileName}`)),
]; ];
}, },
}; };

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 90 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,32 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="789.000000pt" height="789.000000pt" viewBox="0 0 789.000000 789.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.14, written by Peter Selinger 2001-2017
</metadata>
<g transform="translate(0.000000,789.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M3119 7886 c-2 -2 -47 -6 -99 -10 -440 -29 -955 -160 -1375 -349
-362 -164 -769 -429 -1038 -676 -20 -19 -51 -47 -69 -63 l-32 -28 25 -27 c37
-42 53 -58 224 -238 88 -92 175 -184 194 -204 18 -20 101 -108 185 -195 83
-87 159 -168 169 -180 10 -12 58 -62 107 -112 l87 -91 34 31 c869 811 2202
938 3217 305 224 -139 480 -365 636 -559 305 -382 481 -807 542 -1310 9 -71 9
-365 1 -452 -70 -706 -427 -1336 -999 -1764 -374 -279 -802 -448 -1288 -508
-111 -14 -522 -15 -595 -2 -16 3 -66 10 -110 16 -504 71 -1019 317 -1388 663
-43 40 -61 45 -74 23 -4 -8 -50 -59 -102 -113 -167 -175 -274 -287 -361 -379
-47 -49 -157 -166 -246 -259 -199 -210 -249 -265 -249 -275 0 -9 157 -149 265
-236 135 -109 321 -237 490 -336 96 -57 393 -208 407 -208 4 0 21 -7 36 -15
32 -16 233 -93 322 -123 309 -104 655 -174 986 -199 189 -14 662 -8 765 11 10
2 46 7 79 10 101 12 125 16 280 47 1512 300 2716 1413 3104 2869 35 131 72
306 85 400 2 19 8 58 11 85 4 28 9 61 11 75 26 160 25 669 -2 885 -6 49 -33
231 -40 271 -14 81 -79 334 -115 449 -402 1281 -1483 2296 -2814 2640 -225 58
-366 83 -645 116 -85 10 -612 23 -621 15z"/>
<path d="M3207 4984 c-309 -40 -582 -211 -749 -469 -118 -181 -169 -357 -169
-575 0 -348 173 -670 464 -864 492 -327 1152 -192 1472 303 72 112 116 220
151 376 12 52 13 308 2 365 -64 331 -254 592 -548 752 -181 98 -408 139 -623
112z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -0,0 +1,48 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="789.000000pt" height="789.000000pt" viewBox="0 0 789.000000 789.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.14, written by Peter Selinger 2001-2017
</metadata>
<g transform="translate(0.000000,789.000000) scale(0.100000,-0.100000)"
fill="#000000" stroke="none">
<path d="M3157 7885 c-1 -2 -54 -5 -117 -9 -100 -6 -205 -17 -290 -31 -14 -3
-43 -7 -65 -10 -68 -10 -209 -37 -290 -56 -369 -85 -762 -240 -1094 -431 -46
-26 -85 -48 -87 -48 -8 0 -234 -154 -330 -225 -111 -82 -295 -238 -346 -291
l-27 -29 66 -70 c124 -131 388 -409 478 -504 50 -52 101 -106 115 -121 155
-166 325 -340 330 -338 7 3 127 108 155 134 27 27 241 176 317 222 238 141
499 245 763 306 108 24 128 28 230 41 28 4 61 9 75 11 36 6 225 17 295 17 127
0 313 -14 427 -34 32 -6 70 -12 85 -15 16 -2 84 -18 152 -35 514 -127 1007
-429 1334 -819 40 -47 75 -87 78 -90 3 -3 37 -50 76 -105 131 -188 227 -370
304 -579 32 -88 85 -272 94 -326 3 -19 8 -42 10 -50 2 -8 7 -33 10 -55 3 -23
8 -52 11 -65 18 -90 25 -418 11 -565 -55 -572 -304 -1093 -722 -1510 -213
-213 -420 -361 -690 -494 -234 -115 -497 -201 -725 -236 -19 -3 -46 -7 -60
-10 -22 -4 -60 -8 -195 -21 -55 -5 -353 -5 -390 0 -16 2 -61 7 -100 10 -98 9
-327 50 -345 61 -3 2 -19 6 -34 9 -64 12 -243 70 -351 114 -83 35 -360 176
-375 192 -3 3 -30 21 -60 40 -65 41 -51 31 -176 129 -56 43 -123 99 -150 125
-27 25 -52 46 -55 46 -6 0 -50 -46 -329 -340 -85 -90 -175 -184 -200 -211 -25
-26 -106 -111 -180 -190 -74 -79 -148 -157 -165 -174 -106 -110 -119 -126
-109 -133 6 -4 47 -39 90 -79 303 -275 708 -535 1084 -697 36 -15 66 -27 68
-27 1 1 17 -6 35 -15 33 -18 321 -120 359 -128 13 -3 72 -19 132 -35 129 -36
282 -69 401 -86 22 -4 47 -8 55 -10 8 -2 43 -7 78 -10 35 -4 71 -8 80 -10 129
-24 730 -24 882 0 14 3 50 7 80 10 61 6 79 9 195 30 44 8 91 16 105 19 14 2
66 14 115 26 50 12 97 23 105 25 87 18 389 118 516 170 908 375 1640 1047
2070 1905 120 239 217 490 270 695 1 6 12 46 23 90 12 44 23 90 26 103 2 12 6
30 9 40 3 9 7 28 10 42 2 14 9 52 15 85 6 33 13 76 15 95 2 19 7 55 10 80 4
25 8 61 11 80 26 207 26 621 -1 860 -13 126 -61 394 -83 468 -5 18 -10 33 -10
35 1 7 -17 75 -43 162 -200 674 -573 1272 -1099 1760 -101 94 -130 118 -261
220 -68 52 -128 99 -133 103 -29 23 -195 132 -201 132 -4 0 -15 6 -23 14 -9 8
-32 23 -51 34 -19 11 -69 39 -110 62 -208 119 -540 261 -783 334 -126 38 -290
81 -347 91 -19 3 -51 10 -70 15 -38 9 -66 14 -175 30 -121 18 -212 28 -315 36
-71 6 -487 13 -493 9z"/>
<path d="M3348 4996 c-1 -2 -41 -6 -88 -10 -110 -7 -139 -13 -235 -43 -293
-92 -534 -309 -651 -585 -57 -135 -76 -223 -80 -378 -5 -192 21 -324 93 -476
28 -58 82 -154 93 -164 3 -3 17 -21 32 -41 139 -186 385 -334 638 -384 108
-21 340 -14 442 13 318 86 554 278 696 567 30 62 67 168 77 220 27 154 31 290
10 420 -11 67 -64 214 -105 294 -164 312 -484 527 -830 557 -36 3 -70 7 -77 9
-6 2 -13 2 -15 1z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB