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 11import React , { useEffect , useState } from 'react' ;
2+ import { usePageData } from '@rspress/core/runtime' ;
23
34type FailingCase = {
45 name : string ;
@@ -108,15 +109,21 @@ export default function RuleManifestTable() {
108109 const [ error , setError ] = useState < string | null > ( null ) ;
109110 const [ statusFilter , setStatusFilter ] = useState < string > ( 'all' ) ;
110111 const [ groupFilter , setGroupFilter ] = useState < string > ( 'all' ) ;
111-
112+ const pageData = usePageData ( ) ;
112113 useEffect ( ( ) => {
114+ if ( pageData . page . ruleManifest ) {
115+ let data : any = pageData . page . ruleManifest ;
116+ setRules ( data . rules ?? [ ] ) ;
117+ setLoading ( false ) ;
118+ return ;
119+ }
113120 fetch ( RULE_MANIFEST_URL )
114121 . then ( res => {
115122 if ( ! res . ok ) throw new Error ( 'Failed to fetch rule-manifest.json' ) ;
116123 return res . json ( ) ;
117124 } )
118125 . then ( data => {
119- setRules ( Array . isArray ( data ) ? data : data . rules || [ ] ) ;
126+ setRules ( data . rules ?? [ ] ) ;
120127 setLoading ( false ) ;
121128 } )
122129 . 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';
66import { pluginOpenGraph } from 'rsbuild-plugin-open-graph' ;
77import { pluginFontOpenSans } from 'rspress-plugin-font-open-sans' ;
88import pluginSitemap from 'rspress-plugin-sitemap' ;
9+ import { pluginPreloadRule } from './preload-plugin' ;
910
1011const siteUrl = 'https://rslint.rs' ;
1112const description = 'The Rspack-based testing framework' ;
@@ -55,6 +56,7 @@ export default defineConfig({
5556 ] ,
5657 } ,
5758 plugins : [
59+ pluginPreloadRule ( ) ,
5860 pluginFontOpenSans ( ) ,
5961 pluginSitemap ( {
6062 domain : siteUrl ,
You can’t perform that action at this time.
0 commit comments