Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import type { TFunction } from "i18next";
|
||||
import type { MetaTagsDto } from "~/application/dtos/seo/MetaTagsDto";
|
||||
import { t as i18nT } from "i18next";
|
||||
|
||||
type SiteTags = {
|
||||
title: string;
|
||||
description: string;
|
||||
keywords: string;
|
||||
image: string;
|
||||
thumbnail: string;
|
||||
twitterCreator: string;
|
||||
twitterSite: string;
|
||||
};
|
||||
|
||||
export function getDefaultSiteTags(): SiteTags {
|
||||
return {
|
||||
title: i18nT("seo.default.title"),
|
||||
description: i18nT("seo.default.description"),
|
||||
keywords: "react-router,tailwindcss,prisma,react,typescript,boilerplate,application-starter,admin-dashboard,multi-tenancy",
|
||||
image: "/android-chrome-512x512.png",
|
||||
thumbnail: "/android-chrome-512x512.png",
|
||||
twitterCreator: "",
|
||||
twitterSite: "",
|
||||
};
|
||||
}
|
||||
|
||||
export function defaultSeoMetaTags({ t, slug }: { t: TFunction; slug?: string }): MetaTagsDto {
|
||||
const siteTags = getDefaultSiteTags();
|
||||
void t;
|
||||
void slug;
|
||||
|
||||
return parseMetaTags(siteTags);
|
||||
}
|
||||
|
||||
function parseMetaTags(tags: SiteTags): MetaTagsDto {
|
||||
return [
|
||||
{ title: tags.title },
|
||||
{ name: "description", content: tags.description },
|
||||
{ name: "keywords", content: tags.keywords },
|
||||
{ property: "og:title", content: tags.title },
|
||||
{ property: "og:type", content: "website" },
|
||||
{ property: "og:image", content: tags.image },
|
||||
{ property: "og:card", content: "summary_large_image" },
|
||||
{ property: "og:description", content: tags.description },
|
||||
{ property: "twitter:image", content: tags.thumbnail },
|
||||
{ property: "twitter:card", content: "summary_large_image" },
|
||||
{ property: "twitter:creator", content: tags.twitterCreator ?? "" },
|
||||
{ property: "og:creator", content: tags.twitterCreator },
|
||||
{ property: "twitter:site", content: tags.twitterSite ?? "" },
|
||||
{ property: "twitter:title", content: tags.title },
|
||||
{ property: "twitter:description", content: tags.description },
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import { MetaTagsDto } from "~/application/dtos/seo/MetaTagsDto";
|
||||
import { i18nConfig } from "~/locale/i18n";
|
||||
import { getBaseURL } from "~/utils/url.server";
|
||||
|
||||
export function getLinkTags(request: Request) {
|
||||
const baseUrl = getBaseURL(request, { https: true });
|
||||
const urlObj = new URL(request.url);
|
||||
const pathname = `${baseUrl}${urlObj.pathname}`;
|
||||
const searchParams = urlObj.searchParams;
|
||||
const lng = searchParams.get("lng") ?? i18nConfig.fallbackLng;
|
||||
const linkTags: MetaTagsDto = [];
|
||||
|
||||
const canonicalHref = lng === i18nConfig.fallbackLng ? pathname : `${pathname}?lng=${lng}`;
|
||||
linkTags.push({ property: "og:locale", content: lng });
|
||||
linkTags.push({ tagName: "link", rel: "canonical", href: canonicalHref });
|
||||
linkTags.push({ property: "og:url", content: canonicalHref });
|
||||
|
||||
i18nConfig.supportedLngs.forEach((supportedLng) => {
|
||||
const href = supportedLng === i18nConfig.fallbackLng ? pathname : `${pathname}?lng=${supportedLng}`;
|
||||
linkTags.push({ tagName: "link", rel: "alternate", href, hrefLang: supportedLng });
|
||||
});
|
||||
linkTags.push({ tagName: "link", rel: "alternate", href: pathname, hrefLang: "x-default" });
|
||||
|
||||
return linkTags;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
// @vitest-environment node
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { shouldNoindex, X_ROBOTS_TAG_NOINDEX } from "./noindex.server";
|
||||
|
||||
describe("AK-INFRA1 noindex gating", () => {
|
||||
it("noindexes only when WEB_NOINDEX is exactly 'true'", () => {
|
||||
expect(shouldNoindex({ WEB_NOINDEX: "true" })).toBe(true);
|
||||
expect(shouldNoindex({ WEB_NOINDEX: "false" })).toBe(false);
|
||||
expect(shouldNoindex({ WEB_NOINDEX: "1" })).toBe(false);
|
||||
expect(shouldNoindex({})).toBe(false);
|
||||
});
|
||||
|
||||
it("uses a standard noindex,nofollow tag value", () => {
|
||||
expect(X_ROBOTS_TAG_NOINDEX).toBe("noindex, nofollow");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
// AK-INFRA1 (Staging-Härtung) — Nicht-Produktiv-Umgebungen (Staging) dürfen nicht von Suchmaschinen
|
||||
// indexiert werden. Gate über ein EXPLIZITES Env-Flag `WEB_NOINDEX` (auf Staging in Coolify gesetzt),
|
||||
// bewusst statt Host-String-Matching: explizit, testbar, und prod bleibt ohne Flag indexierbar.
|
||||
//
|
||||
// Durchgesetzt über den `X-Robots-Tag: noindex, nofollow`-Header auf jeder SSR-HTML-Antwort
|
||||
// (siehe entry.server.tsx). Das ist der verlaessliche Mechanismus; robots.txt bleibt statisch
|
||||
// (public/robots.txt) und env-unabhaengig, da der Header den noindex ohnehin erzwingt.
|
||||
|
||||
export const X_ROBOTS_TAG_NOINDEX = "noindex, nofollow";
|
||||
|
||||
export function shouldNoindex(env: Record<string, string | undefined> = process.env): boolean {
|
||||
return env.WEB_NOINDEX === "true";
|
||||
}
|
||||
Reference in new issue
Block a user