add next-sitemap
This commit is contained in:
parent
51a01237a2
commit
d45481d5fa
|
@ -0,0 +1,11 @@
|
||||||
|
const SITE_URL =
|
||||||
|
process.env.NEXT_PUBLIC_URL || 'https://zdamegzaminzawodowy.pl';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
siteUrl: SITE_URL,
|
||||||
|
generateRobotsTxt: true,
|
||||||
|
exclude: ['/server-sitemap.xml', '/404', '/pl', '/500'],
|
||||||
|
robotsTxtOptions: {
|
||||||
|
additionalSitemaps: [`${SITE_URL}/server-sitemap.xml`],
|
||||||
|
},
|
||||||
|
};
|
|
@ -5,6 +5,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "next dev",
|
"dev": "next dev",
|
||||||
"build": "next build",
|
"build": "next build",
|
||||||
|
"postbuild": "next-sitemap",
|
||||||
"start": "next start",
|
"start": "next start",
|
||||||
"codegen": "graphql-codegen"
|
"codegen": "graphql-codegen"
|
||||||
},
|
},
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
"graphql-request": "^3.4.0",
|
"graphql-request": "^3.4.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"next": "10.0.9",
|
"next": "10.0.9",
|
||||||
|
"next-sitemap": "^1.6.25",
|
||||||
"polish-plurals": "^1.1.0",
|
"polish-plurals": "^1.1.0",
|
||||||
"react": "17.0.1",
|
"react": "17.0.1",
|
||||||
"react-dom": "17.0.1",
|
"react-dom": "17.0.1",
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
import { GetServerSideProps } from 'next';
|
||||||
|
import { gql } from 'graphql-request';
|
||||||
|
import { getServerSideSitemap } from 'next-sitemap';
|
||||||
|
import { ISitemapFiled } from 'next-sitemap/dist/@types/interface';
|
||||||
|
import { createClient } from 'libs/graphql';
|
||||||
|
import { Query, QueryQualificationsArgs } from 'libs/graphql';
|
||||||
|
import { WEBSITE_URL, QUESTIONS } from 'config/app';
|
||||||
|
import { Route } from 'config/routing';
|
||||||
|
import resolveAs from 'utils/resolveAs';
|
||||||
|
|
||||||
|
const QUERY_QUALIFICATIONS = gql`
|
||||||
|
query qualifications($sort: [String!], $limit: Int) {
|
||||||
|
qualifications(sort: $sort, limit: $limit) {
|
||||||
|
items {
|
||||||
|
slug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
const LIMIT = 1000;
|
||||||
|
|
||||||
|
export const getServerSideProps: GetServerSideProps = async ctx => {
|
||||||
|
const client = createClient();
|
||||||
|
let fields: ISitemapFiled[] = [];
|
||||||
|
|
||||||
|
try {
|
||||||
|
const {
|
||||||
|
qualifications: { items },
|
||||||
|
} = await client.request<
|
||||||
|
Pick<Query, 'qualifications'>,
|
||||||
|
QueryQualificationsArgs
|
||||||
|
>(QUERY_QUALIFICATIONS, { limit: LIMIT, sort: ['code ASC'] });
|
||||||
|
if (Array.isArray(items)) {
|
||||||
|
fields = ([] as typeof fields).concat(
|
||||||
|
...QUESTIONS.map(limit => {
|
||||||
|
return items.map(
|
||||||
|
(item): ISitemapFiled => {
|
||||||
|
return {
|
||||||
|
loc: `${WEBSITE_URL}${resolveAs({
|
||||||
|
pathname: Route.TestPage,
|
||||||
|
query: { slug: item.slug, limit },
|
||||||
|
})}`,
|
||||||
|
lastmod: new Date().toISOString(),
|
||||||
|
changefreq: 'always',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.log('server-sitemap.xml', e.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getServerSideSitemap(ctx, fields);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Default export to prevent next.js errors
|
||||||
|
const Index = () => <div />;
|
||||||
|
|
||||||
|
export default Index;
|
|
@ -0,0 +1,10 @@
|
||||||
|
# *
|
||||||
|
User-agent: *
|
||||||
|
Allow: /
|
||||||
|
|
||||||
|
# Host
|
||||||
|
Host: https://zdamegzaminzawodowy.pl
|
||||||
|
|
||||||
|
# Sitemaps
|
||||||
|
Sitemap: https://zdamegzaminzawodowy.pl/sitemap.xml
|
||||||
|
Sitemap: https://zdamegzaminzawodowy.pl/server-sitemap.xml
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">
|
||||||
|
<url><loc>https://zdamegzaminzawodowy.pl</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2021-04-13T15:59:54.800Z</lastmod></url>
|
||||||
|
<url><loc>https://zdamegzaminzawodowy.pl/polityka-prywatnosci</loc><changefreq>daily</changefreq><priority>0.7</priority><lastmod>2021-04-13T15:59:54.800Z</lastmod></url>
|
||||||
|
</urlset>
|
|
@ -1,6 +1,6 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { URL } from 'config/app';
|
import { WEBSITE_URL } from 'config/app';
|
||||||
|
|
||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
|
|
||||||
|
@ -19,27 +19,33 @@ const SEO = ({ title, description = DEFAULT_DESCRIPTION }: SEOProps) => {
|
||||||
return (
|
return (
|
||||||
<Head>
|
<Head>
|
||||||
<title>{formattedTitle}</title>
|
<title>{formattedTitle}</title>
|
||||||
<link rel="canonical" href={URL + asPath} />
|
<link rel="canonical" href={WEBSITE_URL + asPath} />
|
||||||
<link rel="icon" href={URL + '/favicon.ico'} />
|
<link rel="icon" href={WEBSITE_URL + '/favicon.ico'} />
|
||||||
<meta name="description" content={description} />
|
<meta name="description" content={description} />
|
||||||
<meta
|
<meta
|
||||||
name="apple-touch-icon"
|
name="apple-touch-icon"
|
||||||
content={`${URL}/images/logo-192x192.png`}
|
content={`${WEBSITE_URL}/images/logo-192x192.png`}
|
||||||
/>
|
/>
|
||||||
<meta property="og:site_name" content={NAME} />
|
<meta property="og:site_name" content={NAME} />
|
||||||
<meta property="og:title" content={formattedTitle} />
|
<meta property="og:title" content={formattedTitle} />
|
||||||
<meta property="og:description" content={description} />
|
<meta property="og:description" content={description} />
|
||||||
<meta property="og:url" content={URL + asPath} />
|
<meta property="og:url" content={WEBSITE_URL + asPath} />
|
||||||
<meta property="og:type" content="website" />
|
<meta property="og:type" content="website" />
|
||||||
<meta property="og:image" content={`${URL}/images/meta/zdam.png`} />
|
<meta
|
||||||
|
property="og:image"
|
||||||
|
content={`${WEBSITE_URL}/images/meta/zdam.png`}
|
||||||
|
/>
|
||||||
<meta property="og:image:width" content={'1280'} />
|
<meta property="og:image:width" content={'1280'} />
|
||||||
<meta property="og:image:height" content={'640'} />
|
<meta property="og:image:height" content={'640'} />
|
||||||
<meta property="og:locale" content="pl" />
|
<meta property="og:locale" content="pl" />
|
||||||
<meta name="twitter:card" content="summary_large_image" />
|
<meta name="twitter:card" content="summary_large_image" />
|
||||||
<meta name="twitter:title" content={formattedTitle} />
|
<meta name="twitter:title" content={formattedTitle} />
|
||||||
<meta name="twitter:description" content={description} />
|
<meta name="twitter:description" content={description} />
|
||||||
<meta name="twitter:url" content={URL + asPath} />
|
<meta name="twitter:url" content={WEBSITE_URL + asPath} />
|
||||||
<meta name="twitter:image" content={`${URL}/images/meta/zdam.png`} />
|
<meta
|
||||||
|
name="twitter:image"
|
||||||
|
content={`${WEBSITE_URL}/images/meta/zdam.png`}
|
||||||
|
/>
|
||||||
<meta name="twitter:image:alt" content={NAME} />
|
<meta name="twitter:image:alt" content={NAME} />
|
||||||
</Head>
|
</Head>
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,5 +9,5 @@ export const QUESTIONS = [1, 40];
|
||||||
export const GOOGLE_PLAY_URL =
|
export const GOOGLE_PLAY_URL =
|
||||||
'https://play.google.com/store/apps/details?id=com.dawidwysokinski.zdamegzaminzawodowy';
|
'https://play.google.com/store/apps/details?id=com.dawidwysokinski.zdamegzaminzawodowy';
|
||||||
|
|
||||||
export const URL =
|
export const WEBSITE_URL =
|
||||||
process.env.NEXT_PUBLIC_URL ?? 'https://zdamegzaminzawodowy.pl';
|
process.env.NEXT_PUBLIC_URL ?? 'https://zdamegzaminzawodowy.pl';
|
||||||
|
|
26
yarn.lock
26
yarn.lock
|
@ -505,6 +505,11 @@
|
||||||
lodash "^4.17.19"
|
lodash "^4.17.19"
|
||||||
to-fast-properties "^2.0.0"
|
to-fast-properties "^2.0.0"
|
||||||
|
|
||||||
|
"@corex/deepmerge@^2.5.6":
|
||||||
|
version "2.5.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/@corex/deepmerge/-/deepmerge-2.5.6.tgz#a5d26c6a0f4df1f65d17871c94f463d5097e349a"
|
||||||
|
integrity sha512-zvClQyrUGV4Hzr2zWnyD/MS0DrNWJ9jMKFLYA/abmsU4dObMuFXhragGqWpWHW6G/ghJpf09E+JumTo5jSb9rg==
|
||||||
|
|
||||||
"@emotion/hash@^0.8.0":
|
"@emotion/hash@^0.8.0":
|
||||||
version "0.8.0"
|
version "0.8.0"
|
||||||
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413"
|
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413"
|
||||||
|
@ -2514,6 +2519,11 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
|
||||||
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
|
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
|
||||||
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
|
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
|
||||||
|
|
||||||
|
escape-string-regexp@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
|
||||||
|
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
|
||||||
|
|
||||||
eslint-config-react-app@^6.0.0:
|
eslint-config-react-app@^6.0.0:
|
||||||
version "6.0.0"
|
version "6.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-6.0.0.tgz#ccff9fc8e36b322902844cbd79197982be355a0e"
|
resolved "https://registry.yarnpkg.com/eslint-config-react-app/-/eslint-config-react-app-6.0.0.tgz#ccff9fc8e36b322902844cbd79197982be355a0e"
|
||||||
|
@ -4068,6 +4078,13 @@ map-cache@^0.2.0:
|
||||||
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
|
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
|
||||||
integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=
|
integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=
|
||||||
|
|
||||||
|
matcher@^4.0.0:
|
||||||
|
version "4.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/matcher/-/matcher-4.0.0.tgz#a42a05a09aaed92e2d241eb91fddac689461ea51"
|
||||||
|
integrity sha512-S6x5wmcDmsDRRU/c2dkccDwQPXoFczc5+HpQ2lON8pnvHlnvHAHj5WlLVvw6n6vNyHuVugYrFohYxbS+pvFpKQ==
|
||||||
|
dependencies:
|
||||||
|
escape-string-regexp "^4.0.0"
|
||||||
|
|
||||||
md5.js@^1.3.4:
|
md5.js@^1.3.4:
|
||||||
version "1.3.5"
|
version "1.3.5"
|
||||||
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
|
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
|
||||||
|
@ -4213,6 +4230,15 @@ natural-compare@^1.4.0:
|
||||||
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
|
resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7"
|
||||||
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
|
integrity sha1-Sr6/7tdUHywnrPspvbvRXI1bpPc=
|
||||||
|
|
||||||
|
next-sitemap@^1.6.25:
|
||||||
|
version "1.6.25"
|
||||||
|
resolved "https://registry.yarnpkg.com/next-sitemap/-/next-sitemap-1.6.25.tgz#bab5694e998e57b9932c57fb6dd95448d55ab88c"
|
||||||
|
integrity sha512-lZ1Mchz0Kwfy9C2kdxlp1FPT1kj6g2EY6+cAuBjmRht+3fbDqLaDaC0z3cYhjvsfmHlshc1FNkZ7Ntq5a8q7tQ==
|
||||||
|
dependencies:
|
||||||
|
"@corex/deepmerge" "^2.5.6"
|
||||||
|
matcher "^4.0.0"
|
||||||
|
minimist "^1.2.5"
|
||||||
|
|
||||||
next@10.0.9:
|
next@10.0.9:
|
||||||
version "10.0.9"
|
version "10.0.9"
|
||||||
resolved "https://registry.yarnpkg.com/next/-/next-10.0.9.tgz#ad5d8e0368fee8363cdfd64d22dfbf71f683ae66"
|
resolved "https://registry.yarnpkg.com/next/-/next-10.0.9.tgz#ad5d8e0368fee8363cdfd64d22dfbf71f683ae66"
|
||||||
|
|
Reference in New Issue