-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
585 lines (382 loc) · 34.8 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.4.0">
<link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
<link rel="mask-icon" href="/images/logo.svg" color="#222">
<link rel="stylesheet" href="/css/main.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/[email protected]/css/all.min.css" integrity="sha256-mUZM63G8m73Mcidfrv5E+Y61y7a12O5mW4ezU3bxqW4=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/animate.min.css" integrity="sha256-PR7ttpcvz8qrF57fur/yAx1qXMFJeJFiA6pSzWi0OIE=" crossorigin="anonymous">
<script class="next-config" data-name="main" type="application/json">{"hostname":"example.com","root":"/","images":"/images","scheme":"Gemini","version":"8.7.1","exturl":false,"sidebar":{"position":"left","display":"post","padding":18,"offset":12},"copycode":false,"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果:${query}","hits_time":"找到 ${hits} 个搜索结果(用时 ${time} 毫秒)","hits":"找到 ${hits} 个搜索结果"}}</script><script src="/js/config.js"></script>
<meta property="og:type" content="website">
<meta property="og:title" content="Curry's Blog">
<meta property="og:url" content="http://example.com/index.html">
<meta property="og:site_name" content="Curry's Blog">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="Curry">
<meta name="twitter:card" content="summary">
<link rel="canonical" href="http://example.com/">
<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":true,"isPost":false,"lang":"zh-CN","comments":"","permalink":"","path":"index.html","title":""}</script>
<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>Curry's Blog</title>
<noscript>
<link rel="stylesheet" href="/css/noscript.css">
</noscript>
</head>
<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
<div class="headband"></div>
<main class="main">
<header class="header" itemscope itemtype="http://schema.org/WPHeader">
<div class="header-inner"><div class="site-brand-container">
<div class="site-nav-toggle">
<div class="toggle" aria-label="切换导航栏" role="button">
</div>
</div>
<div class="site-meta">
<a href="/" class="brand" rel="start">
<i class="logo-line"></i>
<h1 class="site-title">Curry's Blog</h1>
<i class="logo-line"></i>
</a>
</div>
<div class="site-nav-right">
<div class="toggle popup-trigger">
</div>
</div>
</div>
</div>
<div class="toggle sidebar-toggle" role="button">
<span class="toggle-line"></span>
<span class="toggle-line"></span>
<span class="toggle-line"></span>
</div>
<aside class="sidebar">
<div class="sidebar-inner sidebar-overview-active">
<ul class="sidebar-nav">
<li class="sidebar-nav-toc">
文章目录
</li>
<li class="sidebar-nav-overview">
站点概览
</li>
</ul>
<div class="sidebar-panel-container">
<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
</div>
<!--/noindex-->
<div class="site-overview-wrap sidebar-panel">
<div class="site-overview">
<div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
<p class="site-author-name" itemprop="name">Curry</p>
<div class="site-description" itemprop="description"></div>
</div>
<div class="site-state-wrap site-overview-item animated">
<nav class="site-state">
<div class="site-state-item site-state-posts">
<a href="/archives/">
<span class="site-state-item-count">4</span>
<span class="site-state-item-name">日志</span>
</a>
</div>
<div class="site-state-item site-state-categories">
<a href="/categories/">
<span class="site-state-item-count">2</span>
<span class="site-state-item-name">分类</span></a>
</div>
<div class="site-state-item site-state-tags">
<a href="/tags/">
<span class="site-state-item-count">2</span>
<span class="site-state-item-name">标签</span></a>
</div>
</nav>
</div>
</div>
</div>
</div>
</div>
</aside>
<div class="sidebar-dimmer"></div>
</header>
<div class="back-to-top" role="button" aria-label="返回顶部">
<i class="fa fa-arrow-up"></i>
<span>0%</span>
</div>
<noscript>
<div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>
<div class="main-inner index posts-expand">
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2021/09/24/hexo-YAMLException/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Curry">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Curry's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/09/24/hexo-YAMLException/" class="post-title-link" itemprop="url">hexo YAMLException</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-09-24 15:00:22 / 修改时间:15:32:18" itemprop="dateCreated datePublished" datetime="2021-09-24T15:00:22+08:00">2021-09-24</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/hexo/" itemprop="url" rel="index"><span itemprop="name">hexo</span></a>
</span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>保存准备发布文章时,提示如下报错:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">ERROR {</span><br><span class="line"> err: YAMLException: can not read a block mapping entry; a multiline key may not be an implicit key at line 5, column 1:</span><br><span class="line">...</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>问题原因:<strong>缺少空格</strong>!</p>
<figure class="highlight kotlin"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//错误示例(categories:hexo)</span></span><br><span class="line">title: hexo YAMLException</span><br><span class="line">date: <span class="number">2021</span>-09-<span class="number">24</span> <span class="number">15</span>:<span class="number">00</span>:<span class="number">22</span></span><br><span class="line">tags: hexo</span><br><span class="line">categories:hexo</span><br></pre></td></tr></table></figure>
<figure class="highlight kotlin"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//正确示例(categories: hexo)</span></span><br><span class="line">title: hexo YAMLException</span><br><span class="line">date: <span class="number">2021</span>-09-<span class="number">24</span> <span class="number">15</span>:<span class="number">00</span>:<span class="number">22</span></span><br><span class="line">tags: hexo</span><br><span class="line">categories: hexo</span><br></pre></td></tr></table></figure>
<p><a target="_blank" rel="noopener" href="https://hexo.io/zh-cn/docs/troubleshooting.html#YAML-%E8%A7%A3%E6%9E%90%E9%94%99%E8%AF%AF">官方说明</a></p>
<p><img src="/2021/09/24/hexo-YAMLException/image-20210924151457951.png" alt="image-20210924151457951"></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2021/09/24/hexo%E5%A2%9E%E5%8A%A0%E5%88%86%E7%B1%BB%E5%92%8C%E6%A0%87%E7%AD%BE/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Curry">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Curry's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/09/24/hexo%E5%A2%9E%E5%8A%A0%E5%88%86%E7%B1%BB%E5%92%8C%E6%A0%87%E7%AD%BE/" class="post-title-link" itemprop="url">hexo增加分类和标签</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-09-24 14:58:15 / 修改时间:15:44:44" itemprop="dateCreated datePublished" datetime="2021-09-24T14:58:15+08:00">2021-09-24</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/hexo/" itemprop="url" rel="index"><span itemprop="name">hexo</span></a>
</span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h4 id="创建“分类”选项"><a href="#创建“分类”选项" class="headerlink" title="创建“分类”选项"></a><strong>创建“分类”选项</strong></h4><p>在hexo目录下,执行:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo new page categories</span><br></pre></td></tr></table></figure>
<p>hexo\source目录下会生成categories文件夹;编辑categories\index.md,添加 type: “categories”;添加后保存并关闭文件。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">---</span><br><span class="line">title: 分类</span><br><span class="line">date: 2021-09-24 14:43:00</span><br><span class="line">type: categories</span><br><span class="line">---</span><br></pre></td></tr></table></figure>
<p><strong>给文章添加“categories”属性</strong></p>
<p>打开需要添加分类的文章,为其添加categories属性。</p>
<p>下方的categories:hexo表示这篇文章添加到到“hexo”这个分类。注意:一篇文章只会添加到一个分类中,如果是多个默认放到第一个分类中。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">---</span><br><span class="line">title: hexo增加分类和标签</span><br><span class="line">date: 2021-09-24 14:43:00</span><br><span class="line">categories: hexo</span><br><span class="line">---</span><br></pre></td></tr></table></figure>
<h4 id="创建“标签”选项(与添加分类操作类似)"><a href="#创建“标签”选项(与添加分类操作类似)" class="headerlink" title="创建“标签”选项(与添加分类操作类似)"></a><strong>创建“标签”选项</strong>(与添加分类操作类似)</h4><p>在hexo目录下,执行:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo new page tags</span><br></pre></td></tr></table></figure>
<p>hexo\source目录下会生成tags文件夹;编辑tags\index.md,添加 type: “tags”;添加后保存并关闭文件。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">---</span><br><span class="line">title: 标签</span><br><span class="line">date: 2021-09-24 14:43:00</span><br><span class="line">type: tags</span><br><span class="line">---</span><br></pre></td></tr></table></figure>
<p><strong>给文章添加“tags”属性</strong></p>
<p>打开需要添加标签的文章,为其添加tags属性。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">---</span><br><span class="line">title: hexo增加分类和标签</span><br><span class="line">date: 2019-04-24 15:40:24</span><br><span class="line">categories: hexo</span><br><span class="line">tags: hexo</span><br><span class="line">---</span><br></pre></td></tr></table></figure>
<p><strong>参考:</strong></p>
<p><a target="_blank" rel="noopener" href="https://juejin.cn/post/6844903830216261645">https://juejin.cn/post/6844903830216261645</a></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2021/09/24/T-Unit/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Curry">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Curry's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/09/24/T-Unit/" class="post-title-link" itemprop="url">T.()->Unit</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-09-24 13:57:58 / 修改时间:14:43:51" itemprop="dateCreated datePublished" datetime="2021-09-24T13:57:58+08:00">2021-09-24</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/Kotlin/" itemprop="url" rel="index"><span itemprop="name">Kotlin</span></a>
</span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<p>T.()->Unit相当于是给类T定义了一个扩展函数,该函数没有形参,没有返回值;</p>
<figure class="highlight kotlin"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">typealias</span> CallBack<T> = TestCallBack<T>.()-><span class="built_in">Unit</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">fun</span> <span class="title">test</span><span class="params">(callback:<span class="type">CallBack</span><<span class="type">T</span>>)</span></span>{</span><br><span class="line"> <span class="keyword">val</span> test = TestCallBack<T>()</span><br><span class="line"> test.callback()</span><br><span class="line">}</span><br></pre></td></tr></table></figure>
<p>这里callback就相当于一个TestCallBack的扩展函数,所以可以test.callback()</p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
<div class="post-block">
<article itemscope itemtype="http://schema.org/Article" class="post-content" lang="">
<link itemprop="mainEntityOfPage" href="http://example.com/2021/09/18/Github-Hexo%E6%90%AD%E5%BB%BA%E7%AC%94%E8%AE%B0/">
<span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
<meta itemprop="image" content="/images/avatar.gif">
<meta itemprop="name" content="Curry">
<meta itemprop="description" content="">
</span>
<span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
<meta itemprop="name" content="Curry's Blog">
</span>
<header class="post-header">
<h2 class="post-title" itemprop="name headline">
<a href="/2021/09/18/Github-Hexo%E6%90%AD%E5%BB%BA%E7%AC%94%E8%AE%B0/" class="post-title-link" itemprop="url">Github+Hexo搭建笔记</a>
</h2>
<div class="post-meta-container">
<div class="post-meta">
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar"></i>
</span>
<span class="post-meta-item-text">发表于</span>
<time title="创建时间:2021-09-18 16:51:31" itemprop="dateCreated datePublished" datetime="2021-09-18T16:51:31+08:00">2021-09-18</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-calendar-check"></i>
</span>
<span class="post-meta-item-text">更新于</span>
<time title="修改时间:2021-09-24 14:57:17" itemprop="dateModified" datetime="2021-09-24T14:57:17+08:00">2021-09-24</time>
</span>
<span class="post-meta-item">
<span class="post-meta-item-icon">
<i class="far fa-folder"></i>
</span>
<span class="post-meta-item-text">分类于</span>
<span itemprop="about" itemscope itemtype="http://schema.org/Thing">
<a href="/categories/hexo/" itemprop="url" rel="index"><span itemprop="name">hexo</span></a>
</span>
</span>
</div>
</div>
</header>
<div class="post-body" itemprop="articleBody">
<h4 id="一-Github"><a href="#一-Github" class="headerlink" title="一. Github"></a><strong>一. Github</strong></h4><ol>
<li><p>gihub中创建仓库,仓库名为:<github昵称>.github.io</p>
<p><img src="/2021/09/18/Github-Hexo%E6%90%AD%E5%BB%BA%E7%AC%94%E8%AE%B0/image-20210918165516634.png" alt="image-20210918165516634"></p>
<blockquote>
<p>2021年8月13日之后github不在支持密码登录,使用<strong>personal access token</strong>替代</p>
<p>在github的Settings – Developer settings – personal access token 中配置</p>
</blockquote>
</li>
</ol>
<h4 id="二-Hexo"><a href="#二-Hexo" class="headerlink" title="二. Hexo"></a><strong>二. Hexo</strong></h4><ol>
<li><p>安装hexo</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install -g hexo</span><br></pre></td></tr></table></figure></li>
<li><p>hexo初始化</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo init</span><br></pre></td></tr></table></figure></li>
<li><p>本地运行命令</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo s <span class="comment">// hexo server</span></span><br></pre></td></tr></table></figure></li>
<li><p>部署到github,打开hexo文件夹中的_config.xml,文末添加deploy的对应内容,参考如下:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"># Deployment</span><br><span class="line">## Docs: https://hexo.io/docs/one-command-deployment</span><br><span class="line">deploy:</span><br><span class="line"> type: git</span><br><span class="line"> repo: https://github.com/zhengcurry/zhengcurry.github.io</span><br><span class="line"> branch: master</span><br></pre></td></tr></table></figure>
<p>然后执行</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-deployer-git --save</span><br></pre></td></tr></table></figure>
<p>部署:</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">hexo clean</span><br><span class="line"></span><br><span class="line">hexo deploy</span><br></pre></td></tr></table></figure></li>
<li><p>新建文章</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">hexo new xxxx</span><br></pre></td></tr></table></figure></li>
<li><p>添加图片</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">npm install hexo-asset-image --save</span><br></pre></td></tr></table></figure>
<p>hexo文件夹中的_config.xml,把post_asset_folder值改为false</p>
<p>打开/node_modules/hexo-asset-image/index.js文件,替换如下</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">'use strict'</span>;</span><br><span class="line">var cheerio = require(<span class="string">'cheerio'</span>);</span><br><span class="line"></span><br><span class="line">// http://stackoverflow.com/questions/14480345/how-to-get-the-nth-occurrence-in-a-string</span><br><span class="line"><span class="keyword">function</span> getPosition(str, m, i) {</span><br><span class="line"> <span class="built_in">return</span> str.split(m, i).join(m).length;</span><br><span class="line">}</span><br><span class="line"></span><br><span class="line">var version = String(hexo.version).split(<span class="string">'.'</span>);</span><br><span class="line">hexo.extend.filter.register(<span class="string">'after_post_render'</span>, <span class="keyword">function</span>(data){</span><br><span class="line"> var config = hexo.config;</span><br><span class="line"> <span class="keyword">if</span>(config.post_asset_folder){</span><br><span class="line"> var link = data.permalink;</span><br><span class="line"> <span class="keyword">if</span>(version.length > 0 && Number(version[0]) == 3)</span><br><span class="line"> var beginPos = getPosition(link, <span class="string">'/'</span>, 1) + 1;</span><br><span class="line"> <span class="keyword">else</span></span><br><span class="line"> var beginPos = getPosition(link, <span class="string">'/'</span>, 3) + 1;</span><br><span class="line"> // In hexo 3.1.1, the permalink of <span class="string">"about"</span> page is like <span class="string">".../about/index.html"</span>.</span><br><span class="line"> var endPos = link.lastIndexOf(<span class="string">'/'</span>) + 1;</span><br><span class="line"> link = link.substring(beginPos, endPos);</span><br><span class="line"></span><br><span class="line"> var toprocess = [<span class="string">'excerpt'</span>, <span class="string">'more'</span>, <span class="string">'content'</span>];</span><br><span class="line"> <span class="keyword">for</span>(var i = 0; i < toprocess.length; i++){</span><br><span class="line"> var key = toprocess[i];</span><br><span class="line"> </span><br><span class="line"> var $ = cheerio.load(data[key], {</span><br><span class="line"> ignoreWhitespace: <span class="literal">false</span>,</span><br><span class="line"> xmlMode: <span class="literal">false</span>,</span><br><span class="line"> lowerCaseTags: <span class="literal">false</span>,</span><br><span class="line"> decodeEntities: <span class="literal">false</span></span><br><span class="line"> });</span><br><span class="line"></span><br><span class="line"> $(<span class="string">'img'</span>).each(<span class="function"><span class="title">function</span></span>(){</span><br><span class="line"> <span class="keyword">if</span> ($(this).attr(<span class="string">'src'</span>)){</span><br><span class="line"> // For windows style path, we replace <span class="string">'\'</span> to <span class="string">'/'</span>.</span><br><span class="line"> var src = $(this).attr(<span class="string">'src'</span>).replace(<span class="string">'\\'</span>, <span class="string">'/'</span>);</span><br><span class="line"> <span class="keyword">if</span>(!/http[s]*.*|\/\/.*/.<span class="built_in">test</span>(src) &&</span><br><span class="line"> !/^\s*\//.<span class="built_in">test</span>(src)) {</span><br><span class="line"> // For <span class="string">"about"</span> page, the first part of <span class="string">"src"</span> can<span class="string">'t be removed.</span></span><br><span class="line"><span class="string"> // In addition, to support multi-level local directory.</span></span><br><span class="line"><span class="string"> var linkArray = link.split('</span>/<span class="string">').filter(function(elem){</span></span><br><span class="line"><span class="string"> return elem != '</span><span class="string">';</span></span><br><span class="line"><span class="string"> });</span></span><br><span class="line"><span class="string"> var srcArray = src.split('</span>/<span class="string">').filter(function(elem){</span></span><br><span class="line"><span class="string"> return elem != '</span><span class="string">' && elem != '</span>.<span class="string">';</span></span><br><span class="line"><span class="string"> });</span></span><br><span class="line"><span class="string"> if(srcArray.length > 1)</span></span><br><span class="line"><span class="string"> srcArray.shift();</span></span><br><span class="line"><span class="string"> src = srcArray.join('</span>/<span class="string">');</span></span><br><span class="line"><span class="string"> $(this).attr('</span>src<span class="string">', config.root + link + src);</span></span><br><span class="line"><span class="string"> console.info&&console.info("update link as:-->"+config.root + link + src);</span></span><br><span class="line"><span class="string"> }</span></span><br><span class="line"><span class="string"> }else{</span></span><br><span class="line"><span class="string"> console.info&&console.info("no src attr, skipped...");</span></span><br><span class="line"><span class="string"> console.info&&console.info($(this));</span></span><br><span class="line"><span class="string"> }</span></span><br><span class="line"><span class="string"> });</span></span><br><span class="line"><span class="string"> data[key] = $.html();</span></span><br><span class="line"><span class="string"> }</span></span><br><span class="line"><span class="string"> }</span></span><br><span class="line"><span class="string">});</span></span><br></pre></td></tr></table></figure>
<p>然后即可添加图片,参考<a href="#Typora">Typora</a></p>
</li>
<li><p>删除文章</p>
<p>删除本地对应文件,然后执行如下命令</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">hexo g</span><br><span class="line">hexo d</span><br></pre></td></tr></table></figure></li>
</ol>
<h4 id="Typora"><a href="#Typora" class="headerlink" title="Typora"></a><strong>Typora</strong></h4><p>配置如下,将图片拖拽到md文档中,即可复制到指定目录下:</p>
<p><img src="/2021/09/18/Github-Hexo%E6%90%AD%E5%BB%BA%E7%AC%94%E8%AE%B0/image-20210923104949941.png" alt="image-20210923104949941"></p>
<p>在md文档中,直接使用图片名称,预览或发布后即可看到图片</p>
<p><img src="/2021/09/18/Github-Hexo%E6%90%AD%E5%BB%BA%E7%AC%94%E8%AE%B0/image-20210923105008730.png" alt="image-20210923105008730"></p>
<p><strong>参考:</strong></p>
<p><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/390f202c5b0e">https://www.jianshu.com/p/390f202c5b0e</a></p>
<p><a target="_blank" rel="noopener" href="https://zhuanlan.zhihu.com/p/155996962">https://zhuanlan.zhihu.com/p/155996962</a></p>
<p><a target="_blank" rel="noopener" href="https://www.jianshu.com/p/f72aaad7b852">https://www.jianshu.com/p/f72aaad7b852</a></p>
</div>
<footer class="post-footer">
<div class="post-eof"></div>
</footer>
</article>
</div>
</div>
</main>
<footer class="footer">
<div class="footer-inner">
<div class="copyright">
©
<span itemprop="copyrightYear">2021</span>
<span class="with-love">
<i class="fa fa-heart"></i>
</span>
<span class="author" itemprop="copyrightHolder">Curry</span>
</div>
<div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/" rel="noopener" target="_blank">NexT.Gemini</a> 强力驱动
</div>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/lib/anime.min.js" integrity="sha256-XL2inqUJaslATFnHdJOi9GfQ60on8Wx1C2H8DYiN1xY=" crossorigin="anonymous"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/next-boot.js"></script>
</body>
</html>