Skip to content

Commit da70d8b

Browse files
authored
fix(html/astro): keep a blank after the frontmatter (#8039)
1 parent 78011b1 commit da70d8b

File tree

15 files changed

+22
-377
lines changed

15 files changed

+22
-377
lines changed

.changeset/flat-rockets-battle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Biome now keeps a blank line after the frontmatter section in Astro files.

crates/biome_cli/tests/cases/handle_astro_files.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ let schema = z.object().optional();
223223
schema + sure()
224224
---
225225
226+
227+
228+
226229
<html><head><title>Astro</title></head><body></body></html>
227230
228231
<style>

crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/dont_indent_frontmatter.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ if (bar > 1) {
2424
console.log(bar + 1);
2525
}
2626
---
27+
2728
<Foo>{bar}</Foo>
2829
2930
<style>

crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/format_astro_with_typescript_script_tag.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ expression: redactor(content)
2020
---
2121
const title = "My Page";
2222
---
23+
2324
<html>
2425
<body>
2526
<script>

crates/biome_cli/tests/snapshots/main_cases_handle_astro_files/full_support.snap

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import z from "zod";
2424
const schema = z.object().optional();
2525
schema + sure();
2626
---
27+
2728
<html>
2829
<head>
2930
<title>Astro</title>
@@ -56,15 +57,15 @@ check ━━━━━━━━━━━━━━━━━━━━━━━━
5657
# Emitted Messages
5758

5859
```block
59-
file.astro:13:20 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
60+
file.astro:16:20 lint/a11y/useGenericFontNames ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
6061
6162
× Generic font family missing.
6263
63-
12 │ <style>
64-
> 13 │ #id { font-family: comic-sans } .class { background: red}
64+
15 │ <style>
65+
> 16 │ #id { font-family: comic-sans } .class { background: red}
6566
│ ^^^^^^^^^^
66-
14 │ </style>
67-
15
67+
17 │ </style>
68+
18
6869
6970
i Consider adding a generic font family as a fallback.
7071

crates/biome_html_formatter/src/html/auxiliary/root.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl FormatNodeRule<HtmlRoot> for FormatHtmlRoot {
1818
}
1919

2020
if let Some(frontmatter) = frontmatter {
21-
write!(f, [frontmatter.format(), hard_line_break()])?;
21+
write!(f, [frontmatter.format(), empty_line()])?;
2222
}
2323

2424
if let Some(directive) = directive {

crates/biome_html_formatter/tests/specs/html/component-frameworks/astro-component-casing.astro.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Self close void elements: never
4141
import Button from './Button.astro';
4242
import TextInput from './TextInput.astro';
4343
---
44+
4445
<Button label="test button"/>
4546
<TextInput placeholder="enter text"/>
4647
<button>native button</button>

crates/biome_html_formatter/tests/specs/html/frontmatter.html.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ Self close void elements: never
3636
---
3737
layout: foo
3838
---
39+
3940
Test <a href="https://prettier.io">abc</a>.
4041
```

crates/biome_html_formatter/tests/specs/prettier/html/front-matter/custom-parser.html.snap

Lines changed: 0 additions & 66 deletions
This file was deleted.

crates/biome_html_formatter/tests/specs/prettier/html/front-matter/empty.html.snap

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)