@hamur/seo 0.0.0-stage → 0.0.1
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/LICENSE +22 -0
- package/README.md +26 -2
- package/dist/chunks/bun-index-rnjhv41c.js +62 -0
- package/dist/chunks/bun-index-xf4srhvn.js +97 -0
- package/dist/src/adapters/html.js +40 -0
- package/dist/src/adapters/preact.js +36 -0
- package/dist/src/adapters/react.js +36 -0
- package/dist/src/adapters/solid.js +35 -0
- package/dist/src/adapters/svelte.js +35 -0
- package/dist/src/adapters/vue.js +43 -0
- package/dist/src/index.js +1375 -0
- package/dist/src/schema.js +51 -0
- package/dist/src/server/index.js +1 -0
- package/dist/src/share.js +40 -0
- package/dist/types/src/adapters/html.d.ts +6 -0
- package/dist/types/src/adapters/preact.d.ts +5 -0
- package/dist/types/src/adapters/react.d.ts +5 -0
- package/dist/types/src/adapters/solid.d.ts +6 -0
- package/dist/types/src/adapters/svelte.d.ts +5 -0
- package/dist/types/src/adapters/vue.d.ts +9 -0
- package/dist/types/src/build/links.d.ts +4 -0
- package/dist/types/src/build/llms.d.ts +6 -0
- package/dist/types/src/build/own.d.ts +5 -0
- package/dist/types/src/build/robots.d.ts +3 -0
- package/dist/types/src/build/schema.d.ts +4 -0
- package/dist/types/src/build/sitemap.d.ts +7 -0
- package/dist/types/src/index.d.ts +2 -0
- package/dist/types/src/links/check.d.ts +7 -0
- package/dist/types/src/links/external.d.ts +6 -0
- package/dist/types/src/links/options.d.ts +12 -0
- package/dist/types/src/links/report.d.ts +4 -0
- package/dist/types/src/links/scan.d.ts +24 -0
- package/dist/types/src/llms/options.d.ts +9 -0
- package/dist/types/src/llms/paths.d.ts +8 -0
- package/dist/types/src/llms/text.d.ts +12 -0
- package/dist/types/src/module.d.ts +3 -0
- package/dist/types/src/robots/ai-bots.d.ts +2 -0
- package/dist/types/src/robots/body.d.ts +16 -0
- package/dist/types/src/robots/options.d.ts +9 -0
- package/dist/types/src/runtime/breadcrumbs.d.ts +37 -0
- package/dist/types/src/runtime/markdown.d.ts +15 -0
- package/dist/types/src/runtime/schema-plugin.d.ts +2 -0
- package/dist/types/src/runtime/schema-store.d.ts +34 -0
- package/dist/types/src/schema/graph.d.ts +13 -0
- package/dist/types/src/schema/helpers.d.ts +358 -0
- package/dist/types/src/schema/options.d.ts +7 -0
- package/dist/types/src/schema.d.ts +10 -0
- package/dist/types/src/server/agent.d.ts +4 -0
- package/dist/types/src/server/door.d.ts +5 -0
- package/dist/types/src/server/index.d.ts +1 -0
- package/dist/types/src/server/llms.d.ts +2 -0
- package/dist/types/src/server/render.d.ts +9 -0
- package/dist/types/src/server/robots.d.ts +1 -0
- package/dist/types/src/server/sitemap.d.ts +5 -0
- package/dist/types/src/share.d.ts +18 -0
- package/dist/types/src/sitemap/alternates.d.ts +14 -0
- package/dist/types/src/sitemap/answer.d.ts +6 -0
- package/dist/types/src/sitemap/entries.d.ts +9 -0
- package/dist/types/src/sitemap/options.d.ts +7 -0
- package/dist/types/src/sitemap/paths.d.ts +13 -0
- package/dist/types/src/sitemap/xml.d.ts +23 -0
- package/dist/types/src/types.d.ts +73 -0
- package/package.json +106 -4
- package/src/adapters/html.ts +43 -0
- package/src/adapters/preact.ts +37 -0
- package/src/adapters/react.ts +37 -0
- package/src/adapters/solid.ts +38 -0
- package/src/adapters/svelte.ts +37 -0
- package/src/adapters/vue.ts +55 -0
- package/src/build/links.ts +13 -0
- package/src/build/llms.ts +79 -0
- package/src/build/own.ts +46 -0
- package/src/build/robots.ts +58 -0
- package/src/build/schema.ts +23 -0
- package/src/build/sitemap.ts +101 -0
- package/src/env.d.ts +44 -0
- package/src/index.ts +14 -0
- package/src/links/check.ts +233 -0
- package/src/links/external.ts +41 -0
- package/src/links/options.ts +69 -0
- package/src/links/report.ts +49 -0
- package/src/links/scan.ts +123 -0
- package/src/llms/options.ts +49 -0
- package/src/llms/paths.ts +33 -0
- package/src/llms/text.ts +26 -0
- package/src/module.ts +22 -0
- package/src/robots/ai-bots.ts +14 -0
- package/src/robots/body.ts +51 -0
- package/src/robots/options.ts +75 -0
- package/src/runtime/breadcrumbs.ts +84 -0
- package/src/runtime/markdown.ts +381 -0
- package/src/runtime/schema-plugin.ts +22 -0
- package/src/runtime/schema-store.ts +144 -0
- package/src/schema/graph.ts +125 -0
- package/src/schema/helpers.ts +372 -0
- package/src/schema/options.ts +39 -0
- package/src/schema.ts +5 -0
- package/src/server/agent.ts +45 -0
- package/src/server/door.ts +8 -0
- package/src/server/index.ts +1 -0
- package/src/server/llms.ts +139 -0
- package/src/server/render.ts +33 -0
- package/src/server/robots.ts +19 -0
- package/src/server/sitemap.ts +222 -0
- package/src/share.ts +56 -0
- package/src/sitemap/alternates.ts +66 -0
- package/src/sitemap/answer.ts +42 -0
- package/src/sitemap/entries.ts +136 -0
- package/src/sitemap/options.ts +47 -0
- package/src/sitemap/paths.ts +39 -0
- package/src/sitemap/xml.ts +71 -0
- package/src/types.ts +89 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import {
|
|
3
|
+
defineWebSite2,
|
|
4
|
+
defineWebPage2,
|
|
5
|
+
defineOrganization2,
|
|
6
|
+
definePerson2,
|
|
7
|
+
defineLocalBusiness2,
|
|
8
|
+
defineArticle2,
|
|
9
|
+
defineBlogPosting2,
|
|
10
|
+
defineProduct2,
|
|
11
|
+
defineOffer2,
|
|
12
|
+
defineAggregateRating2,
|
|
13
|
+
defineReview2,
|
|
14
|
+
defineQuestion2,
|
|
15
|
+
defineFaqPage2,
|
|
16
|
+
defineHowTo2,
|
|
17
|
+
defineEvent2,
|
|
18
|
+
defineRecipe2,
|
|
19
|
+
defineVideoObject2,
|
|
20
|
+
defineImageObject2,
|
|
21
|
+
defineSoftwareApp2,
|
|
22
|
+
defineBook2,
|
|
23
|
+
defineCourse2,
|
|
24
|
+
defineJobPosting2,
|
|
25
|
+
defineBreadcrumbList2
|
|
26
|
+
} from "../chunks/bun-index-rnjhv41c.js";
|
|
27
|
+
export {
|
|
28
|
+
defineAggregateRating2 as defineAggregateRating,
|
|
29
|
+
defineArticle2 as defineArticle,
|
|
30
|
+
defineBlogPosting2 as defineBlogPosting,
|
|
31
|
+
defineBook2 as defineBook,
|
|
32
|
+
defineBreadcrumbList2 as defineBreadcrumbList,
|
|
33
|
+
defineCourse2 as defineCourse,
|
|
34
|
+
defineEvent2 as defineEvent,
|
|
35
|
+
defineFaqPage2 as defineFaqPage,
|
|
36
|
+
defineHowTo2 as defineHowTo,
|
|
37
|
+
defineImageObject2 as defineImageObject,
|
|
38
|
+
defineJobPosting2 as defineJobPosting,
|
|
39
|
+
defineLocalBusiness2 as defineLocalBusiness,
|
|
40
|
+
defineOffer2 as defineOffer,
|
|
41
|
+
defineOrganization2 as defineOrganization,
|
|
42
|
+
definePerson2 as definePerson,
|
|
43
|
+
defineProduct2 as defineProduct,
|
|
44
|
+
defineQuestion2 as defineQuestion,
|
|
45
|
+
defineRecipe2 as defineRecipe,
|
|
46
|
+
defineReview2 as defineReview,
|
|
47
|
+
defineSoftwareApp2 as defineSoftwareApp,
|
|
48
|
+
defineVideoObject2 as defineVideoObject,
|
|
49
|
+
defineWebPage2 as defineWebPage,
|
|
50
|
+
defineWebSite2 as defineWebSite
|
|
51
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// @bun
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// packages/seo/src/share.ts
|
|
3
|
+
var hostName = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*(:\d{1,5})?$/i;
|
|
4
|
+
function shareLinks(input) {
|
|
5
|
+
let scheme;
|
|
6
|
+
try {
|
|
7
|
+
scheme = new URL(input.url).protocol;
|
|
8
|
+
} catch {
|
|
9
|
+
scheme = "";
|
|
10
|
+
}
|
|
11
|
+
if (scheme !== "http:" && scheme !== "https:")
|
|
12
|
+
throw new Error(`shareLinks: url must be absolute (got ${JSON.stringify(input.url)})`);
|
|
13
|
+
if (input.mastodon !== undefined && !hostName.test(input.mastodon)) {
|
|
14
|
+
throw new Error(`shareLinks: mastodon must be a host name such as "mastodon.social" (got ${JSON.stringify(input.mastodon)})`);
|
|
15
|
+
}
|
|
16
|
+
const e = encodeURIComponent;
|
|
17
|
+
const url = e(input.url);
|
|
18
|
+
const title = e(input.title);
|
|
19
|
+
const text = input.text ?? input.title;
|
|
20
|
+
const textOnly = e(text);
|
|
21
|
+
const textAndUrl = e(`${text} ${input.url}`);
|
|
22
|
+
const links = {
|
|
23
|
+
x: `https://x.com/intent/tweet?url=${url}&text=${textOnly}`,
|
|
24
|
+
facebook: `https://www.facebook.com/sharer/sharer.php?u=${url}`,
|
|
25
|
+
linkedin: `https://www.linkedin.com/sharing/share-offsite/?url=${url}`,
|
|
26
|
+
bluesky: `https://bsky.app/intent/compose?text=${textAndUrl}`,
|
|
27
|
+
email: `mailto:?subject=${title}&body=${e(`${text}
|
|
28
|
+
|
|
29
|
+
${input.url}`)}`,
|
|
30
|
+
whatsapp: `https://wa.me/?text=${textAndUrl}`,
|
|
31
|
+
reddit: `https://www.reddit.com/submit?url=${url}&title=${title}`,
|
|
32
|
+
telegram: `https://t.me/share/url?url=${url}&text=${textOnly}`
|
|
33
|
+
};
|
|
34
|
+
if (input.mastodon !== undefined)
|
|
35
|
+
links.mastodon = `https://${input.mastodon}/share?text=${textAndUrl}`;
|
|
36
|
+
return links;
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
shareLinks
|
|
40
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type BreadcrumbItem, type BreadcrumbOptions } from "../runtime/breadcrumbs.ts";
|
|
2
|
+
import type { SchemaNode } from "../schema.ts";
|
|
3
|
+
export type { BreadcrumbItem, BreadcrumbOptions, SchemaNode };
|
|
4
|
+
/** The calls of a page render are numbered in order; a number that does not grow starts a new render, so the calls of the one before are dropped. */
|
|
5
|
+
export declare function useSchemaOrg(nodes: SchemaNode | SchemaNode[]): void;
|
|
6
|
+
export declare function useBreadcrumbItems(options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type BreadcrumbItem, type BreadcrumbOptions } from "../runtime/breadcrumbs.ts";
|
|
2
|
+
import type { SchemaNode } from "../schema.ts";
|
|
3
|
+
export type { BreadcrumbItem, BreadcrumbOptions, SchemaNode };
|
|
4
|
+
export declare function useSchemaOrg(nodes: SchemaNode | SchemaNode[]): void;
|
|
5
|
+
export declare function useBreadcrumbItems(options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type BreadcrumbItem, type BreadcrumbOptions } from "../runtime/breadcrumbs.ts";
|
|
2
|
+
import type { SchemaNode } from "../schema.ts";
|
|
3
|
+
export type { BreadcrumbItem, BreadcrumbOptions, SchemaNode };
|
|
4
|
+
export declare function useSchemaOrg(nodes: SchemaNode | SchemaNode[]): void;
|
|
5
|
+
export declare function useBreadcrumbItems(options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Accessor } from "solid-js";
|
|
2
|
+
import { type BreadcrumbItem, type BreadcrumbOptions } from "../runtime/breadcrumbs.ts";
|
|
3
|
+
import type { SchemaNode } from "../schema.ts";
|
|
4
|
+
export type { BreadcrumbItem, BreadcrumbOptions, SchemaNode };
|
|
5
|
+
export declare function useSchemaOrg(nodes: SchemaNode | SchemaNode[] | (() => SchemaNode | SchemaNode[])): void;
|
|
6
|
+
export declare function useBreadcrumbItems(options?: BreadcrumbOptions): Accessor<BreadcrumbItem[]>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type BreadcrumbItem, type BreadcrumbOptions } from "../runtime/breadcrumbs.ts";
|
|
2
|
+
import type { SchemaNode } from "../schema.ts";
|
|
3
|
+
export type { BreadcrumbItem, BreadcrumbOptions, SchemaNode };
|
|
4
|
+
export declare function useSchemaOrg(nodes: SchemaNode | SchemaNode[] | (() => SchemaNode | SchemaNode[])): void;
|
|
5
|
+
export declare function useBreadcrumbItems(options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ComputedRef, type MaybeRefOrGetter } from "vue";
|
|
2
|
+
import { type BreadcrumbItem, type BreadcrumbOptions } from "../runtime/breadcrumbs.ts";
|
|
3
|
+
import type { SchemaNode } from "../schema.ts";
|
|
4
|
+
export type { BreadcrumbItem, BreadcrumbOptions, SchemaNode };
|
|
5
|
+
type MaybeRefOrGetterDeep<T> = MaybeRefOrGetter<T extends (...args: never[]) => unknown ? T : T extends readonly (infer U)[] ? MaybeRefOrGetterDeep<U>[] : T extends object ? {
|
|
6
|
+
[K in keyof T]: MaybeRefOrGetterDeep<T[K]>;
|
|
7
|
+
} : T>;
|
|
8
|
+
export declare function useSchemaOrg(nodes: MaybeRefOrGetterDeep<SchemaNode | SchemaNode[]>): void;
|
|
9
|
+
export declare function useBreadcrumbItems(options?: BreadcrumbOptions): ComputedRef<BreadcrumbItem[]>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { HamurContext } from "hamur/kit";
|
|
2
|
+
import type { SeoConfig } from "../types.ts";
|
|
3
|
+
/** The link rules over every page the prerender writes, reported in `prerender:done`. */
|
|
4
|
+
export declare function setupLinkChecker(value: SeoConfig["linkChecker"], hamur: HamurContext): void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type HamurContext } from "hamur/kit";
|
|
2
|
+
import { type ResolvedLlms } from "../llms/options.ts";
|
|
3
|
+
/** `seo.llms` as it resolved, `undefined` while it is off; fails when `content.llms` serves the same files. */
|
|
4
|
+
export declare function readLlms(input: unknown, hamur: HamurContext): ResolvedLlms | undefined;
|
|
5
|
+
/** `/llms.txt`, `/llms-full.txt` and the agent Markdown of every page; the app's `public/llms.txt` or own route wins. */
|
|
6
|
+
export declare function setupLlms(llms: ResolvedLlms | undefined, hamur: HamurContext): void;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { type HamurContext } from "hamur/kit";
|
|
2
|
+
/** With `enabled` false the module's record is dropped without a word; otherwise the app's `public/<file>` or its own `GET` handler of `path` wins; the module then drops its record in `server:extend` and logs once. `served()` tells whether the module's route stands. `companions` are the module's other routes that stand and fall with it. */
|
|
3
|
+
export declare function yieldToApp(hamur: HamurContext, path: string, enabled: boolean, companions?: string[]): {
|
|
4
|
+
served(): boolean;
|
|
5
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type HamurContext } from "hamur/kit";
|
|
2
|
+
import type { SeoConfig } from "../types.ts";
|
|
3
|
+
/** The `#hamur/seo/schema-org` template and the app plugin that writes the page's graph on both sides. */
|
|
4
|
+
export declare function setupSchemaOrg(value: SeoConfig["schemaOrg"], hamur: HamurContext): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type HamurContext } from "hamur/kit";
|
|
2
|
+
import { type ResolvedSitemap } from "../sitemap/options.ts";
|
|
3
|
+
export declare const PART_ROUTE = "/sitemap-:n.xml";
|
|
4
|
+
/** Under `app.trailingSlash: "always"` a listed page path ends in `/`, by the one rule of the handler and the client. */
|
|
5
|
+
export declare const slashed: (path: string) => string;
|
|
6
|
+
/** `listed` keeps the URL list in the build for `seo.llms` while `seo.sitemap` serves no file. */
|
|
7
|
+
export declare function setupSitemap(served: ResolvedSitemap | undefined, hamur: HamurContext, listed?: boolean): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type HamurContext, type PrerenderPage, type PrerenderRun, type PrerenderedPage } from "hamur/kit";
|
|
2
|
+
import { type ResolvedLinkChecker } from "./options.ts";
|
|
3
|
+
/** Collects the pages through `prerender:page`, runs the rules that need other pages in `prerender:done`. */
|
|
4
|
+
export declare function createLinkChecker(hamur: HamurContext, options: ResolvedLinkChecker): {
|
|
5
|
+
page: (current: PrerenderPage) => void;
|
|
6
|
+
done: (_pages: PrerenderedPage[], run: PrerenderRun) => Promise<void>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const EXTERNAL_TIMEOUT_MS = 5000;
|
|
2
|
+
export declare const EXTERNAL_CONCURRENCY = 8;
|
|
3
|
+
/** The finding text of one external URL, or `undefined` when it answers below 400; `HEAD`, then `GET` once for a 405 or 501. */
|
|
4
|
+
export declare function probe(url: string): Promise<string | undefined>;
|
|
5
|
+
/** Each distinct URL once, at most `EXTERNAL_CONCURRENCY` at a time; the map holds the finding text of the URLs that failed. */
|
|
6
|
+
export declare function probeAll(urls: Iterable<string>): Promise<Map<string, string>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { LinkRuleId } from "../types.ts";
|
|
2
|
+
export type LinkLevel = "error" | "warning";
|
|
3
|
+
export declare const LINK_RULES: Record<LinkRuleId, LinkLevel>;
|
|
4
|
+
export interface ResolvedLinkChecker {
|
|
5
|
+
failOnError: boolean;
|
|
6
|
+
external: boolean;
|
|
7
|
+
report: Array<"json" | "markdown" | "html">;
|
|
8
|
+
exclude: string[];
|
|
9
|
+
rules: Partial<Record<LinkRuleId, LinkLevel | false>>;
|
|
10
|
+
}
|
|
11
|
+
/** `seo.linkChecker`, `true` when unset; `undefined` when it is `false`. */
|
|
12
|
+
export declare function resolveLinkChecker(input: unknown): ResolvedLinkChecker | undefined;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type LinkFinding } from "hamur/server/internal";
|
|
2
|
+
export type ReportFormat = "json" | "markdown" | "html";
|
|
3
|
+
/** The files of `seo.linkChecker.report` under `<buildDir>/reports/`, never in `.output/`. */
|
|
4
|
+
export declare function writeReports(buildDir: string, formats: ReportFormat[], pages: number, findings: LinkFinding[]): Promise<void>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface ScannedLink {
|
|
2
|
+
href: string;
|
|
3
|
+
/** Whether the link has text, an `aria-label`, `aria-labelledby`, a `title` or an `<img alt>`. */
|
|
4
|
+
named: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface PageScan {
|
|
7
|
+
links: ScannedLink[];
|
|
8
|
+
ids: Set<string>;
|
|
9
|
+
}
|
|
10
|
+
export declare function decode(text: string): string;
|
|
11
|
+
export declare function attributes(source: string): Map<string, string>;
|
|
12
|
+
/** The `<a href>` elements of a page with their accessible text, and every `id` and `<a name>`, by a tag scan. */
|
|
13
|
+
export declare function scanPage(html: string): PageScan;
|
|
14
|
+
export type HtmlToken = {
|
|
15
|
+
text: string;
|
|
16
|
+
} | {
|
|
17
|
+
open: string;
|
|
18
|
+
attrs: Map<string, string>;
|
|
19
|
+
selfClosing: boolean;
|
|
20
|
+
} | {
|
|
21
|
+
close: string;
|
|
22
|
+
};
|
|
23
|
+
/** The tags and text of a page in order, comments, scripts, styles and declarations left out; text is raw, entities not decoded. */
|
|
24
|
+
export declare function tokenize(html: string): HtmlToken[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface ResolvedLlms {
|
|
2
|
+
title?: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
exclude: string[];
|
|
5
|
+
}
|
|
6
|
+
/** `seo.llms`, off by default; `undefined` when it is off. */
|
|
7
|
+
export declare function resolveLlms(input: unknown): ResolvedLlms | undefined;
|
|
8
|
+
/** `/llms.txt` and `/llms-full.txt` have one owner. */
|
|
9
|
+
export declare function checkOwner(contentLlms: unknown): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** `/` is `/index.md`, a trailing slash is dropped, so `/docs/` is `/docs.md`. */
|
|
2
|
+
export declare const markdownPath: (path: string) => string;
|
|
3
|
+
/** The page path a `<path>.md` request stands for; `undefined` for a path that does not end in `.md`. */
|
|
4
|
+
export declare function pageOfMarkdown(path: string): string | undefined;
|
|
5
|
+
/** Whether an `Accept` header names `text/markdown` with a higher quality than `text/html`, or names no `text/html`. */
|
|
6
|
+
export declare function prefersMarkdown(accept: string | null): boolean;
|
|
7
|
+
/** The pathname below `app.baseURL`, `undefined` outside it. */
|
|
8
|
+
export declare function pathBelow(pathname: string, baseURL: string): string | undefined;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface LlmsPage {
|
|
2
|
+
title: string;
|
|
3
|
+
url: string;
|
|
4
|
+
description?: string;
|
|
5
|
+
}
|
|
6
|
+
/** The llmstxt.org layout, for `content.llms`. */
|
|
7
|
+
export declare function llmsText(head: {
|
|
8
|
+
title: string;
|
|
9
|
+
description?: string | undefined;
|
|
10
|
+
}, pages: readonly LlmsPage[]): string;
|
|
11
|
+
/** Every page's Markdown joined by a rule. */
|
|
12
|
+
export declare const llmsFullText: (sources: readonly string[]) => string;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/** Training and indexing crawlers; agents that fetch one page for a user who asked (`ChatGPT-User`) are not listed. */
|
|
2
|
+
export declare const AI_BOTS: readonly ["GPTBot", "ClaudeBot", "anthropic-ai", "CCBot", "Google-Extended", "Applebot-Extended", "PerplexityBot", "Bytespider", "meta-externalagent", "Amazonbot", "cohere-ai"];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ResolvedRobots } from "./options.ts";
|
|
2
|
+
export interface BodyInput {
|
|
3
|
+
robots: ResolvedRobots;
|
|
4
|
+
/** The patterns of `routeRules` whose merged rule has `noindex: true`, in table order. */
|
|
5
|
+
noindex: string[];
|
|
6
|
+
/** `app.baseURL`. */
|
|
7
|
+
baseURL: string;
|
|
8
|
+
/** The locale codes whose pages `@hamur/i18n` copies under a prefix. */
|
|
9
|
+
prefixes: string[];
|
|
10
|
+
}
|
|
11
|
+
/** The answer when `site.indexable` is false. */
|
|
12
|
+
export declare const NOINDEX_BODY = "User-agent: *\nDisallow: /\n";
|
|
13
|
+
/** A route rule pattern as an RFC 9309 path below `prefix`; a trailing `/**` or `/*` becomes the folder, any other path ends in `$`. */
|
|
14
|
+
export declare function rulePath(pattern: string, prefix: string): string;
|
|
15
|
+
/** The robots file of an indexable site, without its `Sitemap:` line (the answer adds it, it needs `site.url`). */
|
|
16
|
+
export declare function robotsBody(input: BodyInput): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RobotsGroup } from "../types.ts";
|
|
2
|
+
export interface ResolvedRobots {
|
|
3
|
+
groups: RobotsGroup[];
|
|
4
|
+
blockAiBots: boolean;
|
|
5
|
+
fromRules: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_GROUPS: RobotsGroup[];
|
|
8
|
+
/** `seo.robots` with its defaults, `undefined` when it is `false`; the first wrong value throws. */
|
|
9
|
+
export declare function resolveRobots(input: unknown): ResolvedRobots | undefined;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type AppContext } from "hamur/app";
|
|
2
|
+
import type { SchemaNode } from "../schema.ts";
|
|
3
|
+
export interface BreadcrumbItem {
|
|
4
|
+
label: string;
|
|
5
|
+
to: string | undefined;
|
|
6
|
+
current: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface BreadcrumbOptions {
|
|
9
|
+
hideRoot?: boolean;
|
|
10
|
+
overrides?: (Partial<BreadcrumbItem> | false | undefined)[];
|
|
11
|
+
schemaOrg?: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface I18nLike {
|
|
14
|
+
localeOf(path: string): {
|
|
15
|
+
code: string;
|
|
16
|
+
};
|
|
17
|
+
localePath(to: string, code: string): string;
|
|
18
|
+
}
|
|
19
|
+
export interface BreadcrumbEnv {
|
|
20
|
+
/** The route's app path, below `app.baseURL`, with the locale prefix when it has one. */
|
|
21
|
+
path: string;
|
|
22
|
+
resolve(path: string): {
|
|
23
|
+
name?: string;
|
|
24
|
+
};
|
|
25
|
+
titles: Record<string, string>;
|
|
26
|
+
i18n?: I18nLike;
|
|
27
|
+
}
|
|
28
|
+
/** One item per path prefix of `env.path`, root first. */
|
|
29
|
+
export declare function breadcrumbItems(env: BreadcrumbEnv, options?: BreadcrumbOptions): BreadcrumbItem[];
|
|
30
|
+
/** The `BreadcrumbList` of `items`, or no node when `schemaOrg` is off. */
|
|
31
|
+
export declare function breadcrumbNodes(app: AppContext, items: BreadcrumbItem[], options: BreadcrumbOptions): SchemaNode[];
|
|
32
|
+
export declare const i18nOf: (app: AppContext) => I18nLike | undefined;
|
|
33
|
+
/** The page route an app path reaches, from `#hamur/route-paths`, so a page whose record the client has not read still matches. */
|
|
34
|
+
export declare function routeOf(app: AppContext, path: string): {
|
|
35
|
+
name?: string;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface MarkdownOptions {
|
|
2
|
+
/** The absolute URL of the page, which relative `href` and `src` values resolve against. */
|
|
3
|
+
base: string;
|
|
4
|
+
/** The id of the app root element, read when the page has no `<main>`. */
|
|
5
|
+
rootId?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface PageInfo {
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
noindex: boolean;
|
|
11
|
+
}
|
|
12
|
+
/** The title, the description and whether the robots meta holds `noindex`, read from a rendered page. */
|
|
13
|
+
export declare function pageInfo(html: string): PageInfo;
|
|
14
|
+
/** The Markdown of a page's `<main>`, else of the app root element, else of its `<body>`. */
|
|
15
|
+
export declare function htmlToMarkdown(html: string, { base, rootId }: MarkdownOptions): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { AppContext } from "hamur/app";
|
|
2
|
+
import type { IdentityNode, SchemaNode } from "../schema.ts";
|
|
3
|
+
export interface SchemaOrgRuntime {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
identity: IdentityNode | null;
|
|
6
|
+
baseURL: string;
|
|
7
|
+
trailingSlash: "ignore" | "redirect" | "always" | "strict";
|
|
8
|
+
/** Route name → the string-literal `meta.title` of its page, read at build. */
|
|
9
|
+
titles: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export interface SchemaPage {
|
|
12
|
+
pathname: string;
|
|
13
|
+
search: string;
|
|
14
|
+
}
|
|
15
|
+
export interface SchemaStore {
|
|
16
|
+
/** Replaces the nodes of the call `key`; the first `set` of a key fixes its place in the graph. */
|
|
17
|
+
set(key: unknown, nodes: SchemaNode[]): void;
|
|
18
|
+
remove(key: unknown): void;
|
|
19
|
+
clear(): void;
|
|
20
|
+
setPage(page: SchemaPage): void;
|
|
21
|
+
readonly titles: Record<string, string>;
|
|
22
|
+
/** `app.baseURL` without its trailing slash. */
|
|
23
|
+
readonly base: string;
|
|
24
|
+
/** The canonical URL of an app path below `app.baseURL`, `undefined` without `site.url`. */
|
|
25
|
+
urlOf(path: string): string | undefined;
|
|
26
|
+
/** Rebuilds the graph and patches the plugin's one head entry. */
|
|
27
|
+
sync(): void;
|
|
28
|
+
}
|
|
29
|
+
export declare function createSchemaStore(app: AppContext, options: SchemaOrgRuntime, initial: SchemaPage): SchemaStore;
|
|
30
|
+
export declare function setSchemaStore(app: AppContext, store: SchemaStore): void;
|
|
31
|
+
export declare function schemaStoreOf(app: AppContext): SchemaStore;
|
|
32
|
+
export declare const nodeList: (nodes: SchemaNode | SchemaNode[]) => SchemaNode[];
|
|
33
|
+
/** The app of a `useSchemaOrg` call, with the message of `useHead` when there is none. */
|
|
34
|
+
export declare function appOfCall(useApp: () => AppContext): AppContext;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { JsonLdGraph } from "hamur/app";
|
|
2
|
+
import type { SchemaNode } from "../schema.ts";
|
|
3
|
+
export interface GraphInput {
|
|
4
|
+
siteURL: string;
|
|
5
|
+
baseURL: string;
|
|
6
|
+
pageURL: string;
|
|
7
|
+
name?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
identity?: SchemaNode;
|
|
10
|
+
nodes: SchemaNode[];
|
|
11
|
+
}
|
|
12
|
+
/** The page's graph: the default nodes, then each node of `nodes` in order, merged by `@id`. */
|
|
13
|
+
export declare function buildGraph(input: GraphInput): JsonLdGraph;
|