Skip to content

Commit 85ec382

Browse files
committed
docs(linter): add good/bad example for nextjs/no-page-custom-font (#12092)
There is no good example code, because this rule depends on the filename
1 parent 04e2de5 commit 85ec382

File tree

1 file changed

+33
-3
lines changed

1 file changed

+33
-3
lines changed

crates/oxc_linter/src/rules/nextjs/no_page_custom_font.rs

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,46 @@ declare_oxc_lint!(
3131
/// ### Why is this bad?
3232
///
3333
/// * The custom font you're adding was added to a page - this only adds the font to the specific page and not the entire application.
34-
/// * The custom font you're adding was added to a separate component within pages/_document.js - this disables automatic font optimization.
34+
/// * The custom font you're adding was added to a separate component within `pages/_document.js` - this disables automatic font optimization.
3535
///
3636
/// ### Examples
3737
///
3838
/// Examples of **incorrect** code for this rule:
39-
/// ```javascript
39+
/// ```jsx
40+
/// // pages/index.jsx
41+
/// import Head from "next/head";
42+
/// function IndexPage() {
43+
/// return (
44+
/// <Head>
45+
/// <link
46+
/// href="https://fonts.googleapis.com/css2?family=Krona+One&display=swap"
47+
/// rel="stylesheet"
48+
/// />
49+
/// </Head>
50+
/// );
51+
/// }
52+
/// export default IndexPage;
4053
/// ```
4154
///
4255
/// Examples of **correct** code for this rule:
43-
/// ```javascript
56+
/// ```jsx
57+
/// // pages/_document.jsx
58+
/// import NextDocument, { Html, Head } from "next/document";
59+
/// class Document extends NextDocument {
60+
/// render() {
61+
/// return (
62+
/// <Html>
63+
/// <Head>
64+
/// <link
65+
/// href="https://fonts.googleapis.com/css2?family=Krona+One&display=swap"
66+
/// rel="stylesheet"
67+
/// />
68+
/// </Head>
69+
/// </Html>
70+
/// );
71+
/// }
72+
/// }
73+
/// export default Document;
4474
/// ```
4575
NoPageCustomFont,
4676
nextjs,

0 commit comments

Comments
 (0)