-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(typegen): add support for astro (#8098)
- Loading branch information
Showing
4 changed files
with
77 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/@sanity/codegen/src/typescript/__tests__/fixtures/import.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
import groq from 'groq' | ||
import { type Client } from '@sanity/client' | ||
export const query = groq`*[_type == "myType"]` | ||
--- | ||
<MyComponent> | ||
<div>{query}</div> | ||
</MyComponent> |
31 changes: 31 additions & 0 deletions
31
packages/@sanity/codegen/src/typescript/__tests__/parseSource.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import {describe, expect, test} from 'vitest' | ||
|
||
import {parseSourceFile} from '../parseSource' | ||
|
||
describe('parseSource', () => { | ||
test('should parse astro', () => { | ||
const source = ` | ||
--- | ||
import Layout from '../layouts/Layout.astro'; | ||
import { project_dir } from '../libs/utils'; | ||
const proj = "10_prerender" | ||
const render_time = new Date() | ||
export const prerender = true | ||
--- | ||
<Layout title="Prerendered"> | ||
<main> | ||
<h1>Prerendered</h1> | ||
<p>This page was prerendered at {render_time.toISOString()}</p> | ||
</main> | ||
</Layout> | ||
` | ||
|
||
const parsed = parseSourceFile(source, 'foo.astro', {}) | ||
|
||
expect(parsed.type).toBe('File') | ||
expect(parsed.program.body.length).toBe(5) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters