10

假设我有这样的标记:

<ul id="comments">

  <li class="comment"> 
    <div class="author">on Friday 3th, Jenny said:</div>
    <div class="content"><p>bla bla</p></div> 
  </li>

  <li class="comment"> 
    <div class="author">on Friday 3th, Jenny said:</div>
    <div class="content"><p>bla bla</p></div> 

    <ul class="level-2">
      <li class="comment"> 
        <div class="author">on Friday 3th, Mary said:</div>
        <div class="content">stfu jenny</div> 
      </li>       
    </ul>
  </li>
  ...

如何在此标记上使用“UserComments”项? http://schema.org/UserComments

我在哪里添加itemscope itemtype="http://schema.org/UserComments"?一次在列表容器上,还是在每个列表项上多次?

4

4 回答 4

8

您不应该使用 itemprop="name",而应该使用“creator”。

更多示例... http://homebiss.blogspot.com/2011/11/schema-markups-blogger-comments.html

于 2012-10-25T16:07:21.633 回答
7

根据HTML5 Microdata typed items 规范,您可以将其添加到评论部分的容器中,例如

<section itemscope itemtype="http://example.org/animals#cat">
 <h1 itemprop="name">Hedral</h1>
 <p itemprop="desc">Hedral is a male american domestic
 shorthair, with a fluffy black fur with white paws and belly.</p>
 <img itemprop="img" src="hedral.jpeg" alt="" title="Hedral, age 18 months">
</section>

因此,您的评论部分的项目范围将采用如下格式(考虑项目属性):

<ul id="comments" itemscope itemtype="http://schema.org/UserComments">

  <li class="comment"> 
    <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>, Jenny said:</div>
    <div itemprop="commentText" class="content"><p>bla bla</p></div> 
  </li>

  <li class="comment"> 
    <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>, Jenny said:</div>
    <div itemprop="commentText" class="content"><p>bla bla</p></div> 

    <ul class="level-2">
      <li class="comment"> 
        <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>, Mary said:</div>
        <div itemprop="commentText" class="content">stfu jenny</div> 
      </li>       
    </ul>
  </li>
...
于 2012-01-14T13:00:42.373 回答
6

每个评论都是一个自己的项目(在您的示例中为 UserComments)。您可能还想article为每个评论使用一个元素。

<article itemscope itemtype="http://schema.org/UserComments">
  <header>
    on 
    <time itemprop="commentTime" datetime="…">Friday 3th</time>, 
    <span itemprop="creator" itemscope itemtype="http://schema.org/Person">
      <span itemprop="name">Jenny</span>
    </span> 
    said:
  </header>
  <p itemprop="commentText">bla bla</p>
</article>

但是,现在还有Comment,这似乎更合适,因为它是 CreativeWork(而不是 Event,如 UserComments)。

于 2014-04-03T15:29:07.997 回答
0

由于schema.org,最好使用userComments更改为Comment

UserInteraction 及其子类型是谈论用户与页面交互的一种古老方式。通常最好使用基于动作的词汇,以及诸如评论之类的类型。

但是你可以通过添加commentText属性和creator作为一个人来使用这个项目。

于 2019-06-13T13:53:28.727 回答