Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link attribute no longer rendering #832

Open
mingard opened this issue Apr 17, 2020 · 1 comment
Open

Link attribute no longer rendering #832

mingard opened this issue Apr 17, 2020 · 1 comment

Comments

@mingard
Copy link
Contributor

mingard commented Apr 17, 2020

Previous versions of Publish supported the publish.display.link attribute, which accepted a pattern that contained {value} such as https://somedomain.com/path/to/{value} which would use the value of the field to replace the placeholder.

const {display = {}, multiline, readonly, resizable, rows} = publishBlock
const link = formatLink(value, display.link)

export default function formatLink(value, displayDirective) {
if (displayDirective && value) {
if (typeof displayDirective === 'string') {
return displayDirective.replace('{value}', value)
}
return /^https?:\/\//.test(value) ? value : 'http://' + value
}
return null
}

The formatLink seems to be returning only the value of the field where previously it would render.

@jimlambie
Copy link
Contributor

jimlambie commented Apr 19, 2020

@mingard interestingly it still works on the list view

const valueFormatted = value.replace(/(^\w+:|^)\/\//, '').replace(/\/$/, '')
if (typeof template === 'string') {
value = template.replace(/{value}/, value)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants