|
|
|
@ -1,7 +1,6 @@
|
|
|
|
|
import React, { useEffect, useState } from 'react';
|
|
|
|
|
import DocSidebarItem from '@theme-original/DocSidebarItem';
|
|
|
|
|
import styles from './styles.module.css';
|
|
|
|
|
import Comment from '@site/src/components/Comment';
|
|
|
|
|
|
|
|
|
|
export default function DocSidebarItemWrapper(props) {
|
|
|
|
|
const { item } = props;
|
|
|
|
@ -33,7 +32,34 @@ export default function DocSidebarItemWrapper(props) {
|
|
|
|
|
<div className={styles.menuLinkWrapper}>
|
|
|
|
|
<DocSidebarItem {...props} />
|
|
|
|
|
<div className={styles.actionButtons}>
|
|
|
|
|
<Comment docId={item.docId} />
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
const bookmarks = JSON.parse(localStorage.getItem('docBookmarks') || '{}');
|
|
|
|
|
const newState = !isBookmarked;
|
|
|
|
|
bookmarks[item.docId] = newState;
|
|
|
|
|
localStorage.setItem('docBookmarks', JSON.stringify(bookmarks));
|
|
|
|
|
setIsBookmarked(newState);
|
|
|
|
|
window.dispatchEvent(new CustomEvent('bookmarkChanged', {
|
|
|
|
|
detail: { docId: item.docId, isBookmarked: newState }
|
|
|
|
|
}));
|
|
|
|
|
}}
|
|
|
|
|
className={`${styles.bookmarkButton} ${isBookmarked ? styles.bookmarked : ''}`}
|
|
|
|
|
aria-label={isBookmarked ? '取消标记' : '添加标记'}
|
|
|
|
|
type="button"
|
|
|
|
|
>
|
|
|
|
|
<svg
|
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
|
width="16"
|
|
|
|
|
height="16"
|
|
|
|
|
stroke="currentColor"
|
|
|
|
|
strokeWidth="2"
|
|
|
|
|
fill={isBookmarked ? 'currentColor' : 'none'}
|
|
|
|
|
strokeLinecap="round"
|
|
|
|
|
strokeLinejoin="round"
|
|
|
|
|
>
|
|
|
|
|
<path d="M19 21l-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z" />
|
|
|
|
|
</svg>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</li>
|
|
|
|
|