aboutsummaryrefslogtreecommitdiff
path: root/src/theme/Admonition/Layout/index.js
diff options
context:
space:
mode:
author安竹洋平 <61961825+yasutakeyohei@users.noreply.github.com>2024-01-27 01:22:54 +0900
committer安竹洋平 <61961825+yasutakeyohei@users.noreply.github.com>2024-01-27 01:22:54 +0900
commit65350c0839bf5cbbdd128d645018a0f5f07ac14f (patch)
tree11fbb7ef222526e9e3095ba3bc8652061eb5b168 /src/theme/Admonition/Layout/index.js
parentcc128057af3c0805f0c5d26e6a915690d37e2187 (diff)
initial commit
Diffstat (limited to 'src/theme/Admonition/Layout/index.js')
-rw-r--r--src/theme/Admonition/Layout/index.js28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/theme/Admonition/Layout/index.js b/src/theme/Admonition/Layout/index.js
index 14a987b0..8d95599e 100644
--- a/src/theme/Admonition/Layout/index.js
+++ b/src/theme/Admonition/Layout/index.js
@@ -1,13 +1,7 @@
-/**
- * Copyright (c) Facebook, Inc. and its affiliates.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- */
import React from 'react';
import clsx from 'clsx';
-import { ThemeClassNames } from '@docusaurus/theme-common';
-import admonitionStyles from '@docusaurus/theme-classic/lib/theme/Admonition/Layout/styles.module.css';
+import {ThemeClassNames} from '@docusaurus/theme-common';
+import styles from './styles.module.css';
import headingStyles from '@docusaurus/theme-classic/lib/theme/Heading/styles.module.css';
function AdmonitionContainer({type, className, children}) {
@@ -16,33 +10,33 @@ function AdmonitionContainer({type, className, children}) {
className={clsx(
ThemeClassNames.common.admonition,
ThemeClassNames.common.admonitionType(type),
- admonitionStyles.admonition,
+ styles.admonition,
className,
- )}
- >
+ )}>
{children}
</div>
);
}
-function AdmonitionHeading({icon, id, title}) {
+function AdmonitionHeading({icon, title, id}) {
let depth = 0;
- let trimmedTitle = "";
+ let trimmedTitle = title;
// titleにHTML等が含まれている場合は文字列ではなく配列になる
if(typeof title === "string") {
// 文字列冒頭の#の数を数える(
depth = title.match ? (title.toString().match(/^#+/) || [''])[0].length : 0;
// #を省いたタイトルを得る
- trimmedTitle = depth > 0 ? title.replace(/^#+/, '').trim() : title;
+ trimmedTitle = depth > 0 ? title.replace(/^#+/, '').trim() : title;
} else if (typeof title[0] === "string") {
depth = title[0].match ? (title[0].match(/^#+/) || [''])[0].length : 0;
trimmedTitle = depth > 0 ? [title[0].replace(/^#+/, '').trim(), ...title.slice(1)] : title;
}
+
// スクロール位置調整のcss
const classNames = clsx("anchor", "title", headingStyles.anchorWithStickyNavbar);
// depthに応じて見出しタグをレンダー
return (
- <div className={admonitionStyles.admonitionHeading}>
- <span className={admonitionStyles.admonitionIcon}>{icon}</span>
+ <div className={styles.admonitionHeading}>
+ <span className={styles.admonitionIcon}>{icon}</span>
{(() => {
if (depth == 3) {
return(
@@ -93,7 +87,7 @@ function AdmonitionHeading({icon, id, title}) {
}
function AdmonitionContent({children}) {
return children ? (
- <div className={admonitionStyles.admonitionContent}>{children}</div>
+ <div className={styles.admonitionContent}>{children}</div>
) : null;
}
export default function AdmonitionLayout(props) {