Files
psf-memo/psf-memo-client/acceptance/lib/render-post.js
T
Chris Troutner 3971e0736f Render image URLs inline in posts
Recognize common image file extensions in post URLs (query string and
fragment ignored), render them as inline images inside new-tab anchors
with the filename as alt text, and fall back to a plain link when the
image fails to load. Non-image URLs keep the existing plain-link
behavior.

By coder.
2026-09-16 07:07:40 -07:00

24 lines
672 B
JavaScript

/*
Acceptance rendering adapter for post text.
Renders the same PostContent component the browser uses to a static HTML
string, so acceptance assertions can inspect the resulting embed/player
markup without running a browser.
*/
'use strict'
const React = require('react')
const ReactDOMServer = require('react-dom/server')
const PostContent = require('../../src/components/post-feed/post-content')
function renderPostText (text, options = {}) {
const element = React.createElement(PostContent, {
text,
initialFailedImages: options.initialFailedImages
})
return ReactDOMServer.renderToStaticMarkup(element)
}
module.exports = { renderPostText }