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

[docs] ❗️BREAKING ❗️ various theme config options was renamed #721

Merged
merged 9 commits into from Aug 21, 2022

Conversation

dimaMachina
Copy link
Collaborator

@dimaMachina dimaMachina commented Aug 20, 2022

fixes #676 #669

also, add new option toc.component to fix #564

and fixes project.link behaviour #383

export interface DocsThemeConfig {
banner: {
key: string
text: ReactNode | FC
}
bodyExtraContent: ReactNode | FC
components: Record<string, FC>
darkMode: boolean
direction: 'ltr' | 'rtl'
docsRepositoryBase: string
editLink: ReactNode | FC
feedback: {
labels: string
link: ReactNode | FC
}
font: boolean
footer: {
component: ReactNode | FC<{ menu: boolean }>
text: ReactNode | FC
}
gitTimestamp: ReactNode | FC<{ timestamp: Date }>
github: string
head: () => ReactElement
i18n: { direction?: string; locale: string; text: string }[]
logo: ReactNode | FC
navigation: {
next: boolean
prev: boolean
}
nextThemes: Pick<
ThemeProviderProps,
'defaultTheme' | 'storageKey' | 'forcedTheme'
>
notFound: {
labels: string
link: ReactNode | FC
}
project: {
icon: ReactNode | FC
link: string
}
projectChat: {
icon: ReactNode | FC
link: string
}
search: {
component: ReactNode | FC<{ directories: Item[] }>
emptyResult: ReactNode | FC
// Can't be React component
placeholder: string | (() => string)
}
serverSideError: {
labels: string
link: ReactNode | FC
}
sidebar: {
defaultMenuCollapsed: boolean
subtitle: ReactNode | FC<{ title: string }>
}
// Can't be React component, otherwise will get Warning: A title element received an array with more than 1 element as children.
titleSuffix: string | (() => string)
toc: {
extraContent: ReactNode | FC
float: boolean
title: ReactNode | FC
}
unstable_faviconGlyph: string
}

@shuding it was hard to implement without too monkey-business code for some options like

 search: boolean | FC | ReactNode | {
   placeholder?: string | (() => string)
   emptyResult?: ReactNode | FC
 }

So I made the following

 search: { 
     component: ReactNode | FC<{ directories: Item[] }> 
     emptyResult: ReactNode | FC  // will be ignored if component was specified
     placeholder: string | (() => string)  // will be ignored if component was specified
   } 

or more complex usage

  toc: {
    component: ReactNode | FC<TOCProps>
    extraContent: ReactNode | FC // will be ignored if component was specified
    float: boolean // ❗️ headings will be passed in `toc.component` as props based on `headings: config.toc.float ? headings : []` condition
    title: ReactNode | FC // will be ignored if component was specified
  }

@vercel
Copy link

vercel bot commented Aug 20, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
nextra-theme-docs-dev ✅ Ready (Inspect) Visit Preview Aug 20, 2022 at 4:27PM (UTC)
1 Ignored Deployment
Name Status Preview Updated
nextra ⬜️ Ignored (Inspect) Aug 20, 2022 at 4:27PM (UTC)

@changeset-bot
Copy link

changeset-bot bot commented Aug 20, 2022

🦋 Changeset detected

Latest commit: 323ada9

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Owner

@shuding shuding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you this is so much cleaner!

@shuding shuding merged commit b07e153 into fix-edit-on-github Aug 21, 2022
@shuding shuding deleted the new-config-options branch August 21, 2022 01:25
dimaMachina added a commit that referenced this pull request Aug 21, 2022
)

* fix edit on github button for cases when filename named as `index`

* fix typecheck

* [docs] ❗️BREAKING ❗️ various theme config options was renamed (#721)

* rename `meta.json` to `_meta.json` (#722)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component #564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter` (#723)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component #564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter`

* fix swr build

* small fix

* clicking on folder should navigate to first children if `index` page doesn't exist (#724)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component #564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter`

* fix swr build

* small fix

* clicking on folder should navigate to first children if `index` page doesn't exist

* apply review changes

* rebase fixes
shuding pushed a commit that referenced this pull request Aug 27, 2022
…719)

* split css to `hamburger`/`scrollbar`/`typesetting-article` css files

* fix edit on github button for cases when filename named as `index` (#720)

* fix edit on github button for cases when filename named as `index`

* fix typecheck

* [docs] ❗️BREAKING ❗️ various theme config options was renamed (#721)

* rename `meta.json` to `_meta.json` (#722)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component #564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter` (#723)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component #564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter`

* fix swr build

* small fix

* clicking on folder should navigate to first children if `index` page doesn't exist (#724)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component #564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter`

* fix swr build

* small fix

* clicking on folder should navigate to first children if `index` page doesn't exist

* apply review changes

* rebase fixes

* adjust active breadcrumb color (#725)

* move `withLayout` logic directly in nextra loader (#726)

* adjust active breadcrumb color

* move `withLayout` logic directly in nextra loader

* better loader types, add `MetaJsonFile`, `MdxFile`, `Folder` types, add tests for `next/context` (#731)

* fix ci

* fix callout shrinking from children content (#746)
dimaMachina added a commit that referenced this pull request Aug 28, 2022
* refactor toc, fix toc's styles on rtl, use `ref.current` instead `document.getElementsByClassName`

* group both `mask-image`

* fix search overlay styles on mobile

* fix

* split css to `hamburger`/`scrollbar`/`typesetting-article` css files (#719)

* split css to `hamburger`/`scrollbar`/`typesetting-article` css files

* fix edit on github button for cases when filename named as `index` (#720)

* fix edit on github button for cases when filename named as `index`

* fix typecheck

* [docs] ❗️BREAKING ❗️ various theme config options was renamed (#721)

* rename `meta.json` to `_meta.json` (#722)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component #564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter` (#723)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component #564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter`

* fix swr build

* small fix

* clicking on folder should navigate to first children if `index` page doesn't exist (#724)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component #564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter`

* fix swr build

* small fix

* clicking on folder should navigate to first children if `index` page doesn't exist

* apply review changes

* rebase fixes

* adjust active breadcrumb color (#725)

* move `withLayout` logic directly in nextra loader (#726)

* adjust active breadcrumb color

* move `withLayout` logic directly in nextra loader

* better loader types, add `MetaJsonFile`, `MdxFile`, `Folder` types, add tests for `next/context` (#731)

* fix ci

* fix callout shrinking from children content (#746)

* Version Packages (beta) (#728)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix typecheck

* fix typecheck

* simplify

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@Filsommer
Copy link

Regarding this change:
placeholder: string | (() => string)
How can we change that placeholder depending on the locale now?

tatukoivisto pushed a commit to tatukoivisto/nextra that referenced this pull request Aug 20, 2023
* refactor toc, fix toc's styles on rtl, use `ref.current` instead `document.getElementsByClassName`

* group both `mask-image`

* fix search overlay styles on mobile

* fix

* split css to `hamburger`/`scrollbar`/`typesetting-article` css files (shuding#719)

* split css to `hamburger`/`scrollbar`/`typesetting-article` css files

* fix edit on github button for cases when filename named as `index` (shuding#720)

* fix edit on github button for cases when filename named as `index`

* fix typecheck

* [docs] ❗️BREAKING ❗️ various theme config options was renamed (shuding#721)

* rename `meta.json` to `_meta.json` (shuding#722)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component shuding#564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter` (shuding#723)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component shuding#564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter`

* fix swr build

* small fix

* clicking on folder should navigate to first children if `index` page doesn't exist (shuding#724)

* BREAKING! various theme config options was renamed

* add new options `toc.component` to override toc component shuding#564

* rename editLink to editLinkText

* add helpful console warnings

* Update packages/nextra-theme-docs/src/contexts/config.tsx

* Update packages/nextra-theme-docs/src/components/footer.tsx

* fix project.link behaviour

* small fix

* fix

* rename `meta.json` to `_meta.json`

* update snapshots

* rename `PageOpts.meta` to `PageOpts.frontMatter`

* fix swr build

* small fix

* clicking on folder should navigate to first children if `index` page doesn't exist

* apply review changes

* rebase fixes

* adjust active breadcrumb color (shuding#725)

* move `withLayout` logic directly in nextra loader (shuding#726)

* adjust active breadcrumb color

* move `withLayout` logic directly in nextra loader

* better loader types, add `MetaJsonFile`, `MdxFile`, `Folder` types, add tests for `next/context` (shuding#731)

* fix ci

* fix callout shrinking from children content (shuding#746)

* Version Packages (beta) (shuding#728)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

* fix typecheck

* fix typecheck

* simplify

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants