简体   繁体   English

Angular 2+ 社交分享链接预览

[英]Angular 2+ Social Share Link Preview

I am working on an Angular 4 application, which has a feature that generates different feedback form links based on different criteria's.我正在开发一个 Angular 4 应用程序,它具有根据不同标准生成不同反馈表单链接的功能。 So it can have hundreds or thousands of links generated each day.因此,它每天可以生成数百或数千个链接。

What i want to do is make all these links rich in terms of social sharing ie each link if pasted on a social media such as facebook, it should be able to have metadata specific to that form ie all links will have different form names and descriptions.我想做的是使所有这些链接在社交共享方面变得丰富,即每个链接如果粘贴在 facebook 等社交媒体上,它应该能够具有特定于该表单的元数据,即所有链接都将具有不同的表单名称和描述. Each link specific data should be fetched when the link is pasted on facebook, twitter, etc.当链接粘贴到 facebook、twitter 等时,应获取每个链接特定数据。

How to approach this requirement.如何接近这个要求。 How to implement this?如何实施? Thanks in advance.提前致谢。

You need to implement 2 things to solve the problem:您需要实施两件事来解决问题:

  1. Implement Open Graph Tags on you index.html page.在 index.html 页面上实现 Open Graph Tags。 You need to change these meta tags based upon the URL you are routing the user to via Meta Service in angular.您需要根据通过 angular 中的元服务将用户路由到的 URL 更改这些元标记。 Refer to the URL for further information https://alligator.io/angular/meta-tags/有关详细信息,请参阅 URL https://alligator.io/angular/meta-tags/
  2. Post this use server side rendering using Angular Universal.使用 Angular Universal 发布此使用服务器端渲染。
  3. Use Facebook debugger to verify the content generated.使用 Facebook 调试器验证生成的内容。

If your project can't implement SSR (due to static server) then above points won't work with facebook, twitter, linkedin, whatsapp.如果您的项目无法实现 SSR(由于 static 服务器),那么上述几点将不适用于 facebook、twitter、linkedin、whatsapp。

You need to go for solutions like: Angular 4 - Update Meta tags dynamically for Facebook (Open graph)您需要 go 解决方案,例如: Angular 4 - 为 Facebook 动态更新元标记(打开图表)

  1. Proxy Rendering.代理渲染。 prerender.io预渲染.io
  2. .htaccess with PHP. .htaccess 与 PHP。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM