kdnk_obsidian-automatic-linker/src/frontmatter-utils.ts
Kodai Nakamura 1490c1d39f feat: add frontmatter opt-out for URL titles
Why:
- Some notes need to keep raw URLs and avoid web title requests even when global URL title replacement is enabled.
- A per-note frontmatter flag gives users local control without disabling other automatic linking behavior.

What:
- Add automatic-linker-disable-url-title frontmatter detection.
- Skip URL title fetching and replacement when the flag is set on a note.
- Document the frontmatter option and add regression coverage for the helper and plugin flow.
- Record this repository's agent version-control instructions in AGENTS.md.
2026-06-21 23:22:35 +09:00

45 lines
1.3 KiB
TypeScript

/**
* Check if the file has the "off" frontmatter property
*/
export const isLinkingOff = (
frontmatter: Record<string, unknown> | undefined,
): boolean => {
return (
frontmatter?.["automatic-linker-disabled"] === true
|| frontmatter?.["automatic-linker-off"] === true
)
}
/**
* Check if the file has the "scoped" frontmatter property
*/
export const isNamespaceScoped = (
frontmatter: Record<string, unknown> | undefined,
): boolean => {
return (
frontmatter?.["automatic-linker-restrict-namespace"] === true
|| frontmatter?.["automatic-linker-limited-namespace"] === true
|| frontmatter?.["automatic-linker-scoped"] === true
)
}
/**
* Check if the file has the "exclude" frontmatter property
*/
export const isLinkingExcluded = (
frontmatter: Record<string, unknown> | undefined,
): boolean => {
return (
frontmatter?.["automatic-linker-prevent-linking"] === true
|| frontmatter?.["automatic-linker-exclude"] === true
)
}
/**
* Check if the file disables URL title fetching/replacement
*/
export const isUrlTitleReplacementOff = (
frontmatter: Record<string, unknown> | undefined,
): boolean => {
return frontmatter?.["automatic-linker-disable-url-title"] === true
}