-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
170 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use client"; | ||
|
||
import { ComponentPropsWithoutRef, useEffect } from "react"; | ||
import * as tocbot from "tocbot"; | ||
|
||
import useNoColonId from "@/hooks/useNoColonId"; | ||
|
||
interface TocProps extends ComponentPropsWithoutRef<"div"> { | ||
contentSelector: string; | ||
} | ||
|
||
const Toc = ({ contentSelector, ...props }: TocProps) => { | ||
const id = useNoColonId(); | ||
useEffect(() => { | ||
// Tocbotの初期化 | ||
tocbot.init({ | ||
tocSelector: `#${id}`, // 目次の表示部分 | ||
contentSelector: contentSelector, // 目次を生成する対象 | ||
headingSelector: "h2, h3", // 目次に表示する見出しのタグ | ||
}); | ||
|
||
// コンポーネントがアンマウントされたときにTocbotを破棄 | ||
return () => tocbot.destroy(); | ||
}, []); | ||
|
||
return <div id={id} {...props}></div>; | ||
}; | ||
|
||
export default Toc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
"use client"; | ||
import { Tweet as TweetWidget } from "react-twitter-widgets"; | ||
export default function Tweet({ id }: { id: string }) { | ||
return <TweetWidget tweetId={id} />; | ||
import { ComponentPropsWithoutRef } from "react"; | ||
import { Tweet as TweetWidget, TweetProps as LibTweetProps } from "react-twitter-widgets"; | ||
|
||
export type TweetProps = ComponentPropsWithoutRef<"div"> & LibTweetProps; | ||
|
||
export default function Tweet({ tweetId, options, onLoad, renderError, ...props }: TweetProps) { | ||
return ( | ||
<div {...props}> | ||
<TweetWidget tweetId={tweetId} options={options} onLoad={onLoad} renderError={renderError} />; | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { atom, useAtom } from "jotai"; | ||
|
||
const drawerAtom = atom(false); | ||
|
||
const useDrawerAtom = () => useAtom(drawerAtom); | ||
export default useDrawerAtom; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { useId } from "react"; | ||
|
||
const useNoColonId = () => { | ||
const id = useId(); | ||
// 先頭と末尾のコロンを削除 | ||
return id.slice(1, -1); | ||
}; | ||
|
||
export default useNoColonId; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { ComponentPropsWithoutRef, ElementType } from "react"; | ||
|
||
export type WithoutClassName<T> = Omit<T, "className">; | ||
export type ComponentPropsWithoutRefAndClassName<T extends ElementType> = WithoutClassName<ComponentPropsWithoutRef<T>>; |