File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 1
1
import React , { useEffect , useState } from 'react' ;
2
+ import { usePageData } from '@rspress/core/runtime' ;
2
3
3
4
type FailingCase = {
4
5
name : string ;
@@ -108,15 +109,21 @@ export default function RuleManifestTable() {
108
109
const [ error , setError ] = useState < string | null > ( null ) ;
109
110
const [ statusFilter , setStatusFilter ] = useState < string > ( 'all' ) ;
110
111
const [ groupFilter , setGroupFilter ] = useState < string > ( 'all' ) ;
111
-
112
+ const pageData = usePageData ( ) ;
112
113
useEffect ( ( ) => {
114
+ if ( pageData . page . ruleManifest ) {
115
+ let data : any = pageData . page . ruleManifest ;
116
+ setRules ( data . rules ?? [ ] ) ;
117
+ setLoading ( false ) ;
118
+ return ;
119
+ }
113
120
fetch ( RULE_MANIFEST_URL )
114
121
. then ( res => {
115
122
if ( ! res . ok ) throw new Error ( 'Failed to fetch rule-manifest.json' ) ;
116
123
return res . json ( ) ;
117
124
} )
118
125
. then ( data => {
119
- setRules ( Array . isArray ( data ) ? data : data . rules || [ ] ) ;
126
+ setRules ( data . rules ?? [ ] ) ;
120
127
setLoading ( false ) ;
121
128
} )
122
129
. catch ( err => {
Original file line number Diff line number Diff line change
1
+ import { RspressPlugin } from '@rspress/core' ;
2
+ const RULE_MANIFEST_URL =
3
+ 'https://raw.githubusercontent.com/web-infra-dev/rslint/main/packages/rslint-test-tools/rule-manifest.json' ;
4
+ export function pluginPreloadRule ( ) : RspressPlugin {
5
+ return {
6
+ name : 'preload-rules-data' ,
7
+ async extendPageData ( pageData ) {
8
+ try {
9
+ const result = await fetch ( RULE_MANIFEST_URL ) ;
10
+ ( pageData as any ) . ruleManifest = await result . json ( ) ;
11
+ } catch ( error ) {
12
+ // don't stop compile if fetch failed
13
+ console . error ( 'Failed to fetch rule manifest:' , error ) ;
14
+ }
15
+ } ,
16
+ } ;
17
+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { pluginGoogleAnalytics } from 'rsbuild-plugin-google-analytics';
6
6
import { pluginOpenGraph } from 'rsbuild-plugin-open-graph' ;
7
7
import { pluginFontOpenSans } from 'rspress-plugin-font-open-sans' ;
8
8
import pluginSitemap from 'rspress-plugin-sitemap' ;
9
+ import { pluginPreloadRule } from './preload-plugin' ;
9
10
10
11
const siteUrl = 'https://rslint.rs' ;
11
12
const description = 'The Rspack-based testing framework' ;
@@ -55,6 +56,7 @@ export default defineConfig({
55
56
] ,
56
57
} ,
57
58
plugins : [
59
+ pluginPreloadRule ( ) ,
58
60
pluginFontOpenSans ( ) ,
59
61
pluginSitemap ( {
60
62
domain : siteUrl ,
You can’t perform that action at this time.
0 commit comments