Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,30 +114,6 @@ cd docs && python -m SimpleHTTPServer 3000
cd docs && python -m http.server 3000
```

## Loading dialog

If you want, you can show a loading dialog before docsify starts to render your documentation:

```html
<!-- index.html -->

<div id="app">Please wait...</div>
```

By default, the `id` attribute of the main container is `app`. If you want to use a different id, you must also set the `data-app` attribute, and [configure](configuration.md#el) the `el` parameter accordingly:

```html
<!-- index.html -->

<div data-app id="main">Please wait...</div>

<script>
window.$docsify = {
el: '#main',
};
</script>
```

<script>
(function() {
const linkElm = document.querySelector('#template a[download="index.html"]');
Expand Down
3 changes: 3 additions & 0 deletions src/core/event/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isMobile, mobileBreakpoint } from '../util/env.js';
import * as dom from '../util/dom.js';
import { stripUrlExceptId } from '../router/util.js';

/** @typedef {import('../Docsify.js').Constructor} Constructor */

Expand Down Expand Up @@ -474,6 +475,8 @@ export function Events(Base) {
return;
}

href = stripUrlExceptId(href);

const oldActive = dom.find(sidebar, 'li.active');
const newActive = dom
.find(
Expand Down
3 changes: 2 additions & 1 deletion src/core/render/compiler/heading.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getAndRemoveDocsifyIgnoreConfig,
} from '../utils.js';
import { slugify } from '../slugify.js';
import { stripUrlExceptId } from '../../router/util.js';

export const headingCompiler = ({ renderer, router, compiler }) =>
(renderer.heading = function ({ tokens, depth }) {
Expand All @@ -20,7 +21,7 @@ export const headingCompiler = ({ renderer, router, compiler }) =>
nextToc.ignoreSubHeading = ignoreSubHeading;
const slug = slugify(config.id || str);
const url = router.toURL(router.getCurrentPath(), { id: slug });
nextToc.slug = url;
nextToc.slug = stripUrlExceptId(url);
compiler.toc.push(nextToc);

// Note: tabindex="-1" allows programmatically focusing on heading
Expand Down
16 changes: 16 additions & 0 deletions src/core/router/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,22 @@ export function stringifyQuery(obj, ignores = []) {
return qs.length ? `?${qs.join('&')}` : '';
}

export function stripUrlExceptId(str) {
const [path, queryString] = str.split('?');
if (!queryString) {
return str;
}

const params = new URLSearchParams(queryString);
const id = params.get('id');

if (id !== null) {
return `${path}?id=${id}`;
}

return path;
}

export const isAbsolutePath = cached(path => {
return /(:|(\/{2}))/g.test(path);
});
Expand Down
16 changes: 8 additions & 8 deletions src/plugins/search/component.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { search } from './search.js';
import { escapeHtml, search } from './search.js';
import cssText from './style.css';

let NO_DATA_TEXT = '';
Expand Down Expand Up @@ -75,11 +75,11 @@ function bindEvents() {
let timeId;

/**
Prevent to Fold sidebar.

When searching on the mobile end,
the sidebar is collapsed when you click the INPUT box,
making it impossible to search.
* Prevent to Fold sidebar.
*
* When searching on the mobile end,
* the sidebar is collapsed when you click the INPUT box,
* making it impossible to search.
*/
Docsify.dom.on(
$search,
Expand Down Expand Up @@ -129,10 +129,10 @@ export function init(opts, vm) {
return;
}

const keywords = vm.router.parse().query.s;
const keywords = vm.router.parse().query.s || '';

Docsify.dom.style(cssText);
tpl(vm, keywords);
tpl(vm, escapeHtml(keywords));
bindEvents();
keywords && setTimeout(_ => doSearch(keywords), 500);
}
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/search/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { markdownToTxt } from './markdown-to-txt.js';
import Dexie from 'dexie';

let INDEXES = {};
let INDEXES = [];

const db = new Dexie('docsify');
db.version(1).stores({
Expand Down Expand Up @@ -48,7 +48,7 @@ function resolveIndexKey(namespace) {
: LOCAL_STORAGE.INDEX_KEY;
}

function escapeHtml(string) {
export function escapeHtml(string) {
const entityMap = {
'&': '&amp;',
'<': '&lt;',
Expand Down Expand Up @@ -102,7 +102,7 @@ function getListData(token) {
export function genIndex(path, content = '', router, depth, indexKey) {
const tokens = window.marked.lexer(content);
const slugify = window.Docsify.slugify;
const index = {};
const index = [];
let slug;
let title = '';

Expand Down Expand Up @@ -299,7 +299,7 @@ export async function init(config, vm) {
INDEXES = await getData(indexKey);

if (isExpired) {
INDEXES = {};
INDEXES = [];
} else if (!isAuto) {
return;
}
Expand Down
8 changes: 8 additions & 0 deletions src/themes/addons/core-dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,11 @@
border-color: rgba(255, 255, 255, 0.5);
}
}

/* Force light mode for iframes in dark theme */
iframe,
iframe *,
iframe[src],
iframe[src] * {
color-scheme: light;
}
1 change: 1 addition & 0 deletions src/themes/shared/_coverpage.css
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
&:hover {
text-decoration-color: transparent;
}
color: var(--cover-title-color);
}

small {
Expand Down
4 changes: 2 additions & 2 deletions src/themes/shared/_vars.css
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
--callout-charm-translate : -50% -50%;
--callout-color : ;
--callout-padding : 1em 1em 1em var(--callout-charm-size);
--code-bg : var(--color-mono-1);
--code-bg : var(--color-mono-2);
--code-color : ;
--codeblock-bg : var(--code-bg);
--codeblock-color : var(--code-color);
Expand Down Expand Up @@ -199,4 +199,4 @@
--callout-charm-color : #fff;
--callout-charm-content: 'i';
--callout-color : ;
}
}
Loading