Dealing with embedded images in markdown blog post with NodeJS (no CMS) - node.js

I am developing my own blog website using NodeJS and Express with no CMS and I was wondering how I could embed images in a markdown blog post and store the post AND the images on my website. I know that we generally use links in markdown to display images but I don't know how to implement it when writing a post.
The only way I was thinking about to achieve it was to upload the images on the server and then putting links in the post as I would have done it for external images.
I have no code for this solution because I'm confused. Does anyone have already had to deal with it making its own CMS ?

Related

External image can display as WebP Format?

My project is NuxtJS based.
I've been searching but couldn't find anything. In accordance with the working principles of my project, I pull images from external websites to my website via URL.
However, this creates problems in the Lighthouse reports. This is the error: "Serve images in nextgen formats".
Maybe it's silly, but is there a way to publish the images we take from websites in WebP format?
You can use API services.
They will Convert them automatically for you. but it is only possible if you have a backend side for your website, doing this in frontend is pointless.

where to store photos, in database or in api

I'm currently working on creating a website for my college. I want to include a galary section on the page.
so through admin page, authorities can upload photos of special college events. Now my question is where to store those images. I have two options 1)storing in the Database using gridfs 2) storing in the api. I have done a lot of research on this topic but everyone saying it depends on the situation. What do you think the best option for this situation. I'm still new to server side programming, so please help me. I'm using nodejs with ejs and mongodb

Storing images on server

I am new to backend programming. I am working on a personal Full stack project where I display all my art works. These art works are lot of images. I read up in some articles that it is better to save files on server than on database. I am using MEAN stack for my application. Can anyone refer me to some links or help me understand how can I achieve storing images on server?
If you are using node.js I recommend using multer for uploading your files through it to server and then make a public link to your file and store that link in your database.

NodeJS - PDF generate from URL

Wanted to generate a PDF from a URL
(https://10.1.40.117/print/e71b7c0f-4ed1-4d0d-b868-87418d398a4a).
Please help me with the links which is used to do this using nodeJS
I use Puppeteer to generate PDFs and their documentation has many examples. Since it uses Chrom(e|ium), it closes match my development environment as well which is nice when building the web pages.
For those who might stumble on this question nowadays:
There is cool tool called Gotenberg — Docker-powered stateless API for converting HTML, Markdown and Office documents to PDF. It supports converting URLs via Google Chrome headless.
And I am happen to be an author of JS/TS client for Gotenberg — gotenberg-js-client
I welcome you to use it :)
UPD:
Gotenberg has new website now — https://gotenberg.dev

Database for Portfolio CMS based on Node js

I am pretty new to Node.js, and I am stuck a bit. There is a project a portfolio CMS what popped out of my mind, and actually the simplicity of Ghost
Inspired me, that you just download and it works, but I suddenly realized at this case it might not work. Ghost uses SQlight as far as I know.
So my question is, the platform will handle custom pages, so uses will be able to create pages like in Wordpress, will handle blog posts, image gallery and theming.
I was thinking to use MongoDB, but I have some questions.
So people will be available to to create image galleries and insert it to pages as short code (just telling) and my question is.
Is MongoDB capable for this type of cms?
Will the embedded data for the image gallery can cause problems in the future or has any limits?
Image gallery example
Model.Gallery {
id: OjectId,
name: Gallery name 1,
CreatedBy: userId,
images: [
{filename: 'image 1'},
{filename: 'image 2'},
{filename: 'image 3'},
]
}
Or would you recommend something else?
Thank you
Sounds like you're looking for KeystoneJS.
(disclaimer: I am a core contributor)
It's a mongodb-based CMS for node.js and has a Yeoman generator that you can use to quickly create a blog site with posts, image galleries and an enquiry form. The generator builds basic templates with jQuery and Bootstrap, so it's easy to customise or drop a theme into.
It uses Jade for templates by default, but you can configure it with any template engine (EJS, nunjucks, dust, etc). Same with LESS for CSS preprocessing (as Bootstrap does).
While Ghost is very focused in the features it provides (and doesn't give you generic CMS features like Wordpress does), Keystone is more flexible, and its Admin UI is generated based on the models you define (which, in code, look very similar to the example in your question). So you can add other models, and create relationships between them, and the Admin UI will automatically include them.
Image galleries don't really have any limits as in MongoDB you're just storing references to the images, not the files themselves. To make this easy in KeystoneJS we often use a service called Cloudinary, which will handle uploading and resizing for you, and serve the images via a CDN. Keystone also supports Amazon S3 or the local file system if you prefer, though.
For custom pages, you can add these as other templates, or some people define a 'Pages' model for generic content.
Hope this helps!

Resources