Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add support for browser-based theme config file (docusaurus.theme.js)#9619

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
OzakIOne wants to merge13 commits intofacebook:main
base:main
Choose a base branch
Loading
fromOzakIOne:ozaki/themeconfig
Draft
Show file tree
Hide file tree
Changes from1 commit
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
PrevPrevious commit
NextNext commit
wip: navbar
  • Loading branch information
@OzakIOne
OzakIOne committedDec 21, 2023
commitfe7916bce33fba6e9cc4c1a9df2b9646d400e79b
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -139,15 +139,14 @@ export function useThemeConfig(): ThemeConfig {
.themeConfig as ThemeConfig;
const newThemeConfig = useDocusaurusContext().themeConfig as ThemeConfig;

console.log('oldThemeConfig', oldThemeConfig);
console.log('newThemeConfig:', newThemeConfig);

// TODO docusaurus-theme-classic/src/options.ts
// assigns default values in oldThemeConfig (navbar, footer...)
const duplicateKeys = Object.keys(oldThemeConfig).filter((key) =>
Object.prototype.hasOwnProperty.call(newThemeConfig, key),
);

if (duplicateKeys.length > 0) {
throw new Error(
console.warn(
`Duplicate keys found in siteConfig.themeConfig and themeConfig: ${duplicateKeys}`,
);
}
Expand Down
111 changes: 0 additions & 111 deletionswebsite/docusaurus.config.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,7 +12,6 @@ import rehypeKatex from 'rehype-katex';
import configTabs from './src/remark/configTabs';

import versions from './versions.json';
import VersionsArchived from './versionsArchived.json';
import {
dogfoodingPluginInstances,
dogfoodingThemeInstances,
Expand All@@ -28,11 +27,6 @@ import type {Options as PageOptions} from '@docusaurus/plugin-content-pages';
import type {Options as IdealImageOptions} from '@docusaurus/plugin-ideal-image';
import type {Options as ClientRedirectsOptions} from '@docusaurus/plugin-client-redirects';

const ArchivedVersionsDropdownItems = Object.entries(VersionsArchived).splice(
0,
5,
);

function isPrerelease(version: string) {
return (
version.includes('alpha') ||
Expand DownExpand Up@@ -474,111 +468,6 @@ export default async function createConfigAsync() {
}
: undefined,
},
navbar: {
hideOnScroll: true,
title: 'Docusaurus',
logo: {
alt: '',
src: 'img/docusaurus.svg',
srcDark: 'img/docusaurus_keytar.svg',
width: 32,
height: 32,
},
items: [
{
type: 'doc',
position: 'left',
docId: 'introduction',
label: 'Docs',
},
{
type: 'docSidebar',
position: 'left',
sidebarId: 'api',
label: 'API',
},
{to: 'blog', label: 'Blog', position: 'left'},
{to: 'showcase', label: 'Showcase', position: 'left'},
{
to: '/community/support',
label: 'Community',
position: 'left',
activeBaseRegex: `/community/`,
},
// This item links to a draft doc: only displayed in dev
{
type: 'doc',
docId: 'index',
label: 'Tests',
docsPluginId: 'docs-tests',
},
isDev && {to: '/__docusaurus/debug', label: 'Debug'},
// Custom item for dogfooding: only displayed in /tests/ routes
{
type: 'custom-dogfood-navbar-item',
content: '😉',
},
// Right
{
type: 'docsVersionDropdown',
position: 'right',
dropdownActiveClassDisabled: true,
dropdownItemsAfter: [
{
type: 'html',
value: '<hr class="dropdown-separator">',
},
{
type: 'html',
className: 'dropdown-archived-versions',
value: '<b>Archived versions</b>',
},
...ArchivedVersionsDropdownItems.map(
([versionName, versionUrl]) => ({
label: versionName,
href: versionUrl,
}),
),
{
href: 'https://v1.docusaurus.io',
label: '1.x.x',
},
{
type: 'html',
value: '<hr class="dropdown-separator">',
},
{
to: '/versions',
label: 'All versions',
},
],
},
{
type: 'localeDropdown',
position: 'right',
dropdownItemsAfter: [
{
type: 'html',
value: '<hr style="margin: 0.3rem 0;">',
},
{
href: 'https://github.com/facebook/docusaurus/issues/3526',
label: 'Help Us Translate',
},
],
},
{
href: 'https://github.com/facebook/docusaurus',
position: 'right',
className: 'header-github-link',
'aria-label': 'GitHub repository',
},
]
// TODO fix type
.filter(Boolean) as NonNullable<
Preset.ThemeConfig['navbar']
>['items'],
},
},
};
}
118 changes: 116 additions & 2 deletionswebsite/docusaurus.theme.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -8,14 +8,24 @@ import type {ReactNode} from 'react';
import React from 'react';
import Link from '@docusaurus/Link';
import Translate from '@docusaurus/Translate';
import VersionsArchived from './versionsArchived.json';
import PrismLight from './src/utils/prismLight';
import PrismDark from './src/utils/prismDark';
import type * as Preset from '@docusaurus/preset-classic';
// TODO remove this eslint ruse
// TODO PrismDark and PrismLight types
// TODO `satisfies Preset.ThemeConfig` `satisfies Config`
// results Expected ';', got 'satisfies'
/* eslint-disable @docusaurus/no-untranslated-text */
const ArchivedVersionsDropdownItems = Object.entries(VersionsArchived).splice(
0,
5,
);
const isDev = process.env.NODE_ENV === 'development';

export default {
announcementBar: {
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

process is not defined for agolia however no error reported for navbar Debug label with isDev

id: 'announcementBar-3', // Increment on change
// content: `🎉️ <b><a target="_blank" href="https://docusaurus.io/blog/releases/3.0">prout v3.0</a> is now out!</b> 🥳️`,
content: function AnnouncementBarContent(): ReactNode {
return (
<b>
Expand DownExpand Up@@ -190,6 +200,110 @@ export default {
src: '/img/meta_opensource_logo_negative.svg',
href: 'https://opensource.fb.com',
},
copyright: `prout © ${new Date().getFullYear()} Meta Platforms, Inc. Built with Docusaurus.`,
copyright: `Copyright © ${new Date().getFullYear()} Meta Platforms, Inc. Built with Docusaurus.`,
},
navbar: {
hideOnScroll: true,
title: 'Docusaurus',
logo: {
alt: '',
src: 'img/docusaurus.svg',
srcDark: 'img/docusaurus_keytar.svg',
width: 32,
height: 32,
},
items: [
{
type: 'doc',
position: 'left',
docId: 'introduction',
label: 'Docs',
},
{
type: 'docSidebar',
position: 'left',
sidebarId: 'api',
label: 'API',
},
{to: 'blog', label: 'Blog', position: 'left'},
{to: 'showcase', label: 'Showcase', position: 'left'},
{
to: '/community/support',
label: 'Community',
position: 'left',
activeBaseRegex: `/community/`,
},
// This item links to a draft doc: only displayed in dev
{
type: 'doc',
docId: 'index',
label: 'Tests',
docsPluginId: 'docs-tests',
},
isDev && {to: '/__docusaurus/debug', label: 'Debug'},
// Custom item for dogfooding: only displayed in /tests/ routes
{
type: 'custom-dogfood-navbar-item',
content: '😉',
},
// Right
{
type: 'docsVersionDropdown',
position: 'right',
dropdownActiveClassDisabled: true,
dropdownItemsAfter: [
{
type: 'html',
value: '<hr class="dropdown-separator">',
},
{
type: 'html',
className: 'dropdown-archived-versions',
value: '<b>Archived versions</b>',
},
...ArchivedVersionsDropdownItems.map(([versionName, versionUrl]) => ({
label: versionName,
href: versionUrl,
})),
{
href: 'https://v1.docusaurus.io',
label: '1.x.x',
},
{
type: 'html',
value: '<hr class="dropdown-separator">',
},
{
to: '/versions',
label: 'All versions',
},
],
dropdownItemsBefore: [],
},
{
type: 'localeDropdown',
position: 'right',
dropdownItemsAfter: [
{
type: 'html',
value: '<hr style="margin: 0.3rem 0;">',
},
{
href: 'https://github.com/facebook/docusaurus/issues/3526',
label: 'Help Us Translate',
},
],
dropdownItemsBefore: [],
},
{
href: 'https://github.com/facebook/docusaurus',
position: 'right',
className: 'header-github-link',
'aria-label': 'GitHub repository',
},
]
// TODO fix type
.filter(Boolean) as NonNullable<Preset.ThemeConfig['navbar']>['items'],
},
};
// satisfies Preset.ThemeConfig;

[8]ページ先頭

©2009-2025 Movatter.jp