Skip to content

Commit e738653

Browse files
committed
update DocsifyConfig types and docs, improve/fix a few types, and add a test that ensures types are properly exported and consumable in TS ESM projects.
1 parent 2572b18 commit e738653

24 files changed

+2909
-174
lines changed

.gitignore

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
.vercel
55
_playwright-report
66
_playwright-results
7-
dist
8-
lib
97
node_modules
108

119
# Files
@@ -14,3 +12,10 @@ node_modules
1412

1513
# Exceptions
1614
!.gitkeep
15+
16+
# Output folder for the global build only
17+
dist
18+
19+
# TypeScript declaration files for standard ESM consumption
20+
src/**/*.d.ts
21+
src/**/*.d.ts.map

docs/configuration.md

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ window.$docsify = {
456456

457457
## name
458458

459-
- Type: `String`
459+
- Type: `Boolean | String`
460460

461461
Website name as it appears in the sidebar.
462462

@@ -474,6 +474,22 @@ window.$docsify = {
474474
};
475475
```
476476

477+
If `true`, the website name will be inferred from the document's `<title>` tag.
478+
479+
```js
480+
window.$docsify = {
481+
name: true,
482+
};
483+
```
484+
485+
If `false` or empty, no name will be displayed.
486+
487+
```js
488+
window.$docsify = {
489+
name: false,
490+
};
491+
```
492+
477493
## nameLink
478494

479495
- Type: `String`
@@ -652,6 +668,10 @@ window.$docsify = {
652668
};
653669
```
654670

671+
## plugins
672+
673+
See [Plugins](./plugins.md).
674+
655675
## relativePath
656676

657677
- Type: `Boolean`
@@ -694,7 +714,7 @@ window.$docsify = {
694714

695715
## repo
696716

697-
- Type: `String`
717+
- Type: `false | String`
698718

699719
Configure the repository url, or a string of `username/repo`, to add the [GitHub Corner](http://tholman.com/github-corners/) widget in the top right corner of the site.
700720

@@ -706,6 +726,8 @@ window.$docsify = {
706726
};
707727
```
708728

729+
If `false` or empty, no GitHub corner will be displayed.
730+
709731
## requestHeaders
710732

711733
- Type: `Object`
@@ -887,9 +909,9 @@ window.$docsify = {
887909
Determines if/how the site's [skip navigation link](https://webaim.org/techniques/skipnav/) will be rendered.
888910

889911
```js
890-
// Render skip link for all routes (default)
912+
// Render skip link for all routes
891913
window.$docsify = {
892-
skipLink: 'Skip to main content',
914+
skipLink: 'Skip to content',
893915
};
894916
```
895917

@@ -912,6 +934,13 @@ window.$docsify = {
912934
};
913935
```
914936

937+
```js
938+
// Use default
939+
window.$docsify = {
940+
skipLink: true, // "Skip to main content"
941+
};
942+
```
943+
915944
## subMaxLevel
916945

917946
- Type: `Number`

docs/plugins.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# List of Plugins
22

3+
These are built-in and external plugins for Docsify.
4+
5+
See also how to [Write a Plugin](./write-a-plugin.md).
6+
37
## Full text search
48

59
By default, the hyperlink on the current page is recognized and the content is saved in `IndexedDB`. You can also specify the path to the files.

package.json

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,22 @@
2424
},
2525
"type": "module",
2626
"main": "dist/docsify.js",
27+
"types": "src/core/Docsify.d.ts",
2728
"exports": {
2829
".": "./src/core/Docsify.js",
2930
"./*": "./*"
3031
},
3132
"files": [
32-
"dist"
33+
"dist",
34+
"src"
3335
],
3436
"lint-staged": {
3537
"*.js": "eslint --fix"
3638
},
3739
"dependencies": {
40+
"common-tags": "^1.8.0",
3841
"dexie": "^4.0.11",
42+
"marked": "^16.0.0",
3943
"medium-zoom": "^1.1.0",
4044
"opencollective-postinstall": "^2.0.2",
4145
"prismjs": "^1.29.0",
@@ -56,7 +60,6 @@
5660
"@types/prismjs": "^1.26.5",
5761
"axios": "^1.5.0",
5862
"browser-sync": "^3.0.2",
59-
"common-tags": "^1.8.0",
6063
"conventional-changelog-cli": "^3.0.0",
6164
"cross-env": "^10.0.0",
6265
"cssnano": "^7.0.1",
@@ -71,7 +74,6 @@
7174
"jest": "^30.0.4",
7275
"jest-environment-jsdom": "^30.0.5",
7376
"lint-staged": "^16.1.0",
74-
"marked": "^16.0.0",
7577
"npm-run-all": "^4.1.5",
7678
"postcss-cli": "^11.0.0",
7779
"postcss-import": "^16.1.0",
@@ -90,8 +92,9 @@
9092
"build:css:min": "cross-env NODE_ENV='production' npm run build:css -- --ext .min.css",
9193
"build:emoji": "node ./build/emoji.js",
9294
"build:js": "rollup -c",
93-
"build": "run-s clean build:js build:css build:css:min build:cover",
94-
"clean": "rimraf --glob dist/** themes/** _playwright*/**",
95+
"build:types": "tsc",
96+
"build": "run-s clean build:types build:js build:css build:css:min build:cover",
97+
"clean": "rimraf --glob 'dist/**' 'themes/**' '_playwright*/**' 'src/**/*.d.ts' 'src/**/*.d.ts.map'",
9598
"dev": "run-p serve:dev watch:*",
9699
"docker:build:test": "npm run docker:cli -- build:test",
97100
"docker:build": "docker build -f Dockerfile -t docsify-test:local .",
@@ -114,11 +117,15 @@
114117
"test:e2e": "playwright test",
115118
"test:e2e:chromium": "playwright test --project='chromium'",
116119
"test:e2e:ui": "playwright test --ui",
120+
"test:e2e:consume-types": "echo TODO: test the consume-types example with ESM modules",
117121
"test:integration": "npm run test:jest -- --selectProjects integration",
118122
"test:jest": "cross-env NODE_OPTIONS=--experimental-vm-modules jest",
119123
"test:unit": "npm run test:jest -- --selectProjects unit",
120124
"test:update:snapshot": "npm run test:jest -- --updateSnapshot",
125+
"test:consume-types": "cd test/consume-types && npm clean-install --install-links && npm run typecheck",
121126
"test": "run-s test:jest test:e2e",
127+
"typecheck": "tsc --noEmit",
128+
"typecheck:watch": "tsc --noEmit --watch",
122129
"watch:css": "run-p 'build:css -- --watch' 'build:css:min -- --watch'",
123130
"watch:js": "npm run build:js -- --watch"
124131
}

src/core/Docsify.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
import * as prism from 'prismjs';
1+
import prism from 'prismjs';
22
import { Router } from './router/index.js';
33
import { Render } from './render/index.js';
44
import { Fetch } from './fetch/index.js';
55
import { Events } from './event/index.js';
66
import { VirtualRoutes } from './virtual-routes/index.js';
77

8-
// CONTINUE Prism type
9-
console.log('##### Prism:', prism);
10-
118
import config from './config.js';
129
import { isFn } from './util/core.js';
1310
import { Lifecycle } from './init/lifecycle.js';

0 commit comments

Comments
 (0)