mirror of
				https://github.com/owncast/owncast.git
				synced 2025-11-04 05:17:27 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			36 lines
		
	
	
		
			920 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			920 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
/* eslint-disable react/no-danger */
 | 
						|
import { Html, Head, Main, NextScript } from 'next/document';
 | 
						|
import { readFileSync } from 'fs';
 | 
						|
import { join } from 'path';
 | 
						|
 | 
						|
class InlineStylesHead extends Head {
 | 
						|
  getCssLinks: Head['getCssLinks'] = ({ allFiles }) => {
 | 
						|
    const { assetPrefix } = this.context;
 | 
						|
    if (!allFiles || allFiles.length === 0) return null;
 | 
						|
    return allFiles
 | 
						|
      .filter((file: any) => /\.css$/.test(file))
 | 
						|
      .map((file: any) => (
 | 
						|
        <style
 | 
						|
          key={file}
 | 
						|
          nonce={this.props.nonce}
 | 
						|
          data-href={`${assetPrefix}/_next/${file}`}
 | 
						|
          dangerouslySetInnerHTML={{
 | 
						|
            __html: readFileSync(join(process.cwd(), '.next', file), 'utf-8'),
 | 
						|
          }}
 | 
						|
        />
 | 
						|
      ));
 | 
						|
  };
 | 
						|
}
 | 
						|
 | 
						|
export default function Document() {
 | 
						|
  return (
 | 
						|
    <Html lang="en">
 | 
						|
      <InlineStylesHead />
 | 
						|
      <body>
 | 
						|
        <Main />
 | 
						|
        <NextScript />
 | 
						|
      </body>
 | 
						|
    </Html>
 | 
						|
  );
 | 
						|
}
 |