Give every public route its own description, and keep canonicals and structured data on the host that serves the page.
Decorative images on the marketing pages stay quiet, and every dialog close button is named Close. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
0b6e8b00dd
commit
c180e79c38
52 files changed
+363
-209
No files matched your search
@@ -1,8 +1,10 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import metadataMessages from "../../messages/en/metadata.json";
|
||||
import {
|
||||
absoluteSiteUrl,
|
||||
articleShareImages,
|
||||
buildRobots,
|
||||
configuredSiteOrigin,
|
||||
metadataBaseUrl,
|
||||
NO_INDEX_ROBOTS,
|
||||
originFromHost,
|
||||
@@ -12,6 +14,7 @@ import {
|
||||
routeMetadata,
|
||||
sitemapUrl,
|
||||
templatesShareImages,
|
||||
websiteJsonLd,
|
||||
} from "../../lib/siteMetadata";
|
||||
|
||||
const ORIGINAL_SITE_INDEXING = process.env.SITE_INDEXING;
|
||||
@@ -66,6 +69,9 @@ describe("routeMetadata", () => {
|
||||
});
|
||||
expect(meta.title).toBe("Learn");
|
||||
expect(meta.description).toBe("Copy");
|
||||
expect(meta.openGraph?.description).toBe("Copy");
|
||||
expect(meta.openGraph?.title).toBe("Learn");
|
||||
expect(meta.twitter?.description).toBe("Copy");
|
||||
expect(meta.alternates?.canonical).toBe("/learn");
|
||||
expect(meta.openGraph?.url).toBe("/learn");
|
||||
});
|
||||
@@ -99,6 +105,32 @@ describe("routeMetadata", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("absoluteSiteUrl", () => {
|
||||
it("uses the configured origin, which is production when no app origin is set", () => {
|
||||
delete process.env.CLOUDRON_APP_ORIGIN;
|
||||
expect(PRODUCTION_SITE_ORIGIN).toBe("https://communityrule.info");
|
||||
expect(configuredSiteOrigin()).toBe(PRODUCTION_SITE_ORIGIN);
|
||||
expect(absoluteSiteUrl("/")).toBe("https://communityrule.info");
|
||||
expect(absoluteSiteUrl("/about")).toBe("https://communityrule.info/about");
|
||||
});
|
||||
|
||||
it("follows CLOUDRON_APP_ORIGIN so a staging build does not advertise production", () => {
|
||||
process.env.CLOUDRON_APP_ORIGIN = "https://staging.communityrule.info";
|
||||
expect(absoluteSiteUrl("/learn")).toBe(
|
||||
"https://staging.communityrule.info/learn",
|
||||
);
|
||||
});
|
||||
|
||||
it("builds a WebSite block with no search action", () => {
|
||||
expect(websiteJsonLd("https://communityrule.info")).toEqual({
|
||||
"@context": "https://schema.org",
|
||||
"@type": "WebSite",
|
||||
name: "CommunityRule",
|
||||
url: "https://communityrule.info",
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("sitemapUrl", () => {
|
||||
it("resolves paths against the production origin", () => {
|
||||
expect(sitemapUrl("/")).toBe(PRODUCTION_SITE_ORIGIN);
|
||||
@@ -137,7 +169,8 @@ describe("originFromHost", () => {
|
||||
expect(originFromHost("staging.communityrule.info")).toBe(
|
||||
"https://staging.communityrule.info",
|
||||
);
|
||||
expect(originFromHost("communityrule.com")).toBe(PRODUCTION_SITE_ORIGIN);
|
||||
expect(originFromHost("communityrule.info")).toBe(PRODUCTION_SITE_ORIGIN);
|
||||
expect(originFromHost("communityrule.com")).toBe("https://communityrule.com");
|
||||
});
|
||||
|
||||
it("keeps http for localhost so local previews resolve", () => {
|
||||
|
||||
Reference in new issue
Block a user