Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(v2): allow line highlighting #1860

Merged
merged 33 commits into from
Oct 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8657816
feat(v2): allow line highlighting
lex111 Oct 19, 2019
a200e47
Refactor: use parse-numeric-range for parsing
lex111 Oct 22, 2019
a2947a4
Add line highlighting for live code blocks
lex111 Oct 22, 2019
2b0cc9b
Merge branch 'master' into lh
lex111 Oct 22, 2019
68d5adf
feat(v2): add sticky footer (#1855)
lex111 Oct 23, 2019
11f9977
fix(v2): remove empty doc sidebar container (#1870)
lex111 Oct 23, 2019
262dca3
docs: showcase user Amphora (#1873)
xtellurian Oct 24, 2019
0e66c90
fix(v2): fix search input blur on desktop (#1874)
lex111 Oct 24, 2019
91703eb
docs(v2): showcase user mbt-bundle (#1875)
tienvx Oct 24, 2019
22fb869
feat(v2): postcss should only use stage 3 features instead of stage 2…
endiliey Oct 24, 2019
ce6a725
feat(v2): add ability expand all items in doc sidebar (#1876)
lex111 Oct 24, 2019
3acf880
chore(v2): update changelog
endiliey Oct 24, 2019
6afe6b3
chore(v2): update showcase and broken link
endiliey Oct 25, 2019
8bcb5dc
perf(v2): disable hash for css modules localident in dev (#1882)
endiliey Oct 25, 2019
b347968
feat(v2): display footer in docs page for consistency (#1883)
endiliey Oct 25, 2019
11548da
docs(v2): fix format inline code (#1888)
lex111 Oct 25, 2019
a149f77
docs(v2): add docs on useful client api (#1890)
endiliey Oct 25, 2019
a9f752c
docs(v2): update config docs (#1885)
endiliey Oct 25, 2019
60a4d1d
fix(v2): do not show categories with empty items (#1891)
lex111 Oct 26, 2019
9fdda55
styles(v2): update infima and fix styles (#1892)
endiliey Oct 26, 2019
3cc1330
fix(v2): wrong css class
endiliey Oct 26, 2019
d4342dc
v2.0.0-alpha.31
endiliey Oct 26, 2019
242c9e0
chore(v2): update docs and changelog
endiliey Oct 26, 2019
2bbfbf8
docs(v2): update plugins, presets and themes docs (#1889)
endiliey Oct 26, 2019
c23f981
refactor(v2): Convert sitemap plugin to TypeScript (#1894)
moozzyk Oct 27, 2019
fabaf77
perf(v2): significantly reduce bundle size & initial html payload (#1…
endiliey Oct 27, 2019
84462e2
fix(v2): align search icon on small width device (#1893)
endiliey Oct 27, 2019
01f4d9a
refactor(v2): refactor dark toggle into a hook (#1899)
wgao19 Oct 27, 2019
98679b5
perf(v2): reduce memory usage consumption (#1900)
endiliey Oct 27, 2019
f14b6ee
misc(v1): use primary color for hovered items in table of contents (#…
blitz137 Oct 27, 2019
421598e
fix(v1): mobile safari search input misalignment in header (#1895)
jsardev Oct 27, 2019
812a30b
misc(v2): v1 backward compatibility for USE_SSH env var (#1880)
yns88 Oct 27, 2019
e509311
Merge branch 'lh' of https://github.com/lex111/docusaurus into lex111-lh
yangshun Oct 27, 2019
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ packages/docusaurus-init/lib/
packages/docusaurus-plugin-content-blog/lib/
packages/docusaurus-plugin-content-docs/lib/
packages/docusaurus-plugin-content-pages/lib/
packages/docusaurus-plugin-sitemap/lib/
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ packages/docusaurus-init/lib/
packages/docusaurus-plugin-content-blog/lib/
packages/docusaurus-plugin-content-docs/lib/
packages/docusaurus-plugin-content-pages/lib/
packages/docusaurus-plugin-sitemap/lib/
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ packages/docusaurus-init/lib/
packages/docusaurus-plugin-content-blog/lib/
packages/docusaurus-plugin-content-docs/lib/
packages/docusaurus-plugin-content-pages/lib/
packages/docusaurus-plugin-sitemap/lib/
40 changes: 36 additions & 4 deletions CHANGELOG-2.x.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,48 @@
# Docusaurus 2 Changelog

## Unreleased

- Reduce memory usage consumption.
- Slightly adjust search icon position to be more aligned on small width device.
- Convert sitemap plugin to TypeScript.
- Significantly reduce main bundle size and initial HTML payload on production build. Generated JS files from webpack is also shorter in name.
- Refactor dark toggle into a hook.
- Changed the way we read the `USE_SSH` env variable during deployment to be the same as in v1.
- Add highlight specific lines in code blocks.

## 2.0.0-alpha.31

- Footer is now sticky/ pinned to the bottom of the viewport in desktop browsers.
- Footer is now also displayed in docs page for consistency.
- Remove empty doc sidebar container if sidebar for a particular doc page does not exist. Otherwise, it will cause an additional empty space.
- Default PostCSS loader now only polyfills stage 3+ features (previously it was stage 2) like Create React App. Stage 2 CSS is considered relatively unstable and subject to change while Stage 3 features will likely become a standard.
- Fix search bar focus bug. When you put the focus on search input, previously the focus will remain although we have clicked to other area outside of the search input.
- New themeConfig option `sidebarCollapsible`. It is on by default. If explicitly set to `false`, all doc items in sidebar is expanded. Otherwise, it will still be a collapsible sidebar.
- Disable adding hashes to the generated class names of CSS modules in dev mode. Generating unique identifiers takes some time, which can be saved since including paths to files in class names is enough to avoid collisions.
- Fix showing sidebar category with empty items.
- Update infima from 0.2.0-alpha.2 to 0.2.0-alpha.3
- Fix pagination nav and right sidebar color contrast ratio
- Fix sidebar arrow color in dark mode
- Fix footer mobile issue
- Increase sidebar width
- etc

## 2.0.0-alpha.30
- Fix babel transpilation include/exclude logic to be more efficient. This also fix a very weird bug `TypeError: Cannot assign to read only property 'exports' of object '#<Object>'` if your website path contains `docusaurus` word in it.

- Fix babel transpilation include/exclude logic to be more efficient. This also fix a very weird bug `TypeError: Cannot assign to read only property 'exports' of object '#<Object>'`.([#1868](https://github.com/facebook/docusaurus/pull/1868))

If you are still encountering the error. Please check whether you use `module.exports` for your `.js` file instead of doing `export` (mixing CJS and ES). See https://github.com/webpack/webpack/issues/4039#issuecomment-477779322 and https://github.com/webpack/webpack/issues/4039#issuecomment-273804003 for more context.

## 2.0.0-alpha.29

**HOTFIX for 2.0.0-alpha.28**.
**HOTFIX for 2.0.0-alpha.28**.

- Fix missing `core-js` dependencies on `@docusaurus/core`.
- Fix wrong `@babel/env` preset configuration that causes build compilation error.
- New UI for webpack compilation progress bar.

## 2.0.0-alpha.28

- Further reduce memory usage to avoid heap memory allocation failure.
- Fix `keywords` frontmatter for SEO not working properly.
- Fix `swizzle` command not passing context properly to theme packages.
Expand All @@ -19,7 +51,7 @@
- Fix logo URL in footer to be appended with baseUrl automatically.
- Add the option `--no-open` for `start` command.
- Set `@babel/env` useBuiltins to `usage`. This will automatically use browserlist and import polyfills required.
- Modified TerserWebpackPlugin `terserOptions` for better cross-browser compatibility.
- Modified TerserWebpackPlugin `terserOptions` for better cross-browser compatibility.
- **BREAKING** `withBaseUrl` is renamed to `useBaseUrl` because its a React Hooks. Make sure you import/rename it correctly. Eg: `import useBaseUrl from '@docusaurus/useBaseUrl`;
- Fix potential security vulnerability because we're exposing the directory structure of the host machine.
- Upgrade dependencies.
Expand All @@ -29,7 +61,7 @@
- Add `@theme/Tabs` which can be used to implement multi-language code tabs.
- Implement `custom_edit_url` and `hide_title` markdown header for docusaurus v1 feature parity.
- Reduce memory usage and slightly faster production build.
- Misc dependency upgrades.
- Misc dependency upgrades.

## 2.0.0-alpha.26

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "3.14.1",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"npmClient": "yarn",
"useWorkspaces": true
}
6 changes: 4 additions & 2 deletions packages/docusaurus-1.x/lib/static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ input[type='search'] {
padding-left: 10px;
position: absolute;
right: 10px;
top: 15px;
top: 10px;
}

.navSearchWrapper:before {
Expand Down Expand Up @@ -1382,6 +1382,7 @@ input::placeholder {
transition: background-color 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55),
width 0.2s cubic-bezier(0.68, -0.55, 0.265, 1.55), color 0.2s ease;
width: 100%;
height: 30px;
}

.reactNavSearchWrapper input#search_input_react:focus,
Expand Down Expand Up @@ -1977,7 +1978,8 @@ input::placeholder {
color: #717171;
}

.onPageNav .toc-headings > li > a.active {
.onPageNav .toc-headings > li > a.active,
.onPageNav .toc-headings > li > a.hover {
font-weight: 600;
color: $primaryColor;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-1.x/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "docusaurus",
"description": "Easy to Maintain Open Source Documentation Websites",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"license": "MIT",
"keywords": [
"documentation",
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-init/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docusaurus/init",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"description": "Create Docusaurus app easily",
"repository": {
"type": "git",
Expand Down
6 changes: 3 additions & 3 deletions packages/docusaurus-init/templates/classic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "docusaurus-2-classic-template",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"private": true,
"scripts": {
"docusaurus": "docusaurus",
Expand All @@ -10,8 +10,8 @@
"deploy": "docusaurus deploy"
},
"dependencies": {
"@docusaurus/core": "^2.0.0-alpha.30",
"@docusaurus/preset-classic": "^2.0.0-alpha.30",
"@docusaurus/core": "^2.0.0-alpha.31",
"@docusaurus/preset-classic": "^2.0.0-alpha.31",
"classnames": "^2.2.6",
"react": "^16.8.4",
"react-dom": "^16.8.4"
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-mdx-loader/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docusaurus/mdx-loader",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"description": "Docusaurus Loader for MDX",
"main": "src/index.js",
"publishConfig": {
Expand Down
8 changes: 4 additions & 4 deletions packages/docusaurus-plugin-content-blog/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docusaurus/plugin-content-blog",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"description": "Blog plugin for Docusaurus",
"main": "lib/index.js",
"scripts": {
Expand All @@ -11,11 +11,11 @@
},
"license": "MIT",
"devDependencies": {
"@docusaurus/types": "^2.0.0-alpha.30"
"@docusaurus/types": "^2.0.0-alpha.31"
},
"dependencies": {
"@docusaurus/mdx-loader": "^2.0.0-alpha.30",
"@docusaurus/utils": "^2.0.0-alpha.30",
"@docusaurus/mdx-loader": "^2.0.0-alpha.31",
"@docusaurus/utils": "^2.0.0-alpha.31",
"fs-extra": "^8.1.0",
"globby": "^10.0.1",
"loader-utils": "^1.2.3",
Expand Down
8 changes: 4 additions & 4 deletions packages/docusaurus-plugin-content-docs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docusaurus/plugin-content-docs",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"description": "Docs content plugin for Docusaurus",
"main": "lib/index.js",
"scripts": {
Expand All @@ -11,11 +11,11 @@
},
"license": "MIT",
"devDependencies": {
"@docusaurus/types": "^2.0.0-alpha.30"
"@docusaurus/types": "^2.0.0-alpha.31"
},
"dependencies": {
"@docusaurus/mdx-loader": "^2.0.0-alpha.30",
"@docusaurus/utils": "^2.0.0-alpha.30",
"@docusaurus/mdx-loader": "^2.0.0-alpha.31",
"@docusaurus/utils": "^2.0.0-alpha.31",
"cross-spawn": "^7.0.1",
"fs-extra": "^8.1.0",
"globby": "^10.0.1",
Expand Down
6 changes: 3 additions & 3 deletions packages/docusaurus-plugin-content-pages/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docusaurus/plugin-content-pages",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"description": "Pages content plugin for Docusaurus",
"main": "lib/index.js",
"scripts": {
Expand All @@ -11,8 +11,8 @@
},
"license": "MIT",
"dependencies": {
"@docusaurus/types": "^2.0.0-alpha.30",
"@docusaurus/utils": "^2.0.0-alpha.30",
"@docusaurus/types": "^2.0.0-alpha.31",
"@docusaurus/utils": "^2.0.0-alpha.31",
"globby": "^10.0.1"
},
"peerDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-google-analytics/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docusaurus/plugin-google-analytics",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"description": "Global analytics (analytics.js) plugin for Docusaurus",
"main": "src/index.js",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-google-gtag/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docusaurus/plugin-google-gtag",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"description": "Global Site Tag (gtag.js) plugin for Docusaurus",
"main": "src/index.js",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/docusaurus-plugin-ideal-image/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@docusaurus/plugin-ideal-image",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"description": "Docusaurus Plugin to generate an almost ideal image (responsive, lazy-loading, and low quality placeholder)",
"main": "src/index.js",
"publishConfig": {
Expand Down
8 changes: 6 additions & 2 deletions packages/docusaurus-plugin-sitemap/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
{
"name": "@docusaurus/plugin-sitemap",
"version": "2.0.0-alpha.30",
"version": "2.0.0-alpha.31",
"description": "Simple sitemap generation plugin for Docusaurus",
"main": "src/index.js",
"main": "lib/index.js",
"scripts": {
"tsc": "tsc"
},
"publishConfig": {
"access": "public"
},
"license": "MIT",
"dependencies": {
"@docusaurus/types": "^2.0.0-alpha.30",
"sitemap": "^3.2.2"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,30 @@
*/

import createSitemap from '../createSitemap';
import {DocusaurusConfig} from '@docusaurus/types';
import DEFAULT_OPTIONS from '../index';

describe('createSitemap', () => {
test('simple site', () => {
const sitemap = createSitemap({
siteConfig: {
const sitemap = createSitemap(
{
url: 'https://example.com',
} as DocusaurusConfig,
['/', '/test'],
{
cacheTime: 600,
changefreq: 'daily',
priority: 0.7,
},
routesPaths: ['/', '/test'],
});
expect(sitemap).toContain(
);
expect(sitemap.toString()).toContain(
`<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">`,
);
});

test('empty site', () => {
expect(() => {
createSitemap({});
createSitemap({} as any, [], {} as any);
}).toThrowErrorMatchingInlineSnapshot(
`"Url in docusaurus.config.js cannot be empty/undefined"`,
);
Expand Down
33 changes: 0 additions & 33 deletions packages/docusaurus-plugin-sitemap/src/createSitemap.js

This file was deleted.

36 changes: 36 additions & 0 deletions packages/docusaurus-plugin-sitemap/src/createSitemap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

import sitemap, {SitemapItemOptions} from 'sitemap';
import {PluginOptions} from './types';
import {DocusaurusConfig} from '@docusaurus/types';

export default function createSitemap(
siteConfig: DocusaurusConfig,
routesPaths: string[],
options: PluginOptions,
) {
const {url: hostname} = siteConfig;
if (!hostname) {
throw new Error('Url in docusaurus.config.js cannot be empty/undefined');
}

const urls = routesPaths.map(
routesPath =>
({
url: routesPath,
changefreq: options.changefreq,
priority: options.priority,
} as SitemapItemOptions),
);

return sitemap.createSitemap({
hostname,
cacheTime: options.cacheTime,
urls,
});
}
Loading