Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Mar 18, 2024
2 parents 5ac8b9d + f4bc1e4 commit 49c66c8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
1 change: 1 addition & 0 deletions public/dplayer.htm
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
// { name: 'SD', url: 'https://example.com/your-video-sd.mp4', type: 'normal' }
// ],
},
autoplay: false, // 设置为手动点击播放
// 视频封面图片
poster: 'https://example.com/your-video-poster.jpg',
});
Expand Down
1 change: 1 addition & 0 deletions themes/movie/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const CONFIG = {

MOVIE_ARTICLE_RECOMMEND: true, // 推荐关联内容在文章底部
MOVIE_VIDEO_COMBINE: true, // 聚合视频,开启后一篇文章内的多个含caption的视频会被合并到文章开头,并展示分集按钮
MOVIE_VIDEO_COMBINE_SHOW_PAGE_FORCE: false, // 即使只有一集也显示集数切换按钮

MOVIE_POST_LIST_COVER: true // 列表显示文章封面
}
Expand Down
34 changes: 19 additions & 15 deletions themes/movie/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const LayoutBase = props => {
'relative mx-auto justify-center md:flex items-start py-8 px-2'
}>
{/* 内容 */}
<div className={`w-full ${fullWidth ? '' : ''} xl:px-32 lg:px-4`}>
<div className={`w-full ${fullWidth ? '' : ''} px-4`}>
<Transition
show={!onLoading}
appear={true}
Expand Down Expand Up @@ -125,10 +125,10 @@ const LayoutIndex = props => {
*/
const LayoutPostList = props => {
return (
<>
<div className='max-w-[90rem] mx-auto'>
<SlotBar {...props} />
{siteConfig('POST_LIST_STYLE') === 'page' ? <BlogListPage {...props} /> : <BlogListScroll {...props} />}
</>
</div>
)
}

Expand All @@ -155,22 +155,21 @@ const LayoutSlug = props => {
const exists = document.querySelectorAll('.video-wrapper')
if (exists && exists.length > 0) return

// 创建一个新的容器元素
// 创建视频区块容器元素
const videoWrapper = document.createElement('div')
videoWrapper.className = 'video-wrapper p-2 bg-gray-100 dark:bg-hexo-black-gray max-w-4xl mx-auto'
videoWrapper.className = 'video-wrapper py-1 px-3 bg-gray-100 dark:bg-white dark:text-black mx-auto'

// 创建一个新的容器元素
// 创建走马灯封装容器元素
const carouselWrapper = document.createElement('div')
carouselWrapper.classList.add('notion-carousel-wrapper')

// 创建一个用于保存 figcaption 文本内容的数组
// 创建分集按钮figcaption文本的数组
const figCaptionValues = []

// 遍历所有 .notion-asset-wrapper 元素
assetWrappers.forEach((wrapper, index) => {
// 检查 .notion-asset-wrapper 元素是否有子元素 figcaption
const figCaption = wrapper.querySelector('figcaption')
if (!figCaption) return // 如果没有子元素 figcaption,则不处理该元素

// 检查 .notion-asset-wrapper 元素是否有 notion-asset-wrapper-video 或 notion-asset-wrapper-embed 类
if (
Expand All @@ -179,8 +178,10 @@ const LayoutSlug = props => {
)
return

if (!figCaption) return // 如果没有子元素 figcaption,则不处理该元素

// 获取 figcaption 的文本内容并添加到数组中
const figCaptionValue = figCaption.textContent.trim()
const figCaptionValue = figCaption ? figCaption?.textContent?.trim() : `P-${index}`
figCaptionValues.push(figCaptionValue)

// 创建一个新的 div 元素用于包裹当前的 .notion-asset-wrapper 元素
Expand Down Expand Up @@ -223,18 +224,21 @@ const LayoutSlug = props => {
figCaptionWrapper.appendChild(div)
})

// 条件是带有caption的视频数量大于1个,否则不处理
if (figCaptionValues.length > 1) {
// 将包含 figcaption 值的容器元素添加到 notion-article 的第一个子元素插入
if (carouselWrapper.children.length > 0) {
// 将包含 figcaption 值的容器元素添加到 notion-article 的第一个子元素插入
videoWrapper.appendChild(carouselWrapper)
videoWrapper.appendChild(figCaptionWrapper)
// 显示分集按钮 大于1集才显示 ;或者用户 要求强制显示
if (figCaptionWrapper.children.length > 1 || siteConfig('MOVIE_VIDEO_COMBINE_SHOW_PAGE_FORCE', false, CONFIG)) {
videoWrapper.appendChild(figCaptionWrapper)
}
// 放入页面
notionArticle.insertBefore(videoWrapper, notionArticle.firstChild)
}
}

setTimeout(() => {
combineVideo()
}, 100)
}, 2000)

// 404
if (!post) {
Expand Down Expand Up @@ -266,7 +270,7 @@ const LayoutSlug = props => {
return (
<>
{!lock ? (
<div id='article-wrapper' className='px-2 max-w-5xl mx-auto'>
<div id='article-wrapper' className='px-2 max-w-5xl 2xl:max-w-[70%] mx-auto'>
{/* 标题 */}
<ArticleInfo post={post} />
{/* 页面元素 */}
Expand Down
5 changes: 5 additions & 0 deletions themes/movie/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ const Style = () => {
.notion-carousel-route div:hover {
text-decoration: underline;
}
.notion-carousel div {
height: auto !important;
aspect-ratio: 2/1 !important;
}
`}</style>
)
}
Expand Down
4 changes: 2 additions & 2 deletions themes/simple/components/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default function NavBar(props) {

const onKeyUp = e => {
if (e.keyCode === 13) {
const search = document.getElementById('theme-simple-search').value
const search = document.getElementById('simple-search').value
if (search) {
router.push({ pathname: '/search/' + search })
}
Expand All @@ -43,7 +43,7 @@ export default function NavBar(props) {
{showSearchInput && (
<input
autoFocus
id="theme-simple-search"
id="simple-search"
onKeyUp={onKeyUp}
className="float-left w-full outline-none h-full px-4"
aria-label="Submit search"
Expand Down

0 comments on commit 49c66c8

Please sign in to comment.