0

私のドキュメントフォルダは以下のような構造です

index.html
post/
  post1.html
  post2.html
pages/
  about.html
  interior.html
  exterior.html
  gallery.html
  post.html //listing blog post
  contact.html
  interior/
    in1.html
    in2.html
    ...
    in5.html
  exterior/
    ex1.html
    ex2.html
    ...
    ex7.html
  gallery/
    img1,2,3,4

こんなマイメニュー構造

ホーム | 私たちについて | インテリア | 外観 | ギャラリー | 投稿 | コンタクト

ページ集をリストアップしてメニューを作ったらOK!

.navigation
nav
  ul.nav.topnav
    li.dropdown.active
      a(href='/')
        | Home
    each doc in getCollection('pages').toJSON()
      - clazz = (document.url === doc.url) ? 'active' : null
      li.dropdown(typeof="sioc:Page", about=doc.url, class=clazz)
        a(href=doc.url, property="dc:title")= doc.title

interior/exterior フォルダーからページを一覧表示して、Interior と Exterior のサブメニュー項目を追加するにはどうすればよいですか?

少し早いですがお礼を!

4

4 に答える 4

0

最上位ページlocationOfChildrenに、子ページがあるフォルダーへのパスとなるメタデータ タグを与えることができます。トップレベルのページ (たとえば、index.html) に子ページがない場合は、タグを定義したり値を指定したりしないでください。

locationOfChildrenが定義されている場合は、子ドキュメント リストのループを実行する if ステートメントを追加できます。

.navigation
  nav
    ul.nav.topnav
      li.dropdown.active
        a(href='/')
          | Home
      each doc in getCollection('pages').toJSON()
        - clazz = (document.url === doc.url) ? 'active' : null
        li.dropdown(typeof="sioc:Page", about=doc.url, class=clazz)
          a(href=doc.url)= doc.title
          if doc.locationOfChildren
            ul.dropdown
              each childDoc in getFilesAtPath(doc.locationOfChildren).toJSON()
                - clazz = (document.url === childDoc.url) ? 'active' : null
                li.dropdown(typeof="sioc:Page", about=childDoc.url, class=clazz)
                  a(href=childDoc.url)= childDoc.title

ページをアルファベット順にソートしたくない場合はnavOrder、各ページのメタデータにタグを追加して、整数値を割り当てることができます。両方のクエリ文字列 (getCollection と getFilesAtPath) で.findAllLive({isPage:true},[{navigationOrder:1}])、メソッドの前に追加すると、準備完了.toJSON()です。

元: getFilesAtPath(doc.locationOfChildren).findAllLive({isPage:true},[{navOrder:1}]).toJSON()

于 2014-04-12T09:58:32.290 に答える
0

You could flag according docs in their respective YAML, e.g.

---
submenu: interior
title: in1
---

and use that to render from a matching collection in your nav or else like e.g.

<ul>
<% for entry in @getCollection("html").findAllLive({submenu: interior}).toJSON(): %>    
   <li><%= entry.title %></li>
<% end %>
</ul>

To use the matching folder instead of YAML you'd change the query from submenu: interior to relativeOutDirPath: /interior/

于 2013-10-02T08:07:15.673 に答える
0

これはこれを処理する非効率的な方法かもしれませんが、これは私がこれまでにこのようなもの (CoffeeKup + Bootstrap) について考え出したことです:

  li class: "dropdown", ->
    a href: "#", class: "dropdown-toggle", "data-toggle": "dropdown", ->
      text "API"
      b class: "caret"
    ul class: "dropdown-menu", ->
      for file in @getFilesAtPath("api").toJSON()
        li ->
          if @document.relativeOutDirPath == "."
            a href: file.relativeOutPath, file.title
          else
            a href: "../" + file.relativeOutPath, file.title

その部分に注目してください@getFilesAtPath("api").toJSON()。「/api」というフォルダーがあり、ファイルが含まれています。このタイプの構造を使用して、<li>そのフォルダー内の各ファイルのそれぞれのタグ。

もちろん、これを使用して、作成するフォルダーごとにこれらのものをもう 1 つ作成する必要があります (ディレクトリ名をループする方法が見つかりませんでした)。

本当のゴミが飛び交い始めます (そして、これにはもっと良い攻撃があるかもしれません)、それは<li>タグそのものです。index.htmlページまたはサブフォルダーにいるかどうかを確認する必要がある if ステートメントに注意してください。次に"../"、ファイルのパスに追加する必要があります。検索してきましたが、単純な@document.pathToRootスタイル属性はまだ見つかりません。

于 2013-09-18T14:37:52.827 に答える