Commit graph

49 commits

Author SHA1 Message Date
Joshua Chen
1156be3f20
refactor(content-{blog,docs}): unify handling of tags (#7117) 2022-04-07 15:58:21 +02:00
Joshua Chen
13e7de853e
refactor(theme-classic): extract doc-related navbar items' logic to theme-common (#7067) 2022-03-30 14:50:04 +08:00
Joshua Chen
2e79597f83
feat(theme-classic): show blog sidebar on mobile (#7012)
* feat(theme-classic): show blog sidebar on mobile

* fix

* oops

* docs

* add a little margin

* Update display.tsx

* Update content.tsx

* reformat
2022-03-30 09:15:54 +08:00
Joshua Chen
cb03764ce5
refactor(theme): extract plumbing code of BTT button into theme-common (#7021)
* refactor(theme): extract plumbing code of BTT button into theme-common

* oops
2022-03-26 21:05:48 +08:00
Joshua Chen
b456a64f61
feat(theme-common): JSDoc for all APIs (#6974)
* feat(theme-common): JSDoc for all APIs

* fix tests
2022-03-23 21:39:19 +08:00
Joshua Chen
948271a0ff
test: improve test coverage; reorder theme-common files (#6956)
* test: improve test coverage; reorder theme-common files

* no need for this
2022-03-22 15:33:55 +08:00
Sébastien Lorber
74f653dd82
refactor(theme-{classic,common}): change how site/page/search metadata is handled (#6925) 2022-03-18 18:53:00 +01:00
Sébastien Lorber
a1d333e96b
refactor(theme-{classic,common}): split navbar into smaller components + cleanup + swizzle config (#6895) 2022-03-18 16:21:53 +01:00
Alexey Pyltsyn
ecbe0b26c5
refactor(theme-{classic,common}): refactor ColorModeToggle + useColorMode() hook (#6930)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
Co-authored-by: Sébastien Lorber <slorber@users.noreply.github.com>
2022-03-18 15:28:35 +01:00
Sébastien Lorber
8a1421a938
feat(core,theme): useRouteContext + HtmlClassNameProvider (#6933)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
2022-03-18 10:57:32 +01:00
Joshua Chen
cc0bceab9c
chore: tighten ESLint config (#6931)
* chore: tighten ESLint config

* more refactor

* refactor push

* fix
2022-03-17 17:59:41 +08:00
Sébastien Lorber
1efc6c6091
refactor(theme-classic): split theme footer into smaller components + swizzle config (#6894)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
2022-03-11 14:55:53 +01:00
Joshua Chen
c387a177e8
refactor(theme-common): unify missing context errors (#6826)
* refactor(theme-common): unify missing context errors

* update test

* more robust
2022-03-03 22:26:56 +08:00
Sébastien Lorber
ece7399d2e
fix(theme-classic): fix breadcrumb home link bug with new useHomePageRoute() hook (#6749) 2022-02-24 11:27:16 +01:00
Joshua Chen
c3370be64d
refactor: make MDX export a flat TOC list instead of tree (#6729) 2022-02-23 15:12:04 +01:00
Jody Heavener
3629b5ab39
feat(docs,theme-classic): docs breadcrumbs (#6517)
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
2022-02-16 19:02:58 +01:00
Joshua Chen
01c6f15b15
fix(theme-classic): make focused link outlined with JS disabled (#6505) 2022-02-03 18:28:10 +01:00
Joseph
8ce3cee400
feat(theme-classic): auto-collapse sibling categories in doc sidebar (#3811)
Co-authored-by: Josh-Cena <sidachen2003@gmail.com>
2022-01-20 16:38:16 +01:00
Sébastien Lorber
f87a3ead46
refactor: move @theme/hooks to @docusaurus/theme-common (#6289) 2022-01-07 19:19:35 +01:00
Christopher Klint
d987c22996
feat(theme-classic): new configuration syntax for a simple footer (#6132)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: sebastienlorber <lorber.sebastien@gmail.com>
2021-12-20 19:45:27 +01:00
Alexey Pyltsyn
58720c93e8
refactor: simplify Toggle component (#6049) 2021-12-05 09:31:57 +08:00
Sébastien Lorber
cfae5d0933
feat(content-docs): sidebar category linking to document or auto-generated index page (#5830)
Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
Co-authored-by: Armano <armano2@users.noreply.github.com>
Co-authored-by: Alexey Pyltsyn <lex61rus@gmail.com>
2021-12-03 14:44:59 +01:00
Armano
425144afc7
refactor(theme-search-algolia): migrate package to TS (#5935) 2021-11-16 20:35:09 +01:00
Joshua Chen
d1308a8736
refactor: improve setup of type declaration files (#5914) 2021-11-12 17:47:27 +01:00
Joshua Chen
334470b5d4
refactor(theme-classic): move some logic of CodeBlock to theme-common (#5922) 2021-11-12 16:43:40 +01:00
Sergio Moreno
adbc02ea38
feat(search-algolia): algolia externalUrl regex to navigate with window.href (#5795) 2021-10-29 19:53:47 +02:00
Sébastien Lorber
098f210890
chore: Enable ESLint rules of hooks + fix new lint errors (#5714) 2021-10-20 16:09:52 +02:00
Joshua Chen
c8739ec28e
polish(theme-classic): guard against potential definition mistakes in Tabs (#5674) 2021-10-14 15:47:03 +02:00
Shrugsy
7868df13f1
feat: maintain page position for clicked grouped tabs (#5618)
Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-10-13 19:08:00 +02:00
Bharat Middha
09550b0535
feat: properly type-check the Docusaurus config of new sites (#5589)
* fix: makes types DocusaurusConfig optional to match docs

* add UserDocusaurusConfig with required keys for user config

* convert UserDocusaurusConfig to use util type

* Docusaurus website config should be type-checked by CI + fix all existing issues

* add doc for config typechecking

* Update template configs for TS autocompletion

* fix last config typechecking bugs

* reapply prettier

* reapply prettier-docs

* Fix TS doc: add missing ()

* fix some docu plugin types

* add "const config" for simpler jsdoc annotation

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-09-30 17:49:44 +02:00
Erick Zhao
c86dfbda61
feat(v2): allow specifying TOC max depth (themeConfig + frontMatter) (#5578)
* feat: add all TOC levels to MDX loader

* feat: add theme-level config for heading depth

* test: add remark MDX loader test

* fix: limit maxDepth validation to H2 - H6

* refactor: set default `maxDepth` using `joi`

* refactor: `maxDepth` -> `maxHeadingLevel

* refactor: invert underlying TOC depth API

* refactor: make TOC algorithm level-aware

* feat: add support for per-doc TOC heading levels

* feat: support document-level heading levels for blog

* fix: correct validation for toc level frontmatter

* fix: ensure TOC doesn't generate redundant DOM

* perf: simpler TOC heading search alg

* docs: document heading level props for `TOCInline`

* Update website/docs/guides/markdown-features/markdown-features-inline-toc.mdx

Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>

* docs: fix docs (again)

* create dedicated  test file for heading searching logic: exhaustive tests will be simpler to write

* toc search: add real-world test

* fix test

* add dogfooding tests for toc min/max

* add test for min/max toc frontmatter

* reverse min/max order

* add theme minHeadingLevel + tests

* simpler TOC rendering logic

* simplify TOC implementation (temp, WIP)

* reverse unnatural order for minHeadingLevel/maxHeadingLevel

* add TOC dogfooding tests to all content plugins

* expose toc min/max heading level frontmatter to all 3 content plugins

* refactor blogLayout: accept toc ReactElement directly

* move toc utils to theme-common

* add tests for filterTOC

* create new generic TOCItems component

* useless css file copied

* fix toc highlighting className conflicts

* update doc

* fix types

Co-authored-by: HonkingGoose <34918129+HonkingGoose@users.noreply.github.com>
Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-09-29 11:19:11 +02:00
Sébastien Lorber
f361e89b14
feat: on back navigation, close mobile sidebar (#5462)
* On back, close mobile navbar sidebar

* more reliable code to block history pop events

* android backbutton: just close the drawer without cancellin the backward navigation
2021-09-02 16:03:17 +02:00
Isaac Philip
f9c79cbd58
feat: doc tags (same as blog tags) (#3646)
* [v2] tags to doc, same as tags to blog - [IN PROGRESS]

- Addition of plugin-content-docs

- Addition of DocTagsListPage in `docusaurus-theme-classic`

! Error exists for this commit towards the theme aspect and help required.

Commit towards #3434

* docs: make tags list page work

* temp: disable onBrokenLinks

* theme bootstrap: create DocTagsListPage

* DocTagsPage added and functionality too

- individual doc tag page added to show docs for that specific tag

* Added all Docs Tags Link

* add some shared tag utils

* move tag tests to _dogfooding

* fix type

* fix some tests

* fix blog test

* refactor blog post tags handling

* better yaml tag examples

* better dogfood md files

* refactor and factorize theme tag components

* finish DocTagDocListPage

* Extract DocItemFooter + add inline tag list

* minor fix

* better typings

* fix versions.test.ts tests

* add tests for doc tags

* fix tests

* test toTagDocListProp

* move shared theme code to tagUtils

* Add new theme translation keys

* move common theme code to tagUtils + add tests

* update-code-translations should handle theme-common

* update french translation

* revert add translation

* fix pluralization problem in theme.docs.tagDocListPageTitle

* add theme component configuration options

* add more tags tests

* add documentation for docs tagging

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-08-19 10:31:15 +02:00
Sébastien Lorber
dc4664b489
feat: details/summary theme / MDX component (#5216)
* Details component

* polish arrow animation

* fix text selection bug

* fix some edge cases + polish

* example of overriding baseClassName

* Move Details component to theme-common

* make component work even when JS is disabled or failed to load

* update arrow transform

* Details component: better handling of no-JS fallback mode: avoid delaying arrow navigation when JS (see review)

* prefix css vars with --docusaurus

* improve css arrow styling

* slightly change details/summary design

* better md doc + include quotes and details in doc
2021-07-27 18:45:12 +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
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
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
9916a0b4a4
fix(v2): Fix announcementBar layout shifts (#5040)
* Fix announcementBar layout shift

* useAnnouncementBar should return correct state after hydration

* refactor announcementBar => move utils to theme-common

* restore previous announcementBar

* typo
2021-06-24 11:35:35 +02:00
Alexey Pyltsyn
8bda3b2dbf
fix(v2): ignore hash changes in useChangeRoute hook (#5023)
* fix(v2): ignore hash changes in useChangeRoute hook

* refactor and introduce useLocationChange hook

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-06-22 12:41:58 +02:00
Alexey Pyltsyn
0360364570
fix(v2): do not focus on skip link if page refreshed (#4797)
* fix(v2): do not focus on skip link if page refreshed

* rename ref

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-05-18 15:55:11 +02:00
Sébastien Lorber
01adf25b0f
chore(v2): TypeScript, use isolatedModules (#4790)
* Use isolatedModules

* better solution for useDocs?

* fix blog-only mode

* fix bad useDocs import
2021-05-14 15:36:55 +02:00
Steven Hansel
cd47d8a815
feat(v2): add unique page/wrapper className to each theme pages (#4511)
* chore: add theme classnames for blog pages

* fix: component syntax error in blog pages

* style: fix camelcase issue with theme class names

* chore: add theme classnames for doc page and mdx page

* chore: make wrapper classnames in blog and doc page into constants

* chore: add main wrapper theme class name for layout component

* fix: change wrong theme classnames and improve naming

* chore: add wrapper theme class name for mdx page

* docs: add docs for theme class names

* docs: use raw-loader to import documentation and add some comments

* docs: provide more detail to comment

* chore: rename ThemeClassname.ts to ThemeClassName.ts

Co-authored-by: Lisa Chandra <52909743+lisa761@users.noreply.github.com>
Co-authored-by: Javid <singularity.javid@gmail.com>
2021-04-15 18:36:40 +02:00
duanwilliam
1abadbaeca
fix(v2): fix code block title parsing, support multiple metastring attributes (#4541)
* feat: lazy match classic theme code block title

* feat: allow single quotes for classic theme code block title

* refactor(v2): extract parseCodeBlockTitle function

extract `parseCodeBlockTitle` function to add tests for title parsing

* test(v2): add tests for parseCodeBlockTitle

* move code block title parser to theme-common

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-04-14 10:24:52 +02:00
John Knox
2c57f44bd6
fix(v2): fail-safe usage of browser storage (localStorage/sessionStorage) when access is denied (#4501)
* fix: Fix unsafe uses of localStorage

Puts all uses of localStorage behind an abstraction which doesn't fail
when localStorage isn't available.

* cleanup fail-safe browser storage usage

Co-authored-by: slorber <lorber.sebastien@gmail.com>
2021-04-13 12:38:12 +02:00
Sébastien Lorber
364d4dbf01
fix(v2): fix bad theme pluralization rules for some labels (#4304)
* Pluralization test!

* Simplify usePluralForm usage with | plural message separator

* fix interpolate bug with falsy values like 0

* fix interpolate bug with falsy values like 0

* Order plural forms + allow to not provide the last plural forms if they are not used

* fix typo

* revert test!

* plurals and typo of the SearchPage

* update some labels

* improve the update-code-translations cli + update translations

* pluralize blog reading time label

* ensure base.json contains message descriptions: helps the user to provide the translations

* remove russian production locale
2021-03-03 17:05:21 +01:00
Sébastien Lorber
869ebe7b53
fix(v2): fix/enhance minor i18n issues reported (#4092)
* fix comment

* allow to pass custom classname in navbar items

* Add IconLanguage comp to dropdown

* do not trim htmlLang

* Add initial hreflang SEO support

* doc hreflang
2021-01-22 21:26:42 +01:00
Bartosz Kaszubowski
21572ccd37
feat(v2): extract site title formatter to theme-common util (#3838) 2020-11-30 15:41:09 +01:00
Sébastien Lorber
3166fab307
feat(v2): core v2 i18n support + Docusaurus site Crowdin integration (#3325)
* docs i18n initial poc

* docs i18n initial poc

* docs i18n initial poc

* docs i18n initial poc

* crowdin-v2 attempt

* fix source

* use crowdin env variable

* try to install crowdin on netlify

* try to install crowdin on netlify

* try to use crowdin jar directly

* try to curl the crowdin jar

* add java version cmd

* try to run crowdin jar in netlify

* fix translatedDocsDirPath

* fix loadContext issue due to site baseUrl not being modified in generted config file

* real validateLocalesFile

* add locale option to deploy command

* better LocalizationFile type

* create util getPluginI18nPath

* better core localization context loading code

* More explicit VersionMetadata type for localized docs folders

* Ability to translate blog posts with Crowdin!

* blog: refactor markdown loader + report broken links + try to get linkify working better

* upgrade crowdin config to upload all docs folder files except source code related files

* try to support translated pages

* make markdown pages translation work

* add write-translations cli command template

* fix site not  reloaded with correct options

* refactor a bit the read/write of @generated/i18n.json file

* Add <Translate> + translate() API + use it on the docusaurus homepage

* watch locale translation dir

* early POC of adding babel parsing for translation extraction

* fs.stat => pathExists

* add install:fast script

* TSC: noUnusedLocals false as it's already checked  by eslint

* POC of extracting translations from source code

* minor typo

* fix extracted key to code

* initial docs extracted translations

* stable plugin translations POC

* add crowdin commands

* quickfix for i18n deployment

* POC  of themeConfig translation

* add ability to have localized site without path prefix

* sidebar typo

* refactor translation system to output multiple translation files

* translate properly  the docs plugin

* improve theme classic translation

* rework translation extractor to handle new Chrome I18n JSON format (include id/description)

* writeTranslations: allow to pass locales cli arg

* fix ThemeConfig TS issues

* fix localizePath errors

* temporary add write-translations to netlify deploy preview

* complete example of french translated folder

* update fr folder

* remove all translations from repo

* minor translation  refactors

* fix all docs-related tests

* fix blog feed tests

* fix last blog tests

* refactor i18n context a bit, extract codeTranslations in an extra generated file

* improve @generated/i18n type

* fix some i18n todos

* minor refactor

* fix logo typing issue after merge

* move i18n.json to siteConfig instead

* try to fix windows CI build

* fix config test

* attempt to fix windows non-posix path

* increase v1 minify css jest timeout due to flaky test

* proper support for localizePath on windows

* remove non-functional install:fast

* docs, fix docsDirPathLocalized

* fix Docs i18n / md linkify issues

* ensure theme-classic swizzling will use "nextjs" sources (transpiled less aggressively, to make them human readable)

* fix some snapshots

* improve themeConfig translation code

* refactor a bit getPluginI18nPath

* readTranslationFileContent => ensure files are valid, fail fast

* fix versions tests

* add extractSourceCodeAstTranslations comments/resource links

* ignore eslint: packages/docusaurus-theme-classic/lib-next/

* fix windows CI with cross-env

* crowdin ignore .DS_Store

* improve writeTranslations + add exhaustive tests for translations.ts

* remove typo

* Wire currentLocale to algolia search

* improve i18n locale error

* Add tests for translationsExtractor.ts

* better code translation extraction regarding statically evaluable code

* fix typo

* fix typo

* improve theme-classic transpilation

* refactor  +  add i18n tests

* typo

* test new utils

* add missing snapshots

* fix snapshot

* blog onBrokenMarkdownLink

* add sidebars tests

* theme-classic index should now use ES modules

* tests for theme-classic translations

* useless comment

* add more translation tests

* simplify/cleanup writeTranslations

* try to fix Netlify fr deployment

* blog: test translated md is used during feed generation

* blog: better i18n tests regarding editUrl + md translation application

* more i18n tests for docs plugin

* more i18n tests for docs plugin

* Add tests for pages i18n

* polish docusaurus build i18n logs
2020-11-26 12:16:46 +01:00
Sébastien Lorber
abcd8cefd6
feat(v2): @docusaurus/theme-common (#3775)
* create base @docusaurus/theme-common package + fix Webpack client export aliases issue shadowing other theme-common package

* Move theme-classic/src/utils code to new @docusaurus/theme-common package

* add prettierignore

* fix bad test location for getDocusaurusAliases()
2020-11-18 16:00:51 +01:00