Home / Function/ text() — astro Function Reference

text() — astro Function Reference

Architecture documentation for the text() function in overlay.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  e1a743c3_7c2e_2718_5b6c_7781a1e5f6cb["text()"]
  a932a37f_15f5_3203_d9bf_86f83ddbef01["ErrorOverlay"]
  e1a743c3_7c2e_2718_5b6c_7781a1e5f6cb -->|defined in| a932a37f_15f5_3203_d9bf_86f83ddbef01
  7f32b908_586b_fc52_7198_82891a2fdf41["constructor()"]
  7f32b908_586b_fc52_7198_82891a2fdf41 -->|calls| e1a743c3_7c2e_2718_5b6c_7781a1e5f6cb
  style e1a743c3_7c2e_2718_5b6c_7781a1e5f6cb fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/astro/src/core/errors/overlay.ts lines 744–771

	text(selector: string, text: string | undefined, html = false): void {
		if (!text) {
			return;
		}

		const el = this.root.querySelector(selector);

		if (!el) {
			return;
		}

		if (html) {
			// Automatically detect links
			text = text
				.split(' ')
				.map((v) => {
					if (!v.startsWith('https://')) return v;
					if (v.endsWith('.'))
						return `<a target="_blank" href="${v.slice(0, -1)}">${v.slice(0, -1)}</a>.`;
					return `<a target="_blank" href="${v}">${v}</a>`;
				})
				.join(' ');

			el.innerHTML = text.trim();
		} else {
			el.textContent = text.trim();
		}
	}

Domain

Subdomains

Called By

Frequently Asked Questions

What does text() do?
text() is a function in the astro codebase, defined in packages/astro/src/core/errors/overlay.ts.
Where is text() defined?
text() is defined in packages/astro/src/core/errors/overlay.ts at line 744.
What calls text()?
text() is called by 1 function(s): constructor.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free