This repository has been archived by the owner on Oct 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-mode.html
540 lines (507 loc) · 25.7 KB
/
api-mode.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
<!DOCTYPE html>
<html lang="zh-hans">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta http-equiv="cleartype" content="on">
<link rel="alternate" type="application/atom+xml" title="VeriPress Docs" href="/docs/feed.xml"/>
<!-- Link common CSS and JavaScript files -->
<link href="//cdn.bootcss.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet">
<link href="/docs/static/style.css" rel="stylesheet">
<link href="/docs/static/github-markdown-style.css" rel="stylesheet">
<link href="/docs/static/highlight.css" rel="stylesheet">
<link href="/docs/static/bootstrap-theme-cosmo.min.css" rel="stylesheet">
<link rel="shortcut icon" type="image/x-icon" href="/docs/static/favicon.ico">
<title>API 模式 - VeriPress Docs</title>
</head>
<body>
<div class="section">
<div class="container">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="row site-header-row">
<div class="col-md-8 site-header">
<h1><a href="/docs/">VeriPress Docs</a><br>
<small>Documentation of VeriPress.</small>
</h1>
</div>
</div>
<div class="row">
<div class="col-md-12 nav-container">
<ul class="nav nav-tabs">
<li><a href="/docs/">简体中文</a></li>
<li><a href="/docs/en/">English</a></li>
<li><a href="https://github.com/veripress/veripress">GitHub</a></li>
</ul>
</div>
</div>
</div>
<div class="col-md-2"></div>
</div>
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="panel panel-primary">
<div class="panel-heading"></div>
<div class="panel-body markdown-body">
<article>
<h1>API 模式</h1>
<hr>
<ul>
<li><a href="#基础知识">基础知识</a><ul>
<li><a href="#API-可以获取什么">API 可以获取什么?</a></li>
<li><a href="#API-的请求方式">API 的请求方式</a></li>
</ul></li>
<li><a href="#API-列表">API 列表</a><ul>
<li><a href="#api-site-获取网站信息"><code>/api/site</code> 获取网站信息</a></li>
<li><a href="#api-posts-获取文章列表"><code>/api/posts</code> 获取文章列表</a></li>
<li><a href="#api-tags-和-api-categories-获取标签和分类列表"><code>/api/tags</code> 和 <code>/api/categories</code> 获取标签和分类列表</a></li>
<li><a href="#api-widgets-获取页面部件列表"><code>/api/widgets</code> 获取页面部件列表</a></li>
<li><a href="#api-pages-page-path-获取自定义页面"><code>/api/pages/:page_path</code> 获取自定义页面</a></li>
<li><a href="#api-search-搜索文章和页面"><code>/api/search</code> 搜索文章和页面</a></li>
</ul></li>
</ul>
<hr>
<p>当运行模式 <code>MODE</code> 设置为 <code>api-only</code> 或 <code>mixed</code> 时,即开启了 API 模式,这种情况下,可以通过 <code>/api</code> 前缀来访问 API,由此将可以不受 VeriPress 页面划分逻辑的限制(只有首页的文章列表可以分页,标签、分类、归档、搜索页面默认不分页,这些限制是为了保持动态和静态运行的体验一致性),而直接在前端去获取数据并按想要的方式显示。</p>
<h2><a id="基础知识" href="#基础知识" class="anchor"></a>基础知识</h2>
<h3><a id="API-可以获取什么" href="#API-可以获取什么" class="anchor"></a>API 可以获取什么?</h3>
<p>API 模式开放的这些 API,只能获取和页面上显示的同样的文章列表、自定义页面和页面部件等,也就是说,设置为草稿的内容将无法获取到。同时目前也无法获取自定义页面的列表(因为这一内容形式变化性比较强,暂时没有较好的办法提供 API),只能通过具体路径获取单个页面。</p>
<p>另外,在获取文章列表时,返回的结果只有预览部分,获取单个文章时,则返回全部正文内容。</p>
<h3><a id="API-的请求方式" href="#API-的请求方式" class="anchor"></a>API 的请求方式</h3>
<p>所有 API 均使用 GET 方式来请求,当 HTTP 响应码为 200 时表示请求成功,这意味着请求的资源存在,并成功获取,返回的 JSON 中将直接包含该资源的数据,在后面的 API 列表中分别给出。状态码 4xx 表示请求失败,具体的错误状态码根据情况而不同,此时返回的 JSON 数据有 <code>code</code> 和 <code>message</code> 两个字段,分别是错误码和错误信息,例如:</p>
<div class="highlight"><pre><span></span><span class="p">{</span>
<span class="nt">"code"</span><span class="p">:</span> <span class="mi">101</span><span class="p">,</span>
<span class="nt">"message"</span><span class="p">:</span> <span class="s2">"No such API."</span>
<span class="p">}</span>
</pre></div>
<p>不同的 HTTP 状态码、错误码对应错误原因如下表:</p>
<table>
<thead>
<tr>
<th>错误码</th>
<th>HTTP 状态码</th>
<th>错误原因</th>
</tr>
</thead>
<tbody>
<tr>
<td>100</td>
<td>400</td>
<td>未定义的错误</td>
</tr>
<tr>
<td>101</td>
<td>404</td>
<td>API 不存在</td>
</tr>
<tr>
<td>102</td>
<td>404</td>
<td>资源不存在</td>
</tr>
<tr>
<td>103</td>
<td>400</td>
<td>请求参数不正确</td>
</tr>
<tr>
<td>104</td>
<td>403</td>
<td>请求的资源路径不被允许</td>
</tr>
<tr>
<td>105</td>
<td>400</td>
<td>请求的资源路径无法识别</td>
</tr>
</tbody>
</table>
<h2><a id="API-列表" href="#API-列表" class="anchor"></a>API 列表</h2>
<h3><a id="api-site-获取网站信息" href="#api-site-获取网站信息" class="anchor"></a><code>/api/site</code> 获取网站信息</h3>
<p>返回内容即为 <code>site.json</code> 的内容。</p>
<h3><a id="api-posts-获取文章列表" href="#api-posts-获取文章列表" class="anchor"></a><code>/api/posts</code> 获取文章列表</h3>
<p>可以接受的 URL 参数如下:</p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>title</code>、<code>layout</code>、<code>author</code>、<code>email</code>、<code>tags</code>、<code>categories</code></td>
<td>用于限定文章的元信息,可以多选,用英文逗号分隔</td>
</tr>
<tr>
<td><code>created</code>、<code>updated</code></td>
<td>用于限定创建和更新日期,每个参数必须是用逗号分隔的两个值,格式如 <code>2017-03-20</code>,分别为开始日期和截止日期</td>
</tr>
<tr>
<td><code>start</code></td>
<td>经过所有筛选之后,返回数据列表的第一个的下标</td>
</tr>
<tr>
<td><code>count</code></td>
<td>获取的文章数量</td>
</tr>
<tr>
<td><code>fields</code></td>
<td>指定要获取的文章信息的字段名,可多选,用逗号分隔</td>
</tr>
</tbody>
</table>
<p>例如请求 <code>/api/posts?layout=post&tags=Hello,Greeting&created=2017-01-01,2017-03-20&start=10&count=10&fields=title,author,created,updated,preview</code> 将返回布局为 <code>post</code>、有 <code>Hello</code> 或 <code>Greeting</code> 标签、在 2017-01-01 到 2017-03-20 之间创建的所有文章的第 10 条到第 19 条的 <code>title</code>、<code>author</code>、<code>created</code>、<code>updated</code>、<code>preview</code> 字段。</p>
<p>除了 URL 参数之外,还可以通过路径来对返回结果进行筛选(注意这里的筛选会在通过 <code>start</code> 和 <code>count</code> 参数取子列表之前进行),形如 <code>/api/posts/:year/:month/:day/:post_name</code>,四个路径参数分别表示创建年份、月份、日期、文章名(不是标题,是显示在 URL 中的文章名),可以从后往前依次省略。一旦指定了最后一个文章名,返回结果将不再是 JSON 数组,而是单个文章的 JSON 对象。</p>
<p>如果按条件筛选、按 <code>start</code>、<code>count</code> 取子列表之后,结果是空,则会返回错误码 102(资源不存在)。</p>
<p>资源存在时响应数据如下(没有精确指定到文章名的情况,为一个 JSON 数组):</p>
<div class="highlight"><pre><span></span><span class="p">[</span>
<span class="p">{</span>
<span class="nt">"author"</span><span class="p">:</span> <span class="s2">"My Name"</span><span class="p">,</span>
<span class="nt">"categories"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"Mauris"</span><span class="p">],</span>
<span class="nt">"created"</span><span class="p">:</span> <span class="s2">"2017-03-16 00:00:00"</span><span class="p">,</span>
<span class="nt">"email"</span><span class="p">:</span> <span class="s2">"[email protected]"</span><span class="p">,</span>
<span class="nt">"format"</span><span class="p">:</span> <span class="s2">"txt"</span><span class="p">,</span>
<span class="nt">"has_more_content"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="nt">"is_draft"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="nt">"layout"</span><span class="p">:</span> <span class="s2">"post"</span><span class="p">,</span>
<span class="nt">"meta"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"categories"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"Mauris"</span><span class="p">],</span>
<span class="nt">"tags"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"Blog"</span><span class="p">],</span>
<span class="nt">"title"</span><span class="p">:</span> <span class="s2">"Lorem Ipsum"</span>
<span class="p">},</span>
<span class="nt">"preview"</span><span class="p">:</span> <span class="s2">"<pre class=\"txt\">abcd</pre>"</span><span class="p">,</span>
<span class="nt">"rel_url"</span><span class="p">:</span> <span class="s2">"2017/03/16/viverra/"</span><span class="p">,</span>
<span class="nt">"tags"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"Blog"</span><span class="p">],</span>
<span class="nt">"title"</span><span class="p">:</span> <span class="s2">"Lorem Ipsum"</span><span class="p">,</span>
<span class="nt">"unique_key"</span><span class="p">:</span> <span class="s2">"/post/2017/03/16/viverra/"</span><span class="p">,</span>
<span class="nt">"updated"</span><span class="p">:</span> <span class="s2">"2017-03-16 00:00:00"</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"author"</span><span class="p">:</span> <span class="s2">"My Name"</span><span class="p">,</span>
<span class="nt">"categories"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"Donec"</span><span class="p">],</span>
<span class="nt">"created"</span><span class="p">:</span> <span class="s2">"2017-03-04 00:00:00"</span><span class="p">,</span>
<span class="nt">"email"</span><span class="p">:</span> <span class="s2">"[email protected]"</span><span class="p">,</span>
<span class="nt">"format"</span><span class="p">:</span> <span class="s2">"markdown"</span><span class="p">,</span>
<span class="nt">"has_more_content"</span><span class="p">:</span> <span class="kc">true</span><span class="p">,</span>
<span class="nt">"is_draft"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="nt">"layout"</span><span class="p">:</span> <span class="s2">"post"</span><span class="p">,</span>
<span class="nt">"meta"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"categories"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"Donec"</span><span class="p">],</span>
<span class="nt">"tags"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"VeriPress"</span><span class="p">],</span>
<span class="nt">"title"</span><span class="p">:</span> <span class="s2">"Some Title"</span>
<span class="p">},</span>
<span class="nt">"preview"</span><span class="p">:</span> <span class="s2">"The preview part of content."</span><span class="p">,</span>
<span class="nt">"rel_url"</span><span class="p">:</span> <span class="s2">"2017/03/04/lacinia/"</span><span class="p">,</span>
<span class="nt">"tags"</span><span class="p">:</span> <span class="p">[</span><span class="s2">"VeriPress"</span><span class="p">],</span>
<span class="nt">"title"</span><span class="p">:</span> <span class="s2">"\u5f3a\u5212\u9ad8\u9898\u7c7b\u5546"</span><span class="p">,</span>
<span class="nt">"unique_key"</span><span class="p">:</span> <span class="s2">"/post/2017/03/04/lacinia/"</span><span class="p">,</span>
<span class="nt">"updated"</span><span class="p">:</span> <span class="s2">"2017-03-04 00:00:00"</span>
<span class="p">}</span>
<span class="p">]</span>
</pre></div>
<p>其中每个文章对象的字段说明如下:</p>
<table>
<thead>
<tr>
<th>字段名</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>format</code></td>
<td>撰写文章所使用的格式</td>
</tr>
<tr>
<td><code>is_draft</code></td>
<td>是否草稿(API 所能获取到的全为 false)</td>
</tr>
<tr>
<td><code>meta</code></td>
<td>文章的原始元信息,保留了文件中的 YAML 头解析之后的最原始信息</td>
</tr>
<tr>
<td><code>rel_url</code></td>
<td>文章相对于 <code>/post</code> 的路径</td>
</tr>
<tr>
<td><code>unique_key</code></td>
<td>文章的唯一标记值,同时也是页面的绝对路径(不包含 application root)</td>
</tr>
<tr>
<td><code>layout</code></td>
<td>布局</td>
</tr>
<tr>
<td><code>title</code></td>
<td>标题</td>
</tr>
<tr>
<td><code>author</code></td>
<td>作者</td>
</tr>
<tr>
<td><code>email</code></td>
<td>作者 email</td>
</tr>
<tr>
<td><code>tags</code></td>
<td>标签列表</td>
</tr>
<tr>
<td><code>categories</code></td>
<td>分类列表</td>
</tr>
<tr>
<td><code>created</code></td>
<td>创建时间</td>
</tr>
<tr>
<td><code>updated</code></td>
<td>更新时间</td>
</tr>
<tr>
<td><code>preview</code></td>
<td>预览部分解析后的 HTML 内容(只在获取文章列表时有)</td>
</tr>
<tr>
<td><code>has_more_content</code></td>
<td>除了预览部分之外是否正文很有更多内容(只在获取文章列表时有)</td>
</tr>
<tr>
<td><code>content</code></td>
<td>全部正文解析后的 HTML 内容(只在获取单个文章时有)</td>
</tr>
</tbody>
</table>
<h3><a id="api-tags-和-api-categories-获取标签和分类列表" href="#api-tags-和-api-categories-获取标签和分类列表" class="anchor"></a><code>/api/tags</code> 和 <code>/api/categories</code> 获取标签和分类列表</h3>
<p>直接返回所有的标签/分类和该标签/分类下的非草稿(已发布)文章数量,如:</p>
<div class="highlight"><pre><span></span><span class="p">[</span>
<span class="p">{</span>
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Programming Language"</span><span class="p">,</span>
<span class="nt">"published"</span><span class="p">:</span> <span class="mi">2</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Python"</span><span class="p">,</span>
<span class="nt">"published"</span><span class="p">:</span> <span class="mi">2</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Web Framework"</span><span class="p">,</span>
<span class="nt">"published"</span><span class="p">:</span> <span class="mi">1</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"name"</span><span class="p">:</span> <span class="s2">"Flask"</span><span class="p">,</span>
<span class="nt">"published"</span><span class="p">:</span> <span class="mi">1</span>
<span class="p">}</span>
<span class="p">]</span>
</pre></div>
<h3><a id="api-widgets-获取页面部件列表" href="#api-widgets-获取页面部件列表" class="anchor"></a><code>/api/widgets</code> 获取页面部件列表</h3>
<p>可以接受的 URL 参数如下:</p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>position</code></td>
<td>指定要获取的部件的位置</td>
</tr>
</tbody>
</table>
<p>响应数据:</p>
<div class="highlight"><pre><span></span><span class="p">[</span>
<span class="p">{</span>
<span class="nt">"content"</span><span class="p">:</span> <span class="s2">"<h4>My Name</h4>\n<p>Welcome to my blog!</p>"</span><span class="p">,</span>
<span class="nt">"format"</span><span class="p">:</span> <span class="s2">"markdown"</span><span class="p">,</span>
<span class="nt">"is_draft"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="nt">"meta"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"order"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"position"</span><span class="p">:</span> <span class="s2">"sidebar"</span>
<span class="p">},</span>
<span class="nt">"order"</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="nt">"position"</span><span class="p">:</span> <span class="s2">"sidebar"</span>
<span class="p">},</span>
<span class="p">{</span>
<span class="nt">"content"</span><span class="p">:</span> <span class="s2">"<h4>Friend Links</h4>"</span><span class="p">,</span>
<span class="nt">"format"</span><span class="p">:</span> <span class="s2">"markdown"</span><span class="p">,</span>
<span class="nt">"is_draft"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="nt">"meta"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"order"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">"position"</span><span class="p">:</span> <span class="s2">"sidebar"</span>
<span class="p">},</span>
<span class="nt">"order"</span><span class="p">:</span> <span class="mi">1</span><span class="p">,</span>
<span class="nt">"position"</span><span class="p">:</span> <span class="s2">"sidebar"</span>
<span class="p">}</span>
<span class="p">]</span>
</pre></div>
<p>字段说明:</p>
<table>
<thead>
<tr>
<th>字段名</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>format</code></td>
<td>撰写页面部件所使用的格式</td>
</tr>
<tr>
<td><code>is_draft</code></td>
<td>是否草稿(API 所能获取到的全为 false)</td>
</tr>
<tr>
<td><code>meta</code></td>
<td>页面部件的原始元信息,保留了文件中的 YAML 头解析之后的最原始信息</td>
</tr>
<tr>
<td><code>position</code></td>
<td>页面部件的位置</td>
</tr>
<tr>
<td><code>order</code></td>
<td>页面部件的排序</td>
</tr>
<tr>
<td><code>content</code></td>
<td>正文解析后的 HTML 内容</td>
</tr>
</tbody>
</table>
<h3><a id="api-pages-page-path-获取自定义页面" href="#api-pages-page-path-获取自定义页面" class="anchor"></a><code>/api/pages/:page_path</code> 获取自定义页面</h3>
<p><code>page_path</code> 路径参数表示要获取的自定义页面的相对路径,也即在以 view 模式访问时所使用的路径,比如一个页面可以从 <code>/a/b/c/d.html</code> 访问到,则相对应的 API URL 就是 <code>/api/pages/a/b/c/d.html</code>。如果请求的路径是一个直接存在的文件,将会直接返回这个文件,否则,对于使用所支持的格式撰写的页面,将返回解析之后的 JSON 对象。前面一种情况不用多说,文件是什么样就会怎么发送,后一种情况的响应数据如下:</p>
<div class="highlight"><pre><span></span><span class="p">{</span>
<span class="nt">"author"</span><span class="p">:</span> <span class="s2">"My Name"</span><span class="p">,</span>
<span class="nt">"content"</span><span class="p">:</span> <span class="s2">"<p>Lorem ipsum dolor sit amet</p>"</span><span class="p">,</span>
<span class="nt">"created"</span><span class="p">:</span> <span class="s2">"1970-01-01 00:00:00"</span><span class="p">,</span>
<span class="nt">"email"</span><span class="p">:</span> <span class="s2">"[email protected]"</span><span class="p">,</span>
<span class="nt">"format"</span><span class="p">:</span> <span class="s2">"markdown"</span><span class="p">,</span>
<span class="nt">"is_draft"</span><span class="p">:</span> <span class="kc">false</span><span class="p">,</span>
<span class="nt">"layout"</span><span class="p">:</span> <span class="s2">"page"</span><span class="p">,</span>
<span class="nt">"meta"</span><span class="p">:</span> <span class="p">{</span>
<span class="nt">"created"</span><span class="p">:</span> <span class="s2">"1970-01-01 00:00:00"</span>
<span class="p">},</span>
<span class="nt">"rel_url"</span><span class="p">:</span> <span class="s2">"about/"</span><span class="p">,</span>
<span class="nt">"title"</span><span class="p">:</span> <span class="s2">"About"</span><span class="p">,</span>
<span class="nt">"unique_key"</span><span class="p">:</span> <span class="s2">"/about/"</span><span class="p">,</span>
<span class="nt">"updated"</span><span class="p">:</span> <span class="s2">"1970-01-01 00:00:00"</span>
<span class="p">}</span>
</pre></div>
<p>字段说明:</p>
<table>
<thead>
<tr>
<th>字段名</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>format</code></td>
<td>撰写页面所使用的格式</td>
</tr>
<tr>
<td><code>is_draft</code></td>
<td>是否草稿(API 所能获取到的全为 false)</td>
</tr>
<tr>
<td><code>meta</code></td>
<td>页面的原始元信息,保留了文件中的 YAML 头解析之后的最原始信息</td>
</tr>
<tr>
<td><code>rel_url</code></td>
<td>页面相对于 <code>/</code> 的路径</td>
</tr>
<tr>
<td><code>unique_key</code></td>
<td>页面的唯一标记值,同时也是页面的绝对路径(不包含 application root)</td>
</tr>
<tr>
<td><code>layout</code></td>
<td>布局</td>
</tr>
<tr>
<td><code>title</code></td>
<td>标题</td>
</tr>
<tr>
<td><code>author</code></td>
<td>作者</td>
</tr>
<tr>
<td><code>email</code></td>
<td>作者 email</td>
</tr>
<tr>
<td><code>created</code></td>
<td>创建时间</td>
</tr>
<tr>
<td><code>updated</code></td>
<td>更新时间</td>
</tr>
<tr>
<td><code>content</code></td>
<td>全部正文解析后的 HTML 内容</td>
</tr>
</tbody>
</table>
<h3><a id="api-search-搜索文章和页面" href="#api-search-搜索文章和页面" class="anchor"></a><code>/api/search</code> 搜索文章和页面</h3>
<p>通过 URL 参数 <code>q</code> 指定搜索关键词,将会对文章和页面(搜索页面需要配置文件中 <code>ALLOW_SEARCH_PAGES</code> 设置为 True)的标题和正文解析之后的 HTML 内容进行搜索,将搜索到的文章和页面全部放在一个 JSON 数组中返回,具体的每个对象的字段,和上面的获取文章列表和获取自定义页面相同(其中,文章对象中只有 <code>preview</code>,没有 <code>content</code>)。</p>
</article>
</div>
<div class="panel-footer">
<span><i class="fa fa-fw fa-user"></i>Richard Chien</span>
<span><i class="fa fa-fw fa-refresh"></i>2017.03.21</span>
</div>
</div>
</div>
<div class="col-md-2"></div>
</div>
</div>
</div>
<footer class="section">
<div class="container">
<div class="row">
<div class="col-md-2"></div>
<div class="col-md-8">
<div class="row">
<div class="col-md-12">
<hr>
</div>
</div>
<div class="row">
<div class="col-md-12 text-center">
<span>Copyright © 2017 VeriPress.</span>
<br class="hidden-sm hidden-md hidden-lg">
<span>Powered by <a href="https://github.com/veripress/veripress">VeriPress</a>.</span>
</div>
</div>
</div>
<div class="col-md-2"></div>
</div>
</div>
</footer>
<script type="text/javascript">
var elems = document.getElementsByTagName("a");
for (var i = 0; i < elems.length; i++) {
if (elems[i].href.indexOf(document.domain) < 0) {
elems[i].target = "_blank";
}
}
var navLinks = document.querySelectorAll(".nav-tabs li a");
for (i = 0; i < navLinks.length; i++) {
if (document.location.href === navLinks[i].href) {
navLinks[i].parentElement.classList.add("active");
}
}
</script>
</body>
</html>