2013-08-01 85 views
1

编辑为清晰度:Middleman输出路径

我想知道是否有可能设置文件的输出路径在Middleman构建。为了组织的目的,我想将一种类型的页面分组到一个文件夹中,以使其不在主源目录中。然而构建/服务器上,我想它呈现到不同的路径:

/source 
    index.html 
    /landingpages 
     landingpage1.html 
     landingpage2.html 

我有:directory_indexes在我的配置文件中启用希望能够有文件landingpage输出到根目录下:

/build 
    index.html 
    /landingpage1 
     index.html 
    /landingpage2 
     index.html 

这是可能的,以某种方式使用config.rb文件,并仍然显示正确的站点地图?我宁愿没有做到这一点使用的.htaccess

感谢

+0

为什么不'.htaccess'? – Shoe

回答

2

我在当前项目中使用的一种技术是根据各地的代理,也应该解决您的情况:

landingpage_templates = Dir['source/landingpages/*.html'] 

landingpage_templates.map! do |tpl_name| 
    tpl_name = File.basename(tpl_name).gsub(/.html$/, '') 
    proxy "/#{tpl_name}/index.html", "/landingpages/#{tpl_name}.html", :ignore => true 
end 
+0

这工作完美。我只是拿掉了:忽略部分,因为我想让它们索引。非常感谢! – SkyOut

+0

不客气。很高兴有这样的记录,例如这里在这么:) –

0

你应该能够做这样的事情:

page "/file1/index.html", :proxy => "/somefolder/file1.html" 
page "/file2/index.html", :proxy => "/somefolder/file2.html" 

我想你最好using directory indexes代替,但并组织您的文件,如:

/source 
    index.html 
    file1.html 
    file2.html 

在你config.rb

activate :directory_indexes 
+0

这不适用于单个文件,我需要将整个目录重定向。 – SkyOut

+0

您需要提供更多关于您想要实现的信息。你能给你更多的背景问题吗? – jordelver

+0

更新了问题以澄清 – SkyOut