-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(seo): add robots and sitemap configs
- Loading branch information
Showing
7 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import type { MetadataRoute } from 'next'; | ||
|
||
import config from '@/config'; | ||
|
||
export default function robots(): MetadataRoute.Robots { | ||
return { | ||
rules: { | ||
userAgent: '*', | ||
crawlDelay: 10, | ||
}, | ||
sitemap: `${config.url}/sitemap.xml`, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import type { MetadataRoute } from 'next'; | ||
import { Languages } from 'next/dist/lib/metadata/types/alternative-urls-types'; | ||
|
||
import config from '@/config'; | ||
import { ArticleIndexEntrySchema } from '@/lib/schemas/article-index-entry'; | ||
import articlesRaw from '@/public/assets/articles/index.json'; | ||
import i18nConfig from '@/root/next-i18next.config'; | ||
|
||
const extraLangs = i18nConfig.i18n.locales.filter( | ||
(lang) => lang !== i18nConfig.i18n.defaultLocale, | ||
); | ||
const genLangAlternates = (path: string): Languages<string> => { | ||
const items = extraLangs.map((lang) => [ | ||
lang, | ||
`${config.url}/${lang}/${path}`, | ||
]); | ||
|
||
return Object.fromEntries(items); | ||
}; | ||
|
||
const commonPageMeta = (path: string): MetadataRoute.Sitemap[0] => ({ | ||
url: `${config.url}/${path}`, | ||
lastModified: new Date(), | ||
changeFrequency: 'daily', | ||
alternates: { | ||
languages: genLangAlternates(path), | ||
}, | ||
}); | ||
|
||
export default function sitemap(): MetadataRoute.Sitemap { | ||
const articles = articlesRaw.map((article: ArticleIndexEntrySchema) => { | ||
const prefix = | ||
article.locale === i18nConfig.i18n.defaultLocale | ||
? `${config.url}` | ||
: `${config.url}/${article.locale}`; | ||
|
||
return { | ||
url: `${prefix}/articles/${article.slug}`, | ||
lastModified: new Date(), | ||
} satisfies MetadataRoute.Sitemap[0]; | ||
}); | ||
|
||
return [ | ||
commonPageMeta(''), | ||
commonPageMeta('about'), | ||
commonPageMeta('contact'), | ||
commonPageMeta('dilf'), | ||
commonPageMeta('donate'), | ||
commonPageMeta('flaim-a-phone'), | ||
commonPageMeta('hot-things'), | ||
commonPageMeta('privacy-policy'), | ||
commonPageMeta('search'), | ||
commonPageMeta('settings'), | ||
commonPageMeta('user/login'), | ||
commonPageMeta('user/password-reminder'), | ||
commonPageMeta('user/registration'), | ||
...articles, | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,19 @@ | ||
import manifest from '@/root/package.json'; | ||
|
||
const isDev = process.env.NEXT_PUBLIC_IS_DEV === 'true'; | ||
let url = | ||
process.env.NEXT_PUBLIC_SITE_URL || 'https://www.themostannoyingwebsite.com'; | ||
if (isDev) { | ||
url = `https://localhost:${process.env.PORT || 3000}`; | ||
} | ||
|
||
const config = { | ||
contactEmail: 'info@themostannoyingwebsite.com', | ||
githubRepo: manifest.repository.url, | ||
defaultColorScheme: 'dark' as AppTheme, | ||
isBrowser: typeof window !== 'undefined', | ||
isDev, | ||
url, | ||
}; | ||
|
||
export default config; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.