lint/eslint: автоисправление проекта проекта
This commit is contained in:
@@ -1,9 +1,10 @@
|
|||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import yaml from 'js-yaml';
|
|
||||||
import { themes as prismThemes } from 'prism-react-renderer';
|
|
||||||
import type { Config } from '@docusaurus/types';
|
|
||||||
import type * as Preset from '@docusaurus/preset-classic';
|
import type * as Preset from '@docusaurus/preset-classic';
|
||||||
import type { NavbarItem } from '@docusaurus/theme-common';
|
import type { NavbarItem } from '@docusaurus/theme-common';
|
||||||
|
import type { Config } from '@docusaurus/types';
|
||||||
|
import yaml from 'js-yaml';
|
||||||
|
import { themes as prismThemes } from 'prism-react-renderer';
|
||||||
|
|
||||||
interface DocsConfig {
|
interface DocsConfig {
|
||||||
title: string;
|
title: string;
|
||||||
@@ -19,7 +20,7 @@ const url = process.env.DOCUSERVIX_URL;
|
|||||||
|
|
||||||
const { org, repo } = docsConfig.project;
|
const { org, repo } = docsConfig.project;
|
||||||
|
|
||||||
const { docs: docsDir = 'docs', blog: blogDir } = docsConfig.dirs || {};
|
const { docs: _docsDir = 'docs', blog: blogDir } = docsConfig.dirs || {};
|
||||||
|
|
||||||
const giteaUrl = 'https://git.jt4d.ru';
|
const giteaUrl = 'https://git.jt4d.ru';
|
||||||
const onBrokenLinks =
|
const onBrokenLinks =
|
||||||
@@ -116,7 +117,8 @@ const config: Config = {
|
|||||||
},
|
},
|
||||||
footer: {
|
footer: {
|
||||||
style: 'dark',
|
style: 'dark',
|
||||||
copyright: `Проект хостится на JT4D.ru, документация собрана с использованием Docuservix и Docusaurus.`,
|
copyright:
|
||||||
|
'Проект хостится на JT4D.ru, документация собрана с использованием Docuservix и Docusaurus.',
|
||||||
},
|
},
|
||||||
prism: {
|
prism: {
|
||||||
theme: prismThemes.github,
|
theme: prismThemes.github,
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
/* eslint-disable no-console -- logs required */
|
||||||
|
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
|
|
||||||
@@ -10,16 +12,25 @@ pinIndexToTop();
|
|||||||
*/
|
*/
|
||||||
function pinIndexToTop() {
|
function pinIndexToTop() {
|
||||||
const indexPath = path.join(docsDir, 'index.md');
|
const indexPath = path.join(docsDir, 'index.md');
|
||||||
if (!fs.existsSync(indexPath)) return;
|
|
||||||
|
if (!fs.existsSync(indexPath)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let content = fs.readFileSync(indexPath, 'utf8');
|
let content = fs.readFileSync(indexPath, 'utf8');
|
||||||
|
|
||||||
if (content.startsWith('---\n')) {
|
if (content.startsWith('---\n')) {
|
||||||
const endIdx = content.indexOf('\n---\n', 4);
|
const endIdx = content.indexOf('\n---\n', 4);
|
||||||
if (endIdx === -1) return;
|
|
||||||
|
if (endIdx === -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const frontMatter = content.slice(4, endIdx);
|
const frontMatter = content.slice(4, endIdx);
|
||||||
if (/^sidebar_position\s*:/m.test(frontMatter)) return;
|
|
||||||
|
if (/^sidebar_position\s*:/m.test(frontMatter)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
content =
|
content =
|
||||||
'---\nsidebar_position: 0\n' + frontMatter + '\n---\n' + content.slice(endIdx + 5);
|
'---\nsidebar_position: 0\n' + frontMatter + '\n---\n' + content.slice(endIdx + 5);
|
||||||
|
|||||||
+5
-3
@@ -1,14 +1,15 @@
|
|||||||
import type { ReactNode } from 'react';
|
|
||||||
import clsx from 'clsx';
|
|
||||||
import Link from '@docusaurus/Link';
|
import Link from '@docusaurus/Link';
|
||||||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
import useDocusaurusContext from '@docusaurus/useDocusaurusContext';
|
||||||
import Layout from '@theme/Layout';
|
|
||||||
import Heading from '@theme/Heading';
|
import Heading from '@theme/Heading';
|
||||||
|
import Layout from '@theme/Layout';
|
||||||
|
import clsx from 'clsx';
|
||||||
|
import type { ReactNode } from 'react';
|
||||||
|
|
||||||
import styles from './index.module.css';
|
import styles from './index.module.css';
|
||||||
|
|
||||||
function HomepageHeader() {
|
function HomepageHeader() {
|
||||||
const { siteConfig } = useDocusaurusContext();
|
const { siteConfig } = useDocusaurusContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<header className={clsx('hero hero--primary', styles.heroBanner)}>
|
<header className={clsx('hero hero--primary', styles.heroBanner)}>
|
||||||
<div className="container">
|
<div className="container">
|
||||||
@@ -34,6 +35,7 @@ function HomepageHeader() {
|
|||||||
|
|
||||||
export default function Home(): ReactNode {
|
export default function Home(): ReactNode {
|
||||||
const { siteConfig } = useDocusaurusContext();
|
const { siteConfig } = useDocusaurusContext();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Layout
|
<Layout
|
||||||
title={`Hello from ${siteConfig.title}`}
|
title={`Hello from ${siteConfig.title}`}
|
||||||
|
|||||||
Reference in New Issue
Block a user