你如何获得不同的 Soc。 Angular 中不同路线的 M 个缩略图?

How do you get different Soc. M thumbnails for different routes in Angular?

我有一个 Angular 页面 www.title.org 运行 通过 AWS Cloudfront。

这个项目在 index.html 文件中有一些元信息,例如:

<meta property="og:title" content="Title" />
<meta property="og:description" content="Bla bla" />
<meta property="og:image" content="image.png" />
<meta property="og:url" content="www.title.org" />

然而,当我在社交媒体中 post www.title.org/quiz 时,我希望预览中的缩略图与 image.png 不同。

我曾尝试在我的 quiz.component.ts 文件中使用 Angular Meta

this.meta.updateTag({ name: 'og:title', content: 'Title' })
this.meta.updateTag({ name: 'og:description', content: 'New description' })
this.meta.updateTag({ name: 'og:image', content: 'image_2.png' })
this.meta.updateTag({ name: 'og:url', content: 'www.title.org/quiz' })

但这不会更改缩略图或任何其他相关内容。

如何根据链接到 Angular 页面的路径更改缩略图?

更新:我尝试创建一个新的索引文件,其中包含不同的元数据和重定向。所以在 quiz/index.html 我有:

<head>
    <meta charset="utf-8">
    <meta property="og:title" content="My quiz" />
    <meta property="og:description" content="Do the quiz" />
    <meta property="og:image" content="image_2.png" />
    <meta property="og:url" content="https://www.title.org/quiz" />
    ...
</head>

<body>
    <script language="javascript" type="text/javascript">
        window.location.href = "https://www.styreskolen.org/quiz";
    </script>
</body>

所以如果我 post https://www.styreskolen.org/quiz/index.html 我应该得到新的元数据,但没有这样的运气。但是它确实可以在 Skype 上运行,所以 LinkedIn 似乎根本不在乎我做什么,只想看看我的根代码。

好的,最后我解决这个问题的方法是创建一个单独的存储桶,其中包含一个 Cloudfront 分布,它有自己的域名 www.quiz.title.org,它只包含一个 index.html 文件,将您重定向到 www.title.org/quiz 和我想要的元数据。