fix: last paragraph disappearing
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Damillora 2022-08-08 12:24:59 +07:00
parent bba5926af4
commit 85ae5f4e94
2 changed files with 15 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import stringify from "rehype-stringify";
import { visit } from 'unist-util-visit'
import { fromSelector } from 'hast-util-from-selector';
import { generateSizesString, generateSrcsetString } from "./srcset";
import type { Nullable } from "@tryghost/content-api";
const sizes = [300, 600, 1000, 1500, 2000];
@ -59,12 +60,16 @@ export const postProcessor: Plugin = () => {
})
}
}
export const processPostHtml = async (postHtml: string) => {
const processor = unified()
.use(parse)
.use(postProcessor)
.use(stringify);
export const processPostHtml = async (postHtml?: Nullable<string>) => {
if (postHtml) {
const processor = unified()
.use(parse)
.use(postProcessor)
.use(stringify);
const result = await processor.process(postHtml);
return result.toString();
}
return "Unable to process post";
const result = await processor.process(postHtml);
return result.toString();
}

View File

@ -8,7 +8,7 @@
error: new Error('Post not found')
};
}
const newHtml = await processPostHtml(post.html ?? '');
const newHtml = await processPostHtml(post.html);
post.html = newHtml;
const prevPost = await browsePrevPost(post);
const nextPost = await browseNextPost(post);
@ -77,6 +77,8 @@
<PostMain>
<GhostStyle>
{@html post.html}
<br/>
</GhostStyle>
<svelte:fragment slot="comments" />
</PostMain>