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

Improve the display of attached files #61

Closed
giboow opened this issue Feb 23, 2023 · 3 comments
Closed

Improve the display of attached files #61

giboow opened this issue Feb 23, 2023 · 3 comments

Comments

@giboow
Copy link

giboow commented Feb 23, 2023

Attached files (Pdf/File/Video) are displayed via an "Image" link
It would be nice if a link with the file name was displayed.

@giboow
Copy link
Author

giboow commented Feb 23, 2023

It's possible to extract filename from S3 Url using regex:

case "pdf":
                {
                    let blockContent;
                    if (type === "video")
                        blockContent = block.video;
                    if (type === "file")
                        blockContent = block.file;
                    if (type === "pdf")
                        blockContent = block.pdf;

                    if (blockContent) {
                        const file_type = blockContent.type;
                        let link;
                        if (file_type === "external")
                            link = blockContent.external.url;
                        if (file_type === "file")
                            link = blockContent.file.url;

                        if (link) {
                            const matches = link.match(/[^\/\\&\?]+\.\w{3,4}(?=([\?&].*$|$))/);
                            let fileName = matches ? matches[0] : "Image";
                            return md.link(fileName, link);
                        }
                    }
                }
                break;

@souvikinator
Copy link
Owner

Keeping this on hold since a feature to deal with the s3 urls is work in progress. More details here #60

@souvikinator souvikinator moved this from Todo to Done in notion-to-md May 16, 2023
souvikinator added a commit that referenced this issue May 16, 2023
@souvikinator
Copy link
Owner

This feature should be live in the upcoming major release. Thank you for contribution.
Closing the issue now. In case of any issues feel free to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Status: Done
Development

No branches or pull requests

2 participants