mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo.git
synced 2026-09-21 16:52:01 -07:00
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.
24 lines
672 B
JavaScript
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 }
|