@devalon.dev/credits 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -2
- package/dist/chunk-QU6SEFG7.mjs +16 -0
- package/dist/chunk-SHIXBOQB.mjs +1 -0
- package/dist/chunk-YF7SVQTC.mjs +11 -0
- package/dist/core/agent-files.d.ts +46 -0
- package/dist/core/alternates.d.ts +4 -0
- package/dist/core/backlink.d.ts +24 -0
- package/dist/core/escape.d.ts +2 -0
- package/dist/core/headers.d.ts +34 -0
- package/dist/core/html.d.ts +27 -0
- package/dist/core/index.d.ts +13 -0
- package/dist/core/json-ld.d.ts +11 -0
- package/dist/core/url.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.mjs +1 -0
- package/dist/next/agent-files.d.ts +2 -0
- package/dist/next/alternates.d.ts +4 -0
- package/dist/next/backlink.d.ts +5 -0
- package/dist/next/headers.d.ts +2 -0
- package/dist/next/index.d.ts +10 -0
- package/dist/next/index.js +16 -0
- package/dist/next/index.mjs +1 -0
- package/dist/next/json-ld.d.ts +5 -0
- package/dist/next/schema.d.ts +1 -0
- package/dist/next/types.d.ts +1 -0
- package/dist/react/agent-files.d.ts +2 -0
- package/dist/react/alternates.d.ts +5 -0
- package/dist/react/backlink.d.ts +5 -0
- package/dist/react/headers.d.ts +2 -0
- package/dist/react/html.d.ts +2 -0
- package/dist/react/index.d.ts +14 -0
- package/dist/react/index.js +26 -0
- package/dist/react/index.mjs +1 -0
- package/dist/react/json-ld.d.ts +5 -0
- package/dist/react/schema.d.ts +1 -0
- package/dist/react/types.d.ts +1 -0
- package/dist/schema.d.ts +1183 -0
- package/dist/types.d.ts +75 -0
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.js +32 -0
- package/dist/vite/index.mjs +7 -0
- package/dist/vite/plugin.d.ts +51 -0
- package/docs/nextjs/01-app-router.md +101 -0
- package/docs/nextjs/02-app-router-i18n.md +166 -0
- package/docs/nextjs/03-pages-router.md +127 -0
- package/docs/nextjs/04-metadata-and-csp.md +113 -0
- package/docs/nextjs/05-performance-checklist.md +67 -0
- package/docs/nextjs/06-backlink-component.md +203 -0
- package/docs/nextjs/07-validator.md +55 -0
- package/docs/nextjs/08-server-headers.md +122 -0
- package/docs/nextjs/09-llms-and-humans-txt.md +163 -0
- package/docs/react/01-ssr-setup.md +112 -0
- package/docs/react/02-csr-vite.md +116 -0
- package/docs/react/03-i18n.md +104 -0
- package/docs/react/04-metadata-and-csp.md +105 -0
- package/docs/react/05-backlink-component.md +89 -0
- package/docs/react/06-server-headers.md +150 -0
- package/docs/react/07-agent-files.md +136 -0
- package/docs/react/08-validator.md +56 -0
- package/docs/react/09-performance-checklist.md +76 -0
- package/package.json +71 -4
- package/scripts/check-devalon-credits.mjs +175 -0
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# 07 — Credit link validator
|
|
2
|
+
|
|
3
|
+
**When to read this:** before adding a Devalon credit link to a client site, and again after deployment.
|
|
4
|
+
|
|
5
|
+
A credit link on a dead, blocked or unindexed site sends no traffic and adds no signal. This script catches that before you ship.
|
|
6
|
+
|
|
7
|
+
## Run it
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
yarn check:credits https://client.com
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
After deployment, also verify that the link and the JSON-LD are actually in the served HTML:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
yarn check:credits https://client.com --deployed
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
From an installed package, the same tool is available as:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
npx devalon-check https://client.com --deployed
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## What it checks
|
|
26
|
+
|
|
27
|
+
| Check | Result |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| URL is absolute http(s) | error → stop |
|
|
30
|
+
| Site responds with HTTP 2xx/3xx | error if not |
|
|
31
|
+
| No `<meta name="robots" content="noindex">` (also `googlebot`) | error if present |
|
|
32
|
+
| `robots.txt` does not `Disallow: /` for `User-agent: *` | error if blocked |
|
|
33
|
+
| `/sitemap.xml` exists and is a urlset/sitemapindex | warning if missing |
|
|
34
|
+
| With `--deployed`: `devalon.dev` link present in raw HTML | error if missing |
|
|
35
|
+
| With `--deployed`: `application/ld+json` present in raw HTML | error if missing |
|
|
36
|
+
| With `--deployed`: `X-Devalon-Creator` / `X-Devalon-Project` headers | warning if missing (headers are optional) |
|
|
37
|
+
| With `--deployed`: `X-Built-By` and `Link: rel="author"` | warning if missing |
|
|
38
|
+
| With `--deployed`: `/llms.txt` exists and mentions Devalon | warning if missing |
|
|
39
|
+
|
|
40
|
+
Exit code is `1` if any error was found, `0` otherwise. Warnings do not fail the check.
|
|
41
|
+
|
|
42
|
+
## Interpreting failures
|
|
43
|
+
|
|
44
|
+
- **HTTP error** — the site is down, behind auth, or blocks automated clients. Confirm manually in a browser.
|
|
45
|
+
- **noindex** — remove it or choose another page; search engines will not index the credit link.
|
|
46
|
+
- **robots.txt disallows /** — a credit link there will never be crawled.
|
|
47
|
+
- **No sitemap** — add one; the credit page is still crawlable via links, but discovery is slower.
|
|
48
|
+
- **No devalon.dev link with `--deployed`** — the component was not rendered on this URL, or the HTML is generated only on the client (never inject the credit with `useEffect`).
|
|
49
|
+
- **No JSON-LD with `--deployed`** — `DevalonJsonLd` is missing from the layout, or the page was rendered dynamically in a way that strips the script.
|
|
50
|
+
|
|
51
|
+
## Good-to-know
|
|
52
|
+
|
|
53
|
+
- The script is dependency-free and uses Node's built-in `fetch` (Node 18+).
|
|
54
|
+
- Requests time out after 10 seconds.
|
|
55
|
+
- It does not modify any files and does not send data anywhere.
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# 08 — Server utility: Devalon response headers
|
|
2
|
+
|
|
3
|
+
**When to read this:** you want `curl -I` (or your CDN, audit tooling, validator) to state who built the site and in what language, without adding any React code.
|
|
4
|
+
|
|
5
|
+
This is a **server utility**, not a component. It writes HTTP response headers to a `Response` / `NextResponse`. There is no JSX, no `"use client"`, no hydration.
|
|
6
|
+
|
|
7
|
+
## Middleware (recommended for multi-language sites)
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
// middleware.ts
|
|
11
|
+
import { NextResponse, type NextRequest } from "next/server";
|
|
12
|
+
import { withDevalonHeaders } from "@devalon.dev/credits/next";
|
|
13
|
+
|
|
14
|
+
const devalonConfig = {
|
|
15
|
+
site_url: "https://example.com",
|
|
16
|
+
services: ["web_development", "ai_agents_automation"] as const,
|
|
17
|
+
contributions: ["developing", "maintaining"] as const,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export function middleware(request: NextRequest) {
|
|
21
|
+
const response = NextResponse.next();
|
|
22
|
+
const segment = request.nextUrl.pathname.split("/")[1]; // ro | ru | en
|
|
23
|
+
const locale = ["ro", "ru", "en"].includes(segment)
|
|
24
|
+
? (segment as "ro" | "ru" | "en")
|
|
25
|
+
: "en";
|
|
26
|
+
|
|
27
|
+
return withDevalonHeaders(response, { ...devalonConfig, locale });
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Next.js requires this exact export name for middleware configuration.
|
|
31
|
+
export const config = {
|
|
32
|
+
matcher: ["/((?!_next/static|_next/image|favicon.ico).*)"],
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The `matcher` keeps middleware away from static assets, so the extra work happens only on page requests.
|
|
37
|
+
|
|
38
|
+
## Static alternative (`next.config.ts`)
|
|
39
|
+
|
|
40
|
+
If you do not need the locale per request, skip middleware entirely:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { devalonHeadersConfig } from "@devalon.dev/credits/next";
|
|
44
|
+
|
|
45
|
+
export default {
|
|
46
|
+
async headers() {
|
|
47
|
+
return [
|
|
48
|
+
{
|
|
49
|
+
source: "/:path*",
|
|
50
|
+
headers: devalonHeadersConfig({
|
|
51
|
+
site_url: "https://example.com",
|
|
52
|
+
services: ["web_development"],
|
|
53
|
+
contributions: ["developing", "maintaining"],
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Zero runtime cost — the headers are baked into the framework config at build time. The tradeoff: no `X-Devalon-Locale` per page.
|
|
62
|
+
|
|
63
|
+
## Headers emitted
|
|
64
|
+
|
|
65
|
+
```
|
|
66
|
+
X-Devalon-Creator: Devalon
|
|
67
|
+
X-Devalon-Creator-Url: https://devalon.dev
|
|
68
|
+
X-Devalon-Creator-Id: https://devalon.dev/#organization
|
|
69
|
+
X-Devalon-Project: https://example.com
|
|
70
|
+
X-Devalon-Services: web_development, ai_agents_automation
|
|
71
|
+
X-Devalon-Contributions: developing, maintaining
|
|
72
|
+
X-Devalon-Relationships: creator, provider
|
|
73
|
+
X-Devalon-Locale: ro
|
|
74
|
+
X-Built-By: Devalon (https://devalon.dev)
|
|
75
|
+
Link: <https://devalon.dev>; rel="author"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
- `Services` are canonicalized: legacy aliases resolve to the current key, duplicates are removed.
|
|
79
|
+
- `Relationships` come from the same contribution mapping used by the JSON-LD graph (`creator` / `maintainer` / `provider`).
|
|
80
|
+
- `X-Devalon-Locale` is emitted only when `locale` is provided; it accepts all 7 supported languages (`en`, `ro`, `ru`, `de`, `da`, `fr`, `es`).
|
|
81
|
+
- Empty `services`, `contributions` or resolved relationships omit their respective header. `contributions` defaults to `["development", "engineering"]`.
|
|
82
|
+
- All values are ASCII (URLs, keys, locales) so `Headers` never rejects diacritics. The client name lives in the JSON-LD, not in headers.
|
|
83
|
+
- `X-Built-By` is a plain custom header: brand plus URL, no framework/runtime versions, so it does not add stack fingerprinting.
|
|
84
|
+
- `Link: <https://devalon.dev>; rel="author"` uses a registered link relation (Web Linking). In middleware, `withDevalonHeaders` **appends** it to any existing `Link` header instead of overwriting it. With the static `next.config.ts` variant, keep this in mind if you already set `Link` headers.
|
|
85
|
+
- Neither header is a Google ranking signal. They are operational metadata — see [09 — llms.txt and humans.txt](09-llms-and-humans-txt.md) for the identity files agents read.
|
|
86
|
+
|
|
87
|
+
### CDN / platform caveat
|
|
88
|
+
|
|
89
|
+
Vercel, Cloudflare, Coolify or a reverse proxy can rewrite or strip custom headers. After deployment, verify on the real URL:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
curl -sI https://client.com/ro | grep -iE 'x-devalon|x-built-by|^link'
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
If a header is missing, the platform is filtering it — not the code. The JSON-LD and the visible credit are not affected.
|
|
96
|
+
|
|
97
|
+
## Verify
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
curl -sI http://localhost:3000/ro | grep -i '^x-devalon'
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Expect the block above. The validator also checks the creator header after deployment:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
yarn check:credits https://client.com --deployed
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## What this is — and is not
|
|
110
|
+
|
|
111
|
+
- ✅ Operational metadata: instant provenance via `curl -I`, inventory of deployed projects, audit and CDN/debugging checks.
|
|
112
|
+
- ❌ **Not an SEO ranking factor.** Google ignores custom `X-` headers. They do not replace `DevalonJsonLd` or the visible credit link.
|
|
113
|
+
|
|
114
|
+
## Common mistakes
|
|
115
|
+
|
|
116
|
+
| Don't | Do |
|
|
117
|
+
| --- | --- |
|
|
118
|
+
| Expect headers to affect rankings. | Use the JSON-LD component for entity signals. |
|
|
119
|
+
| Export the middleware config as `configMatcher`. | Next.js requires `export const config = { matcher: [...] }`. |
|
|
120
|
+
| Run middleware on `_next/static` assets. | Add the `matcher` exclusion. |
|
|
121
|
+
| Pass a relative `site_url`. | Pass an absolute `https://...` URL. |
|
|
122
|
+
| Put a client name with diacritics in a header. | Keep it in JSON-LD; headers carry ASCII identifiers only. |
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# 09 — llms.txt and humans.txt generated at build
|
|
2
|
+
|
|
3
|
+
**When to read this:** you want AI agents and curious humans to find an explicit credit, without anyone manually editing a text file.
|
|
4
|
+
|
|
5
|
+
These are **plain-text identity files**, not ranking factors. They complement (never replace) `DevalonJsonLd` and the visible footer credit.
|
|
6
|
+
|
|
7
|
+
## The idea
|
|
8
|
+
|
|
9
|
+
A route handler at `app/llms.txt/route.ts` becomes a real endpoint at `/llms.txt`. With `export const dynamic = "force-static"`, Next.js calls `GET()` **once, at `next build`**, takes the returned body and writes it as a static file. At runtime nothing executes — the result is indistinguishable from a file in `public/`, but it was generated from code.
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
client's original text (source) ──► mergeDevalonLlmsTxt ──► static /llms.txt
|
|
13
|
+
▲
|
|
14
|
+
Devalon credit block
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
No copy-paste after setup. The client owns the source text; the library owns the transformation.
|
|
18
|
+
|
|
19
|
+
## Recommended: App Router route handler
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
// app/llms.txt/route.ts
|
|
23
|
+
import { devalonLlmsTxtResponse } from "@devalon.dev/credits/next";
|
|
24
|
+
|
|
25
|
+
export const dynamic = "force-static";
|
|
26
|
+
|
|
27
|
+
export function GET() {
|
|
28
|
+
return devalonLlmsTxtResponse({
|
|
29
|
+
site_url: "https://example.com",
|
|
30
|
+
site_name: "Example Inc.",
|
|
31
|
+
description: "Custom CRM and booking platform for clinics.",
|
|
32
|
+
services: ["web_development", "ai_agents_automation"] as const,
|
|
33
|
+
// source: existing client text, if there is any
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For `humans.txt`, use `devalonHumansTxtResponse` in `app/humans.txt/route.ts`:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
import { devalonHumansTxtResponse } from "@devalon.dev/credits/next";
|
|
42
|
+
|
|
43
|
+
export const dynamic = "force-static";
|
|
44
|
+
|
|
45
|
+
export function GET() {
|
|
46
|
+
return devalonHumansTxtResponse({
|
|
47
|
+
site_url: "https://example.com",
|
|
48
|
+
site_name: "Example Inc.",
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Both helpers return a `Response` with `Content-Type: text/plain; charset=utf-8`. No manual text editing, no `useEffect`, no middleware body rewriting.
|
|
54
|
+
|
|
55
|
+
## Where the client's text comes from
|
|
56
|
+
|
|
57
|
+
`source` is just a string. Pick one place and keep it there:
|
|
58
|
+
|
|
59
|
+
| Source | How | When to use |
|
|
60
|
+
| --- | --- | --- |
|
|
61
|
+
| Constant in the route file | `source: "# Client\n\n> ..."` | Short, rarely changing text |
|
|
62
|
+
| File in the repo | `readFile("content/llms.md", "utf8")` with `runtime = "nodejs"` | Versioned, editor-friendly |
|
|
63
|
+
| CMS / API | `fetch(...)` at build with `force-static` | Editors outside the codebase |
|
|
64
|
+
|
|
65
|
+
Example with a file source:
|
|
66
|
+
|
|
67
|
+
```ts
|
|
68
|
+
// app/llms.txt/route.ts
|
|
69
|
+
import { readFile } from "node:fs/promises";
|
|
70
|
+
import path from "node:path";
|
|
71
|
+
import { devalonLlmsTxtResponse } from "@devalon.dev/credits/next";
|
|
72
|
+
|
|
73
|
+
export const runtime = "nodejs";
|
|
74
|
+
export const dynamic = "force-static";
|
|
75
|
+
|
|
76
|
+
export async function GET() {
|
|
77
|
+
const source = await readFile(
|
|
78
|
+
path.join(process.cwd(), "content/llms.md"),
|
|
79
|
+
"utf8",
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return devalonLlmsTxtResponse({
|
|
83
|
+
site_url: "https://example.com",
|
|
84
|
+
site_name: "Example Inc.",
|
|
85
|
+
source,
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
If `source` is omitted or empty, the helper generates a complete file (H1, description, canonical URL, credit block). So the same route works whether or not a file existed before.
|
|
91
|
+
|
|
92
|
+
## The merge is idempotent
|
|
93
|
+
|
|
94
|
+
The credit is wrapped in markers:
|
|
95
|
+
|
|
96
|
+
```md
|
|
97
|
+
<!-- devalon:start -->
|
|
98
|
+
## Credits
|
|
99
|
+
|
|
100
|
+
Built and maintained by [Devalon](https://devalon.dev), an AI & software development studio.
|
|
101
|
+
Services: Web Development, AI Agents & Automation.
|
|
102
|
+
<!-- devalon:end -->
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
`mergeDevalonLlmsTxt` replaces only what is between the markers, or appends the block if the markers are absent. Running the build 100 times produces the same file — no duplicate credits. For `humans.txt` the markers are `/* devalon:start */` and `/* devalon:end */`, and the block is inserted into an existing `/* TEAM */` section when one exists.
|
|
106
|
+
|
|
107
|
+
## If the site already has `public/llms.txt`
|
|
108
|
+
|
|
109
|
+
A route handler and a public file at the same path collide: Next.js warns about the conflict and the route wins, leaving the public file dead. Do this **once**:
|
|
110
|
+
|
|
111
|
+
1. Move the client's text from `public/llms.txt` to `content/llms.md` (or into a constant);
|
|
112
|
+
2. Let the route handler serve `/llms.txt` using that text as `source`;
|
|
113
|
+
3. Remove `public/llms.txt`.
|
|
114
|
+
|
|
115
|
+
The URL does not change, so any existing links to `/llms.txt` keep working.
|
|
116
|
+
|
|
117
|
+
## Who owns the file
|
|
118
|
+
|
|
119
|
+
| Situation | What to do |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| Has the file and controls it | Use a route handler with its text as `source`. No manual credit editing. |
|
|
122
|
+
| Has the file but a CMS/hosting provider manages it | Do not touch it. Ask its owner to paste `devalonLlmsBlock(config)`, or rely on JSON-LD + footer + headers instead. |
|
|
123
|
+
| Has no file | Use `devalonLlmsTxtResponse` / `devalonHumansTxtResponse` with no `source` — a full file is generated. |
|
|
124
|
+
| Does not want these files | Nothing happens. They are optional conventions; everything else still works. |
|
|
125
|
+
|
|
126
|
+
These helpers are **pure string transforms plus a `Response` wrapper** — they never read or write files on disk. Your route decides where the source comes from.
|
|
127
|
+
|
|
128
|
+
## Pages Router
|
|
129
|
+
|
|
130
|
+
There is no route handler here. Keep static files in `public/`, or run a build script that reads the existing file, calls `mergeDevalonLlmsTxt` / `mergeDevalonHumansTxt`, and writes the result. The generated output is still served as a plain static file.
|
|
131
|
+
|
|
132
|
+
## API
|
|
133
|
+
|
|
134
|
+
| Function | Use |
|
|
135
|
+
| --- | --- |
|
|
136
|
+
| `devalonLlmsBlock(config)` | Markdown fragment only, for pasting into an existing `llms.txt`. |
|
|
137
|
+
| `mergeDevalonLlmsTxt(existing, config)` | Idempotent insert/update of the marked block. |
|
|
138
|
+
| `devalonLlmsTxt(config)` | Whole file string, when there is no source. |
|
|
139
|
+
| `devalonLlmsTxtResponse(config)` | Ready `Response` for `app/llms.txt/route.ts`. |
|
|
140
|
+
| `devalonHumansBlock(config)` | Text fragment for an existing `humans.txt`. |
|
|
141
|
+
| `mergeDevalonHumansTxt(existing, config)` | Idempotent insert/update, prefers `/* TEAM */`. |
|
|
142
|
+
| `devalonHumansTxt(config)` | Whole file string, when there is no source. |
|
|
143
|
+
| `devalonHumansTxtResponse(config)` | Ready `Response` for `app/humans.txt/route.ts`. |
|
|
144
|
+
|
|
145
|
+
Config: `site_url` (absolute), `site_name`, optional `description`, `services`, `contributions`, `source`. Unknown service keys throw a `TypeError`.
|
|
146
|
+
|
|
147
|
+
## What this is — and is not
|
|
148
|
+
|
|
149
|
+
- ✅ Cheap, static, cacheable identity files generated at build, with attribution kept unambiguous for LLM crawlers and humans.
|
|
150
|
+
- ❌ Middleware cannot append to a pass-through response body. The route handler generates a new response instead — see [08 — Server headers](08-server-headers.md) for the header-only case.
|
|
151
|
+
- ❌ `llms.txt` is a **convention**, not an official standard. Google has not said it uses it for ranking.
|
|
152
|
+
- ❌ It does not replace JSON-LD (`creator` / `provider`) or the visible credit link.
|
|
153
|
+
|
|
154
|
+
## Verify
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
yarn build
|
|
158
|
+
curl -s https://client.com/llms.txt | grep -i devalon.dev
|
|
159
|
+
curl -s https://client.com/humans.txt | grep -i devalon.dev
|
|
160
|
+
yarn check:credits https://client.com --deployed
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
The validator reports missing files or a missing mention as **warnings**, not errors: the files belong to the client.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
# 01 — SSR setup (React without Next.js)
|
|
2
|
+
|
|
3
|
+
**When to read this:** you render React on the server — React DOM Server, Remix, Astro, TanStack Start, or a custom Express renderer — and need the Devalon credit in the served HTML.
|
|
4
|
+
|
|
5
|
+
`@devalon.dev/credits/react` has **no Next.js dependency**. Every capability is available in three forms, so you choose how much control you need:
|
|
6
|
+
|
|
7
|
+
| Level | API | Output |
|
|
8
|
+
| --- | --- | --- |
|
|
9
|
+
| Declarative | `DevalonJsonLd`, `DevalonAlternates`, `DevalonBacklink` | React elements, emitted wherever you render them |
|
|
10
|
+
| Explicit server | `devalonHeadHtml()`, `devalonBacklinkHtml()` | HTML strings you place in your own template |
|
|
11
|
+
| Build-time | `devalonInjectHtml()` or the Vite plugin | Injected into an existing HTML document, idempotently |
|
|
12
|
+
|
|
13
|
+
For SEO, only one thing matters: **the JSON-LD and the canonical/backlink must exist in the HTML the server sends**, before hydration. Prefer level 2 if your setup has no head manager.
|
|
14
|
+
|
|
15
|
+
## Recommended: explicit server injection
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
// server/render.tsx
|
|
19
|
+
import { renderToString } from "react-dom/server";
|
|
20
|
+
import {
|
|
21
|
+
devalonHeadHtml,
|
|
22
|
+
type devalon_head_html_config,
|
|
23
|
+
} from "@devalon.dev/credits/react";
|
|
24
|
+
import { App } from "../src/App";
|
|
25
|
+
|
|
26
|
+
export const devalonConfig: devalon_head_html_config = {
|
|
27
|
+
site_url: "https://example.com",
|
|
28
|
+
site_name: "Example Inc.",
|
|
29
|
+
in_language: "en",
|
|
30
|
+
page_url: "https://example.com/",
|
|
31
|
+
services: ["web_development"],
|
|
32
|
+
contributions: ["developing", "maintaining"],
|
|
33
|
+
alternates: {
|
|
34
|
+
canonical: "https://example.com/",
|
|
35
|
+
pages: { en: "https://example.com/", ro: "https://example.com/ro" },
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export function render() {
|
|
40
|
+
const app = renderToString(<App />);
|
|
41
|
+
|
|
42
|
+
return `<!doctype html>
|
|
43
|
+
<html lang="en">
|
|
44
|
+
<head><meta charset="utf-8" /><title>Example Inc.</title>${devalonHeadHtml(devalonConfig)}</head>
|
|
45
|
+
<body><div id="root">${app}</div></body>
|
|
46
|
+
</html>`;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`devalonHeadHtml()` returns the JSON-LD `<script>` plus, when `alternates` is set, the canonical and `hreflang` `<link>` tags. It escapes values, so a client name with diacritics is safe.
|
|
51
|
+
|
|
52
|
+
Render the visible credit inside the app tree; it is a normal server-rendered element:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
// src/App.tsx
|
|
56
|
+
import { DevalonBacklink } from "@devalon.dev/credits/react";
|
|
57
|
+
|
|
58
|
+
export function App() {
|
|
59
|
+
return (
|
|
60
|
+
<>
|
|
61
|
+
<main>…</main>
|
|
62
|
+
<footer><DevalonBacklink locale="en" /></footer>
|
|
63
|
+
</>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Alternative: inject into a finished HTML string
|
|
69
|
+
|
|
70
|
+
If you already have an HTML template (static site, custom renderer, CDN worker), use `devalonInjectHtml`:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
import { devalonInjectHtml } from "@devalon.dev/credits/react";
|
|
74
|
+
|
|
75
|
+
const html = readTemplate(); // ...<head></head>...<body>...</body>...
|
|
76
|
+
const served = devalonInjectHtml(html, {
|
|
77
|
+
...devalonConfig,
|
|
78
|
+
backlink: { locale: "en" },
|
|
79
|
+
});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- Head tags are inserted after the opening `<head>` (or at the top when there is no `<head>`).
|
|
83
|
+
- The backlink is inserted before `</body>` (or at the end when there is no `<body>`).
|
|
84
|
+
- Both blocks are wrapped in `<!-- devalon:head:start/end -->` and `<!-- devalon:backlink:start/end -->` markers. Running it again **replaces** the marked blocks instead of duplicating them.
|
|
85
|
+
|
|
86
|
+
## When the declarative components are enough
|
|
87
|
+
|
|
88
|
+
Frameworks with a head manager (Remix `meta`, Astro `<head>`, TanStack Start head, React 19 hoisting in supported setups) can use the components directly:
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { DevalonAlternates, DevalonJsonLd } from "@devalon.dev/credits/react";
|
|
92
|
+
|
|
93
|
+
<DevalonJsonLd {...credit} />
|
|
94
|
+
<DevalonAlternates canonical="https://example.com/" pages={{ en: "https://example.com/" }} />
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
If the tags do not appear in the server HTML (`curl` check below), switch to `devalonHeadHtml()` — it never depends on hoisting.
|
|
98
|
+
|
|
99
|
+
## Rules
|
|
100
|
+
|
|
101
|
+
1. Render the credit **once per URL**, not once in the layout and again in the page.
|
|
102
|
+
2. `site_url` is the canonical site root and never changes with language; `page_url` is the localized page.
|
|
103
|
+
3. No `"use client"`, no `useEffect`, no `document.createElement` — the markup must exist at render time.
|
|
104
|
+
4. If you use a CSP nonce, pass `nonce` to `devalonHeadHtml()` / `DevalonJsonLd` — see [04 — Metadata and CSP](04-metadata-and-csp.md).
|
|
105
|
+
|
|
106
|
+
## Verify
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
curl -s http://localhost:3000/ | grep -o 'application/ld+json'
|
|
110
|
+
curl -s http://localhost:3000/ | grep -o 'rel="canonical"'
|
|
111
|
+
curl -s http://localhost:3000/ | grep -o 'https://devalon.dev'
|
|
112
|
+
```
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# 02 — CSR / Vite (build-time injection)
|
|
2
|
+
|
|
3
|
+
**When to read this:** your app is a client-side React SPA built with Vite, and you still want the credit in the **initial HTML** — not inserted after hydration.
|
|
4
|
+
|
|
5
|
+
A pure CSR app has no server at request time, so the only place to put metadata is the build output. `@devalon.dev/credits/vite` does exactly that: it transforms `index.html` during `vite build` and writes the identity and header files into the output directory. It also installs response-header middleware in `vite dev` / `vite preview`. Nothing ships to the browser — all plugin hooks run in Node.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @devalon.dev/credits
|
|
11
|
+
# vite is an optional peer; you already have it in a Vite project
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
## Setup
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// vite.config.ts
|
|
18
|
+
import { defineConfig } from "vite";
|
|
19
|
+
import react from "@vitejs/plugin-react";
|
|
20
|
+
import { devalonVite } from "@devalon.dev/credits/vite";
|
|
21
|
+
|
|
22
|
+
export default defineConfig({
|
|
23
|
+
plugins: [
|
|
24
|
+
react(),
|
|
25
|
+
devalonVite({
|
|
26
|
+
site_url: "https://example.com",
|
|
27
|
+
site_name: "Example Inc.",
|
|
28
|
+
in_language: "en",
|
|
29
|
+
page_url: "https://example.com/",
|
|
30
|
+
services: ["web_development", "ai_agents_automation"],
|
|
31
|
+
contributions: ["developing", "maintaining"],
|
|
32
|
+
|
|
33
|
+
alternates: {
|
|
34
|
+
canonical: "https://example.com/",
|
|
35
|
+
pages: {
|
|
36
|
+
en: "https://example.com/",
|
|
37
|
+
ro: "https://example.com/ro",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
backlink: { locale: "ro" },
|
|
42
|
+
agentFilesConfig: {
|
|
43
|
+
description: "Custom CRM and booking platform for clinics.",
|
|
44
|
+
},
|
|
45
|
+
}),
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
After `vite build`:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
dist/index.html ← JSON-LD + canonical/hreflang in <head>, backlink before </body>
|
|
54
|
+
dist/llms.txt ← generated identity file
|
|
55
|
+
dist/humans.txt ← generated identity file
|
|
56
|
+
dist/_headers ← Devalon response headers for Netlify / Cloudflare Pages
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Plugin options
|
|
60
|
+
|
|
61
|
+
| Option | Required | Notes |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `site_url`, `site_name` | yes | Absolute canonical URL and client brand. Same config shape as `DevalonJsonLd`. |
|
|
64
|
+
| `in_language`, `page_url`, `services`, `contributions`, `custom_services` | no | Forwarded to the JSON-LD graph. |
|
|
65
|
+
| `alternates` | no | `devalon_alternates_config`: `canonical` + `pages`. Emits canonical/hreflang tags. |
|
|
66
|
+
| `nonce` | no | Added as the `nonce` attribute of the JSON-LD script. Useful for a strict CSP. |
|
|
67
|
+
| `backlink` | no | `devalon_backlink_props`. Omit it for a metadata-only integration. |
|
|
68
|
+
| `agentFiles` | no | Defaults to `true`. Set to `false` to skip writing `llms.txt` / `humans.txt`. |
|
|
69
|
+
| `agentFilesConfig` | no | Extra config for the identity files (`description`, `source`, …). Merged over the values above. |
|
|
70
|
+
| `humansSource` | no | Existing `humans.txt` text to merge into, when the client already has one. |
|
|
71
|
+
| `headers` | no | `true` by default: applies `devalonHeadersConfig()` as middleware in `vite dev` and `vite preview`. Pass `{ locale, localeFromPath }` to control the locale, or `false` to disable all header handling. |
|
|
72
|
+
| `headersFile` | no | `"_headers"` by default. `"vercel.json"`, `"all"` or `false` are also accepted. Written into `dist` at build. |
|
|
73
|
+
|
|
74
|
+
The plugin is **idempotent**: marked blocks are replaced on every build, so repeated builds never duplicate credits. `source` in `agentFilesConfig` is the client's own `llms.txt` text; the Devalon block is merged into it. Existing `_headers` / `vercel.json` content is preserved — see [06 — Server headers](06-server-headers.md).
|
|
75
|
+
|
|
76
|
+
## Without the plugin
|
|
77
|
+
|
|
78
|
+
`@devalon.dev/credits/react` exposes the pure transform if you prefer to wire your own build step:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
82
|
+
import { devalonAgentFiles, devalonInjectHtml } from "@devalon.dev/credits/react";
|
|
83
|
+
|
|
84
|
+
const html = await readFile("dist/index.html", "utf8");
|
|
85
|
+
await writeFile(
|
|
86
|
+
"dist/index.html",
|
|
87
|
+
devalonInjectHtml(html, {
|
|
88
|
+
site_url: "https://example.com",
|
|
89
|
+
site_name: "Example Inc.",
|
|
90
|
+
backlink: { locale: "en" },
|
|
91
|
+
}),
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
const files = devalonAgentFiles({
|
|
95
|
+
site_url: "https://example.com",
|
|
96
|
+
site_name: "Example Inc.",
|
|
97
|
+
});
|
|
98
|
+
// write files["llms.txt"] and files["humans.txt"] wherever you like
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Caveats
|
|
102
|
+
|
|
103
|
+
- `vite dev` applies the HTML transform and the header middleware, but it does **not** write files to `dist`. Inspect `dist/index.html` and `dist/_headers` after `yarn build` when verifying the production output.
|
|
104
|
+
- A static SPA has one HTML document for all routes. Use the site-level canonical URL, or generate one HTML per locale if you need per-language `hreflang`.
|
|
105
|
+
- The identity files are conventions, not ranking factors. They complement the JSON-LD and the visible credit — see [07 — Agent files](07-agent-files.md).
|
|
106
|
+
|
|
107
|
+
## Verify
|
|
108
|
+
|
|
109
|
+
```bash
|
|
110
|
+
yarn build
|
|
111
|
+
grep -o 'application/ld+json' dist/index.html
|
|
112
|
+
grep -o 'rel="canonical"' dist/index.html
|
|
113
|
+
grep -o 'https://devalon.dev' dist/index.html
|
|
114
|
+
grep -i devalon.dev dist/llms.txt dist/humans.txt
|
|
115
|
+
grep -i 'x-devalon' dist/_headers
|
|
116
|
+
```
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
# 03 — Multi-language sites (ro / ru / en)
|
|
2
|
+
|
|
3
|
+
**When to read this:** the client site serves several languages and the credit must follow the active locale.
|
|
4
|
+
|
|
5
|
+
The package supports 7 locales: `en`, `ro`, `ru`, `de`, `da`, `fr`, `es`. You can use any subset — expose only the languages your app actually serves.
|
|
6
|
+
|
|
7
|
+
## Two URLs, always distinct
|
|
8
|
+
|
|
9
|
+
- `site_url` — the canonical **site root**. It stays the same in every language.
|
|
10
|
+
- `page_url` — the canonical URL of the **localized page**. It changes with the language.
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
const SITE_URL = "https://example.com";
|
|
14
|
+
|
|
15
|
+
const configFor = (locale: "ro" | "ru" | "en") => ({
|
|
16
|
+
site_url: SITE_URL,
|
|
17
|
+
site_name: "Example Inc.",
|
|
18
|
+
in_language: locale,
|
|
19
|
+
page_url: `${SITE_URL}/${locale}`,
|
|
20
|
+
services: ["web_development"] as const,
|
|
21
|
+
contributions: ["developing", "maintaining"] as const,
|
|
22
|
+
alternates: {
|
|
23
|
+
canonical: `${SITE_URL}/${locale}`,
|
|
24
|
+
pages: {
|
|
25
|
+
ro: `${SITE_URL}/ro`,
|
|
26
|
+
ru: `${SITE_URL}/ru`,
|
|
27
|
+
en: `${SITE_URL}/en`,
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`build_devalon_alternates()` (used by `DevalonAlternates` and `devalonAlternatesHtml`) only emits `hreflang` entries for languages present in `pages`, in the canonical locale order. Passing a subset is correct.
|
|
34
|
+
|
|
35
|
+
## SSR with a per-locale route
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
// server/render.tsx — your router gives you the locale
|
|
39
|
+
import { devalonHeadHtml } from "@devalon.dev/credits/react";
|
|
40
|
+
|
|
41
|
+
export function render(locale: "ro" | "ru" | "en", appHtml: string) {
|
|
42
|
+
const config = configFor(locale);
|
|
43
|
+
|
|
44
|
+
return `<!doctype html>
|
|
45
|
+
<html lang="${locale}">
|
|
46
|
+
<head>${devalonHeadHtml(config)}<title>Example Inc.</title></head>
|
|
47
|
+
<body><div id="root">${appHtml}</div></body>
|
|
48
|
+
</html>`;
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Render the visible backlink with the same locale:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { DevalonBacklink } from "@devalon.dev/credits/react";
|
|
56
|
+
|
|
57
|
+
<DevalonBacklink locale={locale} />
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
If you enable `utm`, keep `site_url` identical in every language — only the hostname becomes `utm_source`, so a different root would split your referral data.
|
|
61
|
+
|
|
62
|
+
## Per-request headers
|
|
63
|
+
|
|
64
|
+
For SSR frameworks, attach the locale to the response:
|
|
65
|
+
|
|
66
|
+
```ts
|
|
67
|
+
import { withDevalonHeaders } from "@devalon.dev/credits/react";
|
|
68
|
+
|
|
69
|
+
const response = new Response(html, {
|
|
70
|
+
headers: { "Content-Type": "text/html; charset=utf-8" },
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
withDevalonHeaders(response, {
|
|
74
|
+
site_url: SITE_URL,
|
|
75
|
+
locale,
|
|
76
|
+
services: ["web_development"],
|
|
77
|
+
contributions: ["developing", "maintaining"],
|
|
78
|
+
});
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
See [06 — Server headers](06-server-headers.md) for Express / CDN variants.
|
|
82
|
+
|
|
83
|
+
## Built-in backlink sentences
|
|
84
|
+
|
|
85
|
+
| locale | sentence |
|
|
86
|
+
| --- | --- |
|
|
87
|
+
| `en` | This site was designed and built by |
|
|
88
|
+
| `ro` | Acest site a fost proiectat și construit de |
|
|
89
|
+
| `ru` | Этот сайт спроектирован и разработан |
|
|
90
|
+
| `de` | Diese Website wurde entworfen und entwickelt von |
|
|
91
|
+
| `da` | Denne hjemmeside er designet og udviklet af |
|
|
92
|
+
| `fr` | Ce site a été conçu et développé par |
|
|
93
|
+
| `es` | Este sitio fue diseñado y desarrollado por |
|
|
94
|
+
|
|
95
|
+
Override any of them with `sentence`, or pass `anchor` to change the link text.
|
|
96
|
+
|
|
97
|
+
## Common mistakes
|
|
98
|
+
|
|
99
|
+
| Don't | Do |
|
|
100
|
+
| --- | --- |
|
|
101
|
+
| Change `site_url` per language. | Keep it constant; change `page_url` and `alternates.canonical`. |
|
|
102
|
+
| Emit hreflang for languages the site does not serve. | Pass only the real pages in `alternates.pages`. |
|
|
103
|
+
| Render the credit in every page component. | Render once per URL, in the shared layout/header. |
|
|
104
|
+
| Pass an arbitrary string as `locale`. | Use one of the 7 supported codes; invalid values throw `TypeError`. |
|