Home / Function/ getSnippetCompletions() — astro Function Reference

getSnippetCompletions() — astro Function Reference

Architecture documentation for the getSnippetCompletions() function in snippets.ts from the astro codebase.

Entity Profile

Dependency Diagram

graph TD
  dbbb13ea_1e57_1d02_3b9c_21db87cdd6b6["getSnippetCompletions()"]
  f60dedc5_1402_7c07_f5a8_da94c037c1fd["snippets.ts"]
  dbbb13ea_1e57_1d02_3b9c_21db87cdd6b6 -->|defined in| f60dedc5_1402_7c07_f5a8_da94c037c1fd
  style dbbb13ea_1e57_1d02_3b9c_21db87cdd6b6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/language-tools/language-server/src/plugins/typescript-addons/snippets.ts lines 4–65

export function getSnippetCompletions(frontmatter: FrontmatterStatus): CompletionItem[] {
	if (frontmatter.status === 'doesnt-exist') return [];

	const frontmatterStartPosition = {
		line: frontmatter.position.start.line,
		character: frontmatter.position.start.column - 1,
	};

	return [
		{
			label: 'interface Props',
			kind: CompletionItemKind.Snippet,
			labelDetails: { description: 'Create a new interface to type your props' },
			documentation: {
				kind: 'markdown',
				value: [
					'Create a new interface to type your props.',
					'\n',
					'[Astro reference](https://docs.astro.build/en/guides/typescript/#component-props)',
				].join('\n'),
			},
			insertTextFormat: 2,
			filterText: 'interface props',
			insertText: 'interface Props {\n\t$1\n}',
		},
		{
			label: 'getStaticPaths',
			kind: CompletionItemKind.Snippet,
			labelDetails: { description: 'Create a new getStaticPaths function' },
			documentation: {
				kind: 'markdown',
				value: [
					'Create a new getStaticPaths function.',
					'\n',
					'[Astro reference](https://docs.astro.build/en/reference/routing-reference/#getstaticpaths)',
				].join('\n'),
			},
			insertText:
				'export const getStaticPaths = (() => {\n\t$1\n\treturn [];\n}) satisfies GetStaticPaths;',
			additionalTextEdits: [
				TextEdit.insert(frontmatterStartPosition, 'import type { GetStaticPaths } from "astro";\n'),
			],
			filterText: 'getstaticpaths',
			insertTextFormat: 2,
		},
		{
			label: 'prerender',
			kind: CompletionItemKind.Snippet,
			labelDetails: { description: 'Add prerender export' },
			documentation: {
				kind: 'markdown',
				value: [
					'Add prerender export. When [using server-side rendering](https://docs.astro.build/en/guides/on-demand-rendering/#enabling-on-demand-rendering), this value will be used to determine whether to prerender the page or not.',
					'\n',
					'[Astro reference](https://docs.astro.build/en/reference/routing-reference/#prerender)',
				].join('\n'),
			},
			insertText: 'export const prerender = ${1|true,false|}',
			insertTextFormat: 2,
		},
	];
}

Domain

Subdomains

Frequently Asked Questions

What does getSnippetCompletions() do?
getSnippetCompletions() is a function in the astro codebase, defined in packages/language-tools/language-server/src/plugins/typescript-addons/snippets.ts.
Where is getSnippetCompletions() defined?
getSnippetCompletions() is defined in packages/language-tools/language-server/src/plugins/typescript-addons/snippets.ts at line 4.

Analyze Your Own Codebase

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

Try Supermodel Free