Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function publish (cid) {
body: cid
})

if(!publishResponse.ok) throw new Error("Unable to publish: " + await publishResponse.text())
if (!publishResponse.ok) throw new Error('Unable to publish: ' + await publishResponse.text())

window.localStorage.ipns = ipnsRoot
window.localStorage.ipnsCid = cid
Expand All @@ -30,9 +30,17 @@ export function parseFilename (filename) {
}

function excerpt (content) {
let excerpt_ = content.slice(0, 100)
let start = 0
if (content.slice(0, 3) === '---') {
const secondMark = content.indexOf('---', 3)
start =
secondMark > 0
? secondMark
: 0
}
let excerpt_ = content.slice(start, 100)
if (excerpt_.indexOf('\n') > 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this account for cases where there's an empty newline after the second ---?

e.g.

---
hello: world
---

# My content starts here

excerpt_ = excerpt_.slice(0, excerpt_.indexOf('\n') + 1)
excerpt_ = excerpt_.slice(start, excerpt_.indexOf('\n') + 1)
}
return excerpt_
}
Expand Down Expand Up @@ -188,7 +196,7 @@ export async function mediaAdd (file) {
async function _fetchPosts (cid) {
const request = await fetch(`ipfs://${cid}/ipmb-db/?noResolve`, {
headers: {
Accept: "application/json"
Accept: 'application/json'
}
})
let dirList = await request.json()
Expand Down