preactjs / preact-cli

😺 Your next Preact PWA starts in 30 seconds.
MIT License
4.69k stars 375 forks source link

Lack of documentation around adding meta tags info in template.html #1561

Open lego-sharat opened 3 years ago

lego-sharat commented 3 years ago

My requirement was to add meta tags, so that when sharing links on twitter/fb/whatsapp a link preview should appear. I needed to add meta tags for this purpose. There is not a lot of documentation around that. Two things which are mentioned are preact-cli uses ejs and template.html has preact.title for dynamically showing title. Other than that, I couldn't find anything. I was able to figure out a solution by looking at the source code of the preact documentation site, where something like this is being used <%= htmlWebpackPlugin.options.CLI_DATA.preRenderData.description %>. So my questions are :

Also, I am willing to add the necessary documentation for this if but advance warning I don't have a lot of knowledge on html-webpack-plugin.

PS: Apologies if I have missed some obvious place which has the documentation And thanks for making this really useful framework

rschristian commented 3 years ago

Sorry, could use some extra docs there, but feel free to add.

If you look, preact-www uses preact build --prerenderUrls src/prerender.js ... as its build command, which leads here.

preRenderData.description isn't something that is exposed automatically, as it's coming entirely from that prerender script.

You can make your own script to generate whatever values you need.