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
|
||||
---
|
||||
|
||||
<!--summary-start-->
|
||||
|
||||
This is a public file with some nice text.
|
||||
|
||||
It's easy to write in this file.
|
||||
<!--summary-above-->
|
||||
<!--summary-end-->
|
||||
I can write more things after the comment if I want.
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
//looks for an html comment pattern, and, if found,
|
||||
//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) => {
|
||||
const result = reg.exec(doc._body);
|
||||
if (result) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue