如何解决幽灵博客检查用户是否登录并嵌入博客文章
我正在将一些 html 嵌入到我的博客文章中。 如果用户未登录,我只想显示它。 如何将这个 html 区域包装在 if 语句中以检查用户是否已登录。
{{#if access}}
<p>Thanks for being a member...</p>
{{else}}
<p>You need to become a member in order to read this post... </p>
{{/if}}
或
{{#if @member}}
<p>Thanks for becoming a member ?</p>
{{else}}
<p>You should totally sign up... ?</p>
{{/if}}
如何将其放入 html 卡片中?
解决方法
如果您只想显示访问消息,那么第一个是正确的选项。但是,如果您想将帖子如何订阅会员,那么这是正确的格式。
{{#if access}}
{{!-- if the user has access to this post,show it to them --}
<section>
<div>
{{content}}
</div>
</section>
{{else}}
{{!-- if the user does not have access,show them an upgrade CTA --}}
<p>You don't have access to this post on <strong>{{@site.title}}</strong> at the moment,but if you upgrade your account you'll be able to see the whole thing,as well as all the other posts in the archive! Subscribing only takes a few seconds and will give you immediate access.</p>
{{/if}}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。