Commit graph

1596 commits

Author SHA1 Message Date
Sébastien Lorber
700a82aefe
feat: multiple playground choices (#5207)
* poc of using netlify functions for playground redirections

* push

* cleanup

* restore files

* fix netlify functions?

* fix netlify functions?

* implement serverless functions for playgrounds with persistent cookie

* move new.docusaurus.io to monorepo packages

* move new.docusaurus.io to monorepo packages

* lockfile

* push

* catch-all redirect

* Translate/Interpolate: add better error message if not used correctly

* Add /docs/playground page

* Add some additional doc
2021-07-22 21:10:36 +02:00
Michel Weststrate
ddc0f46b73
fix: cli upgrade helper fail when no package.dependencies (#5204)
* Fix handling of empty `dependencies` section. 

In Flipper, https://github.com/facebook/flipper/blob/master/website/package.json,  all our dependencies live in `devDependecies` of our `package.json`. As a result `dependencies` is not set, causing a crash when running `yarn start`:

```
/Users/mweststrate/fbsource/xplat/sonar/website/node_modules/@docusaurus/core/bin/docusaurus.js:50
  const siteDocusaurusPackagesForUpdate = Object.keys(sitePkg.dependencies)
                                                 ^

TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at Object.<anonymous> (/Users/mweststrate/fbsource/xplat/sonar/website/node_modules/@docusaurus/core/bin/docusaurus.js:50:50)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1043:10)
    at internal/main/run_main_module.js:17:11
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
```

Setting `"dependencies": {}`, works as work around, but this patch fixes the crash, and makes sure the deps are upgraded as well if they live in `devDependencies` instead of `dependencies`.

* formatting fix
2021-07-22 16:13:57 +02:00
Sébastien Lorber
4d06f26c1f
fix(v2): Fix MDX docs being considered as partials when siteDir match the _ prefix convention (#5199)
* Add _ to dogfood docs folder to cover against edge case

* Fix edge case with MDX partials when site / content dir contains a _ prefix

* add globUtils tests

* proper dogfooding folder re-organization, all content plugins being used

* refactor dogfooding folder + expose /tests page index

* fix page plugin ignoring options.routeBasePath
2021-07-21 14:13:51 +02:00
Alexey Pyltsyn
12cea5eefe
refactor(v2): increase content area if blog sidebar is off (#5171)
* refactor(v2): increase content area if blog sidebar is off

* Replace render prop with children to simplicity sake

* Revert to previous layout
2021-07-20 14:11:08 +02:00
Alexey Pyltsyn
88de3a5106
fix(v2): wrap dropdown item to missing li element + remove extra attributes (#5179)
* fix(v2): wrap dropdown item to li element

* Remove extra attrs

* Fix types

* Exclude type/position from parent component

* Fix for positon

* Avoid cloneElement

* Update packages/docusaurus-theme-classic/src/theme/NavbarItem/index.tsx

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>

Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
2021-07-19 19:17:45 +02:00
Alexey Pyltsyn
44225a3df9
fix(v2): pass all props to CodeBlock component (#5183) 2021-07-16 14:55:19 +02:00
Alexey Pyltsyn
54e4b02666
fix(v2): add base URL to content attribute of head tags PWA (#5185) 2021-07-16 11:56:00 +02:00
Joshua Chen
633c2f60dd
fix(v2): Fix type for navlink label (#5176)
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
2021-07-15 15:40:39 +02:00
Alexey Pyltsyn
f7b5e90390
refactor(v2): automatically add base URL to PWA head tags (#5169)
* refactor(v2): automatically add base URL to PWA head tags

* Add baseUrl only if necessary
2021-07-15 15:38:14 +02:00
Sébastien Lorber
8bdb3da233
feat(v2): generalize usage of _ prefix convention to exclude content files/folders (#5173)
* create a swizzleWarning partial for shared text

* Generalize usage of _ prefix convention to exclude content files/folders

* add api doc

* MDX loader should not expect metadata/frontmatter on MDX partial files
2021-07-15 13:21:41 +02:00
Sébastien Lorber
0851e0e5bf
fix(v2): hide mobile collapsible doc toc if no headings (#5172) 2021-07-15 09:51:23 +02:00
Sébastien Lorber
818fb3956b
refactor(v2): mobile dropdown navbar: expand when subitem become active (#5168) 2021-07-14 19:42:47 +02:00
Joshua Chen
007e901354
feat(v2): allow any type of NavbarItem to be passed in a navbar dropdown (#5072)
* Initial work

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* More elegant `eslint-disable`

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Fix typing

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Allow doc links in dropdown

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Allow more dropdowns to use linklike items

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Finalize

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Dogfood

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Disallow nested dropdowns

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Better typing

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Complete type fix

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Use flatmap

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Patch

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Test

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Try fix

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Style change

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Revert (to test)

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Hmmm

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* I know what's wrong

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Does this work?

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Nope

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Wrong class name

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Pass prop to render dropdown item differently

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* This looks better

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Tests passed

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Separate dropdown from default

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Pourquois?

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Better prop typing

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Make code simpler

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* There's some extra className

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Test

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* More test

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* A-ha!

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Test again?

* Add backward compatibility

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Incorporate my type fix

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Resolve conflict

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* minor refactor

* minor refactors

* allow usage of ES2019 in browser code

* revert NavLink rename

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-07-14 18:19:08 +02:00
Sébastien Lorber
677e53d4db
perf(v2): lazy collapsibles, reduce html output and build times (#5136)
* Allow collapsible to be lazy

* cleanup comments

* CollapsibleLazy little bug
2021-07-14 16:18:52 +02:00
Sébastien Lorber
d3764f77fe
fix(v2): revert webpack.resolve.symlinks = false (#5164)
* WathcOptions should work even if Webpack does not resolve symlinks

* re-enable webpack resolve.symlinks = true

* Use symlinked folder as source
2021-07-13 20:11:08 +02:00
Sébastien Lorber
f33cd079c2
fix(v2): Fix Collapsible hydration layout shift (#5159) 2021-07-13 17:31:26 +02:00
Alexey Pyltsyn
fa9b0cd9c1
fix(v2): disable default behavior when click on collapsible item (#5161) 2021-07-13 17:13:07 +02:00
Sébastien Lorber
12faed89db
fix(v2): Fix navbar mobile sidebar secondary menu bugs + refactor navbar (#5157) 2021-07-13 13:01:06 +02:00
Alexey Pyltsyn
45a87a1479
fix(v2): improve work of useCollapsible hook with multiple clicks (#5146) 2021-07-13 10:17:50 +02:00
Pranab Das
0fdb6836ad
refactor(v2): Hindi translation for semantic doc sidebar (#5154) 2021-07-13 10:10:29 +02:00
Alexey Pyltsyn
dd035088c6
refactor(v2): use Collapsible for mobile nav items (#5145) 2021-07-13 10:00:00 +02:00
nirtamir2
bb4ce1a54b
refactor(v2): Update Hebrew translations (#5138) 2021-07-12 20:04:59 +02:00
Pranab Das
1a3557b917
refactor(v2): bn translation improvements for semantic doc sidebar (#5140) 2021-07-12 19:58:19 +02:00
Joshua Chen
be695aa0e9
feat(v2): complete Chinese code translations (#5139)
* feat(v2): complete Chinese code translations

* Complete zh-Hant translation

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
2021-07-12 19:42:03 +02:00
Forresst
3e5a832590
fix(v2): add missing french translations for mobile (#5151) 2021-07-12 19:40:07 +02:00
Clément Vannicatte
7babfe0363
chore(v2): update @docsearch/react (#5135) 2021-07-09 17:52:59 +02:00
Alexey Pyltsyn
9536ef900d
feat(v2): redesign mobile UX: inline TOC + doc sidebar in main menu (#4273)
* feat(v2): mobile TOC

* Bug fixes and various improvements

* Redesign

* extract TOCCollapsible component

* TS improvements

* Assign sidebar name directly to the doc route => no need for either permalinkToSidebar or GlobalData

* revert changes to useWindowSize, fix FOUC issues

* extract DocSidebarDesktop component

* remove now useless menu infima classes

* TOCHeadings => rename + remove unused onClick prop

* Extract DocSidebarItem

* minor renaming

* replace GlobalData usage by a React teleport system to render in the navbar mobile sidebar menu directly from the DocPage component

* useWindowSize => simulate SSR size in dev to make FOUC issues more obvious

* fix remaining sidebar layout shift

* update docs snapshots

* remove unused code translations

* remove unused code translations

* fix minor update-code-translations bug

* Add more build-size paths to watch

* Restyle back button

* Add  missing`menu` class

* extract useShallowMemoizedObject

* fix routes tests + better routes formatting

* use Translate api for labels

* use Translate api for labels

* Update translations

* Improve dark mode support for back button

* Merge branch 'master' into lex111/inline-color-code

# Conflicts:
#	packages/core/dist/css/default-dark/default-dark-rtl.min.css
#	packages/core/dist/css/default-dark/default-dark.min.css
#	packages/core/dist/css/default/default-rtl.min.css
#	packages/core/dist/css/default/default.min.css

* replace useCollapse by new useCollapsible

* Cleanup and use clean-btn for TOCCollapsible button

* Make TOC links clickable over full width

* Cleanup

* fix uncollapsible sidebar that can be collapsed + create <Collapsible> component

* dependency array typo

* rollback sidebars community commit typo

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-07-09 16:50:38 +02:00
Sébastien Lorber
f03479f69e
test(v2): dogfooding: add huge sidebar for testing purposes (#5130)
* dogfoog: add huge sidebar for testing purposes

* Add standalone doc + build-size tracking
2021-07-08 20:26:55 +02:00
Sébastien Lorber
dc9f104ccc
fix(v2): remove webpackConfig.resolve.symlinks: true (#5126)
* remove webpackConfig.resolve.symlinks: true

* Add docs-test docs plugin instance to validate using a symlink folder as docs source is possible

* comment

* useful comments
2021-07-08 18:59:56 +02:00
Sébastien Lorber
7b2723717c
fix(v2): fix d.ts lint error (#5129) 2021-07-08 18:17:53 +02:00
Christian Flach
0acbbc3d38
fix(v2): Invalid type definition for injectHtmlTags (#5124)
This was likely a typo, and resulted in the following error when using Typescript strict mode:

node_modules/@docusaurus/types/src/index.d.ts(250,14): error TS7031: Binding element 'Content' implicitly has an 'any' type.
2021-07-08 13:09:55 +02:00
Marçal Junior
f316ff5cd1
refactor(v2): pt-BR: improve semantic doc sidebar and tags (#5118) 2021-07-07 19:48:38 +02:00
Alexey Pyltsyn
237d1a31f5
fix(v2): introduce useCollapsible to fix collapsible animation perf issues (#5116)
* fix(v2): avoid slowdown transition with huge sidebar items

* move useCollapsible to theme-common

* @docusaurus/theme-classic => watch mode should include type-checking

* refactor useCollapsible => encapsulate more behavior / state / ref inside it, making code simpler for component using it

* useCollapseAnimation => animate DOM properties directly instead of using React inline styles => optimize perf from 4 render per click to 1 render per click

* add missing items in deps array

* rename ref to collapsibleRef

* lint

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-07-07 18:50:13 +02:00
Sébastien Lorber
fbdeefcac6
fix(v2): Fix update-notifier not run at first and not notifying consistently (#5110)
* Fix update-notifier issues

* update for notifier disabled
2021-07-01 15:37:54 +02:00
Sébastien Lorber
d65cc9d23f
fix(v2): fix SkipToContent programmatic focus when updating querystring (#5104) 2021-06-30 19:37:40 +02:00
Sébastien Lorber
15a2b59f9f
fix(v2): fix redirect plugin when trailingSlash=false for .html extension (#5102)
* another redirect plugin fix when trailingSlash=false

* add comment
2021-06-30 17:22:51 +02:00
Sébastien Lorber
1ec2c95e3d
chore(v2): prepare v2.0.0-beta.3 release (#5098)
* beta.3

* publish guide

* publish guide

* v2.0.0-beta.3
2021-06-30 16:05:49 +02:00
Adam Uhlíř
823b020c34
fix(v2): classic theme - semantic correct anchors links (#5080)
* fix(v2): semantic correct anchors

* chore: ignore linting
2021-06-30 15:24:03 +02:00
Joshua Chen
c3127b65d1
fix(v2): fix typos in swizzle command (#5094)
* Fix typos in swizzle command

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>

* Unnecessary comma

Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
2021-06-30 15:20:26 +02:00
Sébastien Lorber
0f144213d6
fix(v2): fix useEffect infinite loop in blogOnly mode (#5097) 2021-06-30 12:50:06 +02:00
Sébastien Lorber
ab3821cb39
fix(v2): fix swizzle readComponent (#5095) 2021-06-30 12:20:57 +02:00
Alexey Pyltsyn
1cecd78f25
feat(v2): add icon to external footer links (#5092) 2021-06-30 10:54:26 +02:00
Sébastien Lorber
e5916dc596
fix(v2): redirect from should work with trailingSlash: true (#5093) 2021-06-30 10:44:03 +02:00
Sébastien Lorber
a78e4f19b2
fix(v2): redirect plugin should emit redirect files with lower precedence than redirect target (#5085)
* revert old behavior of the redirect plugin

* revert old behavior of the redirect plugin
2021-06-29 19:34:55 +02:00
Alexey Pyltsyn
7fe2a9891d
fix(v2): restore previous scroll position on back button click (#5081) 2021-06-29 15:31:25 +02:00
Sébastien Lorber
7592982960
fix(v2): never remove trailing slash from site root like '/baseUrl/' (#5082)
* never apply trailingSlash to site root ('/baseUrl/') => only subroutes

* add deprecation comment for loadContext.baseUrl in favor of loadContext.siteConfig.baseUrl

* commit typo

* useless code
2021-06-29 15:17:23 +02:00
Taylor Reece
41b78466da
fix(v2): sitemap should respect the global trailingSlash config option. (#5068)
* Sitemap should respect the global trailingSlash config option.

* improve tests for createSitemap / trailingSlash

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-06-29 11:15:00 +02:00
Danny Lin
79031af16f
fix(v2): allow negative sidebar positions (#5074)
In some cases, negative sidebar positions can be useful for reversing
the sorting order with minimal maintenance overhead. For example, a docs
folder with changelogs for historical versions should be sorted in
reverse chronological order. This is easy to do for semantic version
numbers by converting them into a negative numerical representation,
e.g. 11.5.1 -> -110501.

The alternative is to make the first version start with a large position
number (e.g. 9999) and decrement it for each version. However, this
requires referring to older versions to get the current sequence number,
thus increasing maintenance overhead. It also makes the number less
intuitive and more prone to error.

Negative sidebar positions work great for this purpose, so make the
front matter validator allow them again as #4796 broke this use case.
2021-06-28 19:59:05 +02:00
Sébastien Lorber
4d93c894f2
chore: unstable yarn.lock (#5067)
* fix unstable yarn.lock

* remove useless typescript dep
2021-06-25 16:19:12 +02:00
Alexey Pyltsyn
5883e2b245
fix(v2): restore responsive menu (#5063) 2021-06-25 15:19:23 +02:00