addSummary: use opening and closing tags to select page summary. So summary doesn't have to be first thing in file.
This commit is contained in:
parent
be6ea7b34e
commit
860380d46a
|
|
@ -3,10 +3,12 @@ title: My Public File
|
||||||
cuid: 26e4-a1
|
cuid: 26e4-a1
|
||||||
---
|
---
|
||||||
|
|
||||||
|
<!--summary-start-->
|
||||||
|
|
||||||
This is a public file with some nice text.
|
This is a public file with some nice text.
|
||||||
|
|
||||||
It's easy to write in this file.
|
It's easy to write in this file.
|
||||||
<!--summary-above-->
|
<!--summary-end-->
|
||||||
I can write more things after the comment if I want.
|
I can write more things after the comment if I want.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
//looks for an html comment pattern, and, if found,
|
//looks for an html comment pattern, and, if found,
|
||||||
//adds the text before it to the doc under the key `summary`.
|
//adds the text before it to the doc under the key `summary`.
|
||||||
const reg = /^(?<summary>.+)?<!--summary-above-->/s
|
const reg = /.*<!--summary-start-->(?<summary>.+)?<!--summary-end-->/s
|
||||||
|
//use a custom element instead.
|
||||||
|
// const reg = /<doc-summary>(?<summary>.+)?<\/doc-summary>/s
|
||||||
export default (doc) => {
|
export default (doc) => {
|
||||||
const result = reg.exec(doc._body);
|
const result = reg.exec(doc._body);
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue