Skip to content

Commit

Permalink
Adapt Site/index.js to Typescript
Browse files Browse the repository at this point in the history
  • Loading branch information
jovyntls committed Apr 10, 2023
1 parent da44988 commit 0f12a21
Show file tree
Hide file tree
Showing 9 changed files with 324 additions and 204 deletions.
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cli/src/cmd/build.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');

const { Site } = require('@markbind/core');
const { Site } = require('@markbind/core').Site;

const cliUtil = require('../util/cliUtil');
const logger = require('../util/logger');
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cmd/deploy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const path = require('path');

const { Site } = require('@markbind/core');
const { Site } = require('@markbind/core').Site;

const cliUtil = require('../util/cliUtil');
const logger = require('../util/logger');
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/cmd/init.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const fs = require('fs-extra');
const path = require('path');

const { Site, Template } = require('@markbind/core');
const { Template } = require('@markbind/core');
const { Site } = require('@markbind/core').Site;

const logger = require('../util/logger');

Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/cmd/serve.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const chokidar = require('chokidar');
const path = require('path');

const { Site } = require('@markbind/core');
const { Site } = require('@markbind/core').Site;
const { pageVueServerRenderer } = require('@markbind/core/src/Page/PageVueServerRenderer');

const fsUtil = require('@markbind/core/src/utils/fsUtil');
Expand Down
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"@types/crypto-js": "^4.1.1",
"@types/domhandler": "^2.4.2",
"@types/fs-extra": "^9.0.13",
"@types/gh-pages": "^3.2.1",
"@types/htmlparser2": "^3.10.3",
"@types/jest": "^27.4.1",
"@types/js-beautify": "^1.13.3",
Expand Down
33 changes: 22 additions & 11 deletions packages/core/src/Site/SiteConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
import { FrontMatter } from '../plugins/Plugin';

const HEADING_INDEXING_LEVEL_DEFAULT = 3;

export type SiteConfigPage = {
glob?: string,
layout?: string,
src?: string[],
title?: string,
externalScripts?: string[],
globExclude?: string,
searchable?: string | boolean,
frontmatter?: FrontMatter,
};

export type SiteConfigStyle = {
bootstrapTheme?: string;
codeTheme: 'dark' | 'light';
codeLineNumbers: boolean; // Default hide display of line numbers for code blocks
};

/**
* Represents a read only site config read from the site configuration file,
* with default values for unspecified properties.
Expand All @@ -10,16 +29,9 @@ export class SiteConfig {
faviconPath?: string;
headingIndexingLevel: number;

style: {
bootstrapTheme?: string;
codeTheme: string;
/**
* Default hide display of line numbers for code blocks
*/
codeLineNumbers: boolean;
};
style: SiteConfigStyle;

pages: string[];
pages: SiteConfigPage[];
pagesExclude: string[];
ignore: string[];

Expand All @@ -40,6 +52,7 @@ export class SiteConfig {
message?: string;
repo?: string;
branch?: string;
baseDir?: string;
};

intrasiteLinkValidation: {
Expand Down Expand Up @@ -87,5 +100,3 @@ export class SiteConfig {
? siteConfigJson.plantumlCheck : true; // check PlantUML's prerequisite by default
}
}

module.exports = SiteConfig;
Loading

0 comments on commit 0f12a21

Please sign in to comment.