【发布时间】:2019-04-23 17:15:30
【问题描述】:
嘿,我遇到了一个问题,我有一个引入动态数据的博客页面,我想用这些数据来填充元标记,例如我正在做这样的事情
getBlogPost() {
this.http.get(...)
.subscribe(result => {
this.blogPost = result;
this.meta.updateTag({ name: 'description', content: this.blogPost.fields.metaDescription });
this.meta.updateTag({name: 'robots', content: 'INDEX, FOLLOW'});
this.title.setTitle(this.blogPost.fields.blogName);
this.meta.updateTag({name: 'twitter:image:src', content: this.blogPost.includes.Asset[0].fields.file.url });
this.meta.updateTag({name: 'twitter:title', content: this.blogPost.fields.blogName });
this.meta.updateTag({name: 'twitter:description', content: this.blogPost.fields.metaDescription });
this.meta.updateTag({property: 'og:title', content: this.blogPost.fields.blogName});
this.meta.updateTag({property: 'og:description', content: this.blogPost.fields.metaDescription});
this.meta.updateTag({property: 'og:image', content: this.blogPost.includes.Asset[0].fields.file.url });
this.meta.updateTag({property: 'og:image:secure_url', content: this.blogPost.includes.Asset[0].fields.file.url});
})
}
现在所有迹象都表明这应该可以工作,但是当我查看源代码时没有看到更新的元标记,当我检查 SEO 工具时也没有看到它们...
有解决办法吗?
提前致谢!!
【问题讨论】:
-
question 的答案可能会有所帮助。
标签: javascript angular typescript angular-universal