Skip to content

Commit a21ca5b

Browse files
authored
Merge pull request #6 from summerscar/master
✨feat(视频组件): 增加懒加载 文档嵌入jsx
2 parents 3c6ddf8 + d8fd470 commit a21ca5b

File tree

3 files changed

+40
-24
lines changed

3 files changed

+40
-24
lines changed

blog/about-codelab-club.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ CodeLab的第一笔捐赠来自罗云先生,这笔捐赠让我们得以全力以
3737

3838
在很多人看来,我们可能有些不切实际,说得好听一点,有些理想主义。我很开心周围能有这样一群"不切实际"的朋友,我们选择做那些我们认为是对的事,而不是那些操作容易见效快的事。感谢早期推动着CodeLab的所有人。我将这份名单列出,名字不分先后。哈哈,我们做到了真正意义上的`不分先后`,用的便是`编程`,我写了几行代码来随机排列人名,你每次刷新页面,排序都将不同 :)
3939

40-
40+
<p>{['aaa', 'bbb', 'ccc', 'ddd', 'eee'].sort(() => Math.random() - 0.5).join('、')}</p>
4141

4242
希望这份名单不断加长,也希望参与其中的每个人,热爱贡献、分享与创造的过程。
4343

@@ -60,9 +60,9 @@ CodeLab的第一笔捐赠来自罗云先生,这笔捐赠让我们得以全力以
6060
{/*
6161
CodeLab将探索多种club模式,构建编程教育的基础设施,科普。我们力图做到中立、客观,不蹭热点不站队:)*/}
6262

63-
线下方面,CodeLab将在全国主要城市,利用周末时间,组织志愿者、借用场地,开展编程活动;
64-
线上方面,CodeLab将构建先进的编程平台,在积木化编程里加入开源硬件、物联网和人工智能;
65-
同时我们将构建活跃的用户社区,鼓励志愿者、学习者、创造者参与其中;
63+
线下方面,CodeLab将在全国主要城市,利用周末时间,组织志愿者、借用场地,开展编程活动;
64+
线上方面,CodeLab将构建先进的编程平台,在积木化编程里加入开源硬件、物联网和人工智能;
65+
同时我们将构建活跃的用户社区,鼓励志愿者、学习者、创造者参与其中;
6666
我们也乐于与其他公益组织展开合作,让编程与更广泛的社会活动结合。
6767

6868
我们目前的办公室在广州,我们会先在广州探索各种club的模式,一旦运转流畅,我们就在全国各地去开展活动。
@@ -126,7 +126,7 @@ NASA(美国国家航空航天局)做了一个开源项目: [JPL Open Source Rove
126126

127127

128128
# 如何参与
129-
{/* > 那些疯狂到以为自己能够改变世界的人, 才能真正改变世界。 -- 史蒂夫·乔布斯*/}
129+
{/* > 那些疯狂到以为自己能够改变世界的人, 才能真正改变世界。 -- 史蒂夫·乔布斯*/}
130130

131131
有很多种方式参与CodeLab。
132132

docusaurus.config.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,26 @@ module.exports = {
3232
position: 'left',
3333
},
3434
{
35-
35+
3636
href: 'https://adapter.codelab.club/',
3737
/*
38-
to: 'docs/adapter',
38+
to: 'docs/adapter',
3939
activeBasePath:'docs/adapter',
4040
*/
4141
label: '文档',
4242
position: 'left',
4343
},
44-
{
45-
to: 'blog',
44+
{
45+
to: 'blog',
4646
/*
4747
activeBasePath:'blog',
4848
*/
49-
label: '博客',
49+
label: '博客',
5050
position: 'left'
5151
},
52-
{
53-
to: '/blog/2018/11/08/about-codelab-club',
54-
label:'关于我们',
52+
{
53+
to: '/blog/2018/11/08/about-codelab-club',
54+
label:'关于我们',
5555
position:'left'
5656
},
5757
{
@@ -139,14 +139,15 @@ module.exports = {
139139
],
140140
],
141141
scripts: [
142+
'https://cdn.jsdelivr.net/npm/lozad/dist/lozad.min.js',
142143
'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js',
143144
'https://cdnjs.cloudflare.com/ajax/libs/lettering.js/0.6.1/jquery.lettering.min.js',
144145
'https://cdn.jsdelivr.net/npm/video.js/dist/video.min.js',
145146
'/script/settheme.js',
146147
],
147148
stylesheets: [
148149
// https://unpkg.com/video.js/dist/video-js.min.css
149-
//
150+
//
150151
//'https://unpkg.com/video.js/dist/video-js.min.css',
151152
'https://cdn.jsdelivr.net/npm/video.js/dist/video-js.min.css',
152153
'https://cdn.jsdelivr.net/npm/@videojs/themes@1/dist/fantasy/index.css'

src/pages/projects/index.js

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ export const VideoRow = function ({title, videos, ...props}) {
7070
}
7171
}
7272

73+
useLayoutEffect(() => {
74+
const observer = window.lozad('.lozad', {
75+
load: (el) => {
76+
el.src = el.getAttribute('data-src');
77+
// Custom implementation to load an element
78+
// e.g. el.src = el.getAttribute('data-src');
79+
},
80+
loaded: (el) => {
81+
el.removeAttribute('poster')
82+
el.classList.add('loaded');
83+
}
84+
}); // lazy loads elements with default selector as '.lozad'
85+
observer.observe();
86+
})
87+
7388
return (
7489
<div className="margin-top--log margin-bottom--log">
7590
{
@@ -82,22 +97,22 @@ export const VideoRow = function ({title, videos, ...props}) {
8297
<div className={clsx('col col--4')} key={index}>
8398
<div>
8499
<video
85-
src={video.src}
86-
/*poster="/static/img/Play.PNG"*/
87-
className={clsx(styles.video)}
88-
onClick={() => openModal(video)}>
89-
<source src={video.src} type="video/mp4"/>
90-
</video>
100+
type="video/mp4"
101+
poster="/static/img/Play.PNG"
102+
data-src={video.src}
103+
className={clsx(styles.video, 'lozad')}
104+
onClick={() => openModal(video)}
105+
/>
91106
<p className={clsx('text--center', isDarkTheme && styles.headerFontTitle)}>{video.title}</p>
92107
</div>
93-
108+
94109
{/*
95110
< div className={clsx(styles.videoName)}>
96111
<p className={clsx('text--left', isDarkTheme && styles.headerFontNum)}>by CodeLab</p>
97112
<p className={clsx('text--center', isDarkTheme && styles.headerFontTitle)}>{video.title}</p>
98113
</div>
99114
*/}
100-
115+
101116
</div>
102117
))
103118
}
@@ -143,13 +158,13 @@ function Projects() {
143158
{/*
144159
<span className={clsx(styles.fancytitle1, 'stack')}>Let's &nbsp;</span>
145160
<span className={clsx(styles.fancytitle1, 'stack')}>&nbsp; Play!</span>
146-
161+
147162
<h1 className={clsx(styles.fancytitle2, 'stack')}>无惧简陋与粗糙</h1>
148163
*/}
149164
<h1 className={clsx(styles.fancytitle2, 'stack')}>在玩乐中创作与表达</h1>
150165
</div>
151166
<main className={clsx("container")}>
152-
<VideoRow title="" videos={videos['来自CodeLab']}/>
167+
<VideoRow title="" videos={videos['来自CodeLab']}/>
153168
<VideoRow title="" videos={videos['来自社区']}/>
154169
</main>
155170
</div>

0 commit comments

Comments
 (0)