parent
cd09d91434
commit
feea7f9b48
1 changed files with 32 additions and 24 deletions
|
|
@ -3,14 +3,18 @@ import {merge} from '../util/core'
|
||||||
|
|
||||||
const cached = {}
|
const cached = {}
|
||||||
|
|
||||||
function walkFetchEmbed({step = 0, embedTokens, compile, fetch}, cb) {
|
function walkFetchEmbed({embedTokens, compile, fetch}, cb) {
|
||||||
const token = embedTokens[step]
|
let token
|
||||||
|
let step = 0
|
||||||
|
let count = 1
|
||||||
|
|
||||||
if (!token) {
|
if (!embedTokens.length) {
|
||||||
return cb({})
|
return cb({})
|
||||||
}
|
}
|
||||||
|
|
||||||
const next = text => {
|
while ((token = embedTokens[step++])) {
|
||||||
|
const next = (function (token) {
|
||||||
|
return text => {
|
||||||
let embedToken
|
let embedToken
|
||||||
if (text) {
|
if (text) {
|
||||||
if (token.embed.type === 'markdown') {
|
if (token.embed.type === 'markdown') {
|
||||||
|
|
@ -26,8 +30,11 @@ function walkFetchEmbed({step = 0, embedTokens, compile, fetch}, cb) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
cb({token, embedToken})
|
cb({token, embedToken})
|
||||||
walkFetchEmbed({step: ++step, compile, embedTokens, fetch}, cb)
|
if (++count >= step) {
|
||||||
|
cb({})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
})(token)
|
||||||
|
|
||||||
if (process.env.SSR) {
|
if (process.env.SSR) {
|
||||||
fetch(token.embed.url).then(next)
|
fetch(token.embed.url).then(next)
|
||||||
|
|
@ -35,6 +42,7 @@ function walkFetchEmbed({step = 0, embedTokens, compile, fetch}, cb) {
|
||||||
get(token.embed.url).then(next)
|
get(token.embed.url).then(next)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function prerenderEmbed({compiler, raw = '', fetch}, done) {
|
export function prerenderEmbed({compiler, raw = '', fetch}, done) {
|
||||||
let hit
|
let hit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue