Repository navigation
🐛 Images - Show the same image URLs with local Tina data as with TinaCloud data - #2804
Open
bradystroud wants to merge 5 commits into
Open
bradystroud wants to merge 5 commits into
bradystroud wants to merge 5 commits into
Conversation
…Cloud data (#2801) The local Tina server returns the stored path of a media file, for example "/uploads/rules/<folder>/<file>". TinaCloud returns the URL of its asset host for the same file. No route of the production site serves the stored path. Thus a page that is built from local content has broken images. - Add lib/tinaAssets.ts. It gives the URL that TinaCloud returns for a stored media path. - Use it in the image embed, the markdown image and the rule thumbnail. - Convert the image URLs in the rule body before TinaMarkdown gets the body. TinaMarkdown shows an image in a table cell with its default components, not with the components of the site. - Use the same function for the link to a file. The result of the link does not change. - In development, the image path does not change. The development server serves that path from the local content repository. A value from TinaCloud does not change. Thus the pages that are built from TinaCloud data stay the same. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTtNDpWnuaUUQ2winSSgMb
… cards (#2801) The "Help Improve Our Rules" card and the "Why All These Rules?" card give only some components to TinaMarkdown. TinaMarkdown thus shows an image in their rich text with its default component, and the URL must be correct in the content. No image is in these two fields at this time, so no page changes. With local Tina data, an image that an editor adds later gets the same URL as with TinaCloud data. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTtNDpWnuaUUQ2winSSgMb
…2801) The list has values that are not a path of the media library. TinaCloud does not return each of them in the same form, so the old comment was not correct. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTtNDpWnuaUUQ2winSSgMb
#2801) The category page, the box embed and the email embed also give rich text to TinaMarkdown. They now convert the image URLs in that content, so each TinaMarkdown render site has the same guarantee. An embed does not depend on the page that renders it. The conversion gives the same result when a value passes through it two times. Tests cover this. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTtNDpWnuaUUQ2winSSgMb
13 tasks
Member
Author
|
🎬 Explainer video for this pull request (about 40 seconds, no sound): the problem, the change, and how it helps. 🤖 Generated with Claude Code pr-2804.mp4 |
- tinaAssets.ts: the development proxy serves only /uploads/rules/ images and files, not each stored path. - typography-components.tsx: Tina leaves a link path unchanged, and this function converts it to the asset URL. Review suggestions from Josh Berman. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UTtNDpWnuaUUQ2winSSgMb
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
✏️
Relates to #2801 (phase 3, first task). Release this pull request before the build reads local content.
Pain
https://assets.tina.io/<client ID>/rules/<folder>/<file>./uploads/rules/<folder>/<file>. The production site does not serve that path (404).mainhas broken images. In a test build, 16 of 18 pages had image URLs that are different from production (50 URLs).Change
lib/tinaAssets.ts:toTinaAssetUrl(value)gives the URL that TinaCloud returns for a stored media path. All other values stay the same.tinaImageSrc(value)does the same for an image value. In development it keeps the stored path, becauseproxy.tsserves that path from the local content repository.withTinaImageSrc(content)converts the URL of each markdown image in rich-text content.NEXT_PUBLIC_TINA_CLIENT_IDgives the client ID. It is a Docker build argument, and Next.js puts it into the server and client code at build time.components/embeds/imageEmbed.tsxsrcof an image embedtinaImageSrccomponents/typography-components.tsx(img)tinaImageSrccomponents/typography-components.tsx(a)toTinaAssetUrl. The result is the same as before.app/[filename]/ServerRulePage.tsxtinaImageSrcTinaMarkdownrender sites:ServerRulePage.tsx,ServerCategoryPage.tsx,rule-list-item.tsx,boxEmbed.tsx,emailEmbed.tsx,HelpImproveCard.tsx,WhyRulesCard.tsxwithTinaImageSrcTinaMarkdownshows the content of a table cell with its default components. An image in a table does not get theimgcomponent of the site. 5 images in 2 rules are in tables.Values (measured on 18 production pages and on all 4,173 content files)
/uploads/rules/<folder>/<file>https://assets.tina.io/<client ID>/rules/<folder>/<file>/uploads/categories/<file>https://assets.tina.io/<client ID>/categories/<file>/uploads/__staging/<path>https://assets.tina.io/<client ID>/__staging/<path>/uploadshttps://github.com/...https://github.com/.../uploads/rules/<folder>/<file>.pdfResult
/,/categories,/archived,/orphaned,/search,/user): no Tina image value in the HTML. The Open Graph routes use the title and the author profile URL only.Tests
tinaAssets,tinaImagePaths,tinaContentImages).pnpm lintandpnpm testpass.tina/tina-lock.jsondoes not change.Risks
/__staging/<branch>/__file/...) was not measured.ImageEmbedand an image in a table ask for/uploads/...without the base path and get a 404. This is the same as onmain./uploadsin front of an external URL. Rules:easy-recording-space,follow-up-effectively,good-email-subject. TinaCloud removes the prefix, and this change does the same.0860fe57-1f97-414a-83c0-f84291018cf3). Rules:browser-add-branding,use-icons-to-not-surprise-users,video-background.Possible TinaCMS follow-up
TinaMarkdowntable cells ignore the given components. It passes onlypto the content of a cell, so an image or a link in a table always gets the default component.Screenshot (optional)
✏️ Not applicable. The pages look the same.
🤖 Generated with Claude Code
https://claude.ai/code/session_01UTtNDpWnuaUUQ2winSSgMb