Hakyll网站的根源是什么? [英] What's the root of a Hakyll site?
问题描述
ghciλ> 我看到create函数需要一个标识符列表。 :t创建
create :: [Identifier] - >规则() - >规则()
我应该使用哪种标识符来匹配网站的根目录?例如,我只想制作出现在www.example.com上,没有/ posts或/ archives或任何其他域名部分的单个html页面。
我试过几个:
create/$ do
route id路由
编译$ pandocCompiler
>> = loadAndApplyTemplatetemplates / default.htmldefaultContext
>>> = relativizeUrls
和
create/ *$ do
route idRoute
编译$ pandocCompiler
>> = loadAndApplyTemplatetemplates / default.htmldefaultContext
>> = relativizeUrls
和
create。 $ do
route idRoute
compile $ pandocCompiler
>>> = loadAndApplyTemplatetemplates / default.htmldefaultContext
>> = relativizeUrls
和
create。 /$ do
route idRoute
compile $ pandocCompiler
>> = loadAndApplyTemplatetemplates / default.htmldefaultContext
>> = relativizeUrls
和
创建/。 $ do
route idRoute
compile $ pandocCompiler
>>> = loadAndApplyTemplatetemplates / default.htmldefaultContext
>> = relativizeUrls
和
创建 $ do
route idRoute
compile $ pandocCompiler
>>> = loadAndApplyTemplatetemplates / default.htmldefaultContext
>> = relativizeUrls
和
create Nothing $ do
route idRoute
compile $ pandocCompiler
>> = loadAndApplyTemplatetemplates / default.htmldefaultContext
>> = relativizeUrls
$ c
我得到如下错误:
site.hs:24:12:error:
•无法匹配类型'标识符'与字符''''
产生的'Char'
•在第一个参数'创造',即'''
在表达式中:create
在'do'块的标记中:
create
$ do {route idRoute;
编译
$ pandocCompiler
>> = loadAndApplyTemplatetemplates / default.htmldefaultContext
>> = relativizeUrls}
失败,模块加载:无。
从/ tmp / ghci29841 / ghci-script加载的GHCi配置
ghciλ> :i标识符
数据标识符
= Hakyll.Core.Identifier.Identifier {identifierVersion :: Maybe
String,
Hakyll.Core.Identifier.identifierPath :: String}
- 在'Hakyll.Core.Identifier'中定义
实例Eq标识符 - 在'Hakyll.Core.Identifier'中定义
实例Ord标识符 - 在'Hakyll.Core.Identifier'中定义
instance显示标识符 - 在'Hakyll.Core.Identifier'中定义
我应该使用什么魔法咒语用来创建出现/的html,我应该如何更好地调查这个问题才能让它更加神秘?
create
函数需要列表标识符
。对于单个元素的情况,只需用括号括起来( []
)。并且标识符
是 IsString
类的成员,所以假设您已经启用了 -XOverloadedStrings 你可以用一个普通的带引号的字符串文字(index.html
)来构建一个。
<所以要创建一个在根目录下提供的文件,你需要写:
create [index.html] $ do
route idRoute
compile $ pandocCompiler
>> = loadAndApplyTemplatetemplates / default.htmldefaultContext
>> = relativizeUrls
当没有显式文件名时请求路径时提醒(例如 http://www.example.com/
)返回文件 index.html
的内容(除非服务器配置在某些其他方式,但这是标准。)
I see the create function takes a list of Identifiers.
ghci λ> :t create
create :: [Identifier] -> Rules () -> Rules ()
What list of identifier should I use to match the root of the site? Eg, I just want to make a single html page that appears on "www.example.com" without "/posts" or "/archives" or any other domain parts.
I've tried a few:
create "/" $ do
route idRoute
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
and
create "/*" $ do
route idRoute
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
and
create "." $ do
route idRoute
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
and
create "./" $ do
route idRoute
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
and
create "/." $ do
route idRoute
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
and
create "" $ do
route idRoute
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
and
create Nothing $ do
route idRoute
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
I get errors like:
site.hs:24:12: error:
• Couldn't match type ‘Identifier’ with ‘Char’
arising from the literal ‘""’
• In the first argument of ‘create’, namely ‘""’
In the expression: create ""
In a stmt of a 'do' block:
create ""
$ do { route idRoute;
compile
$ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls }
Failed, modules loaded: none.
Loaded GHCi configuration from /tmp/ghci29841/ghci-script
I can't say :i Identifier
or reading documentation or reading the source code makes this any clearer for me:
ghci λ> :i Identifier
data Identifier
= Hakyll.Core.Identifier.Identifier {identifierVersion :: Maybe
String,
Hakyll.Core.Identifier.identifierPath :: String}
-- Defined in ‘Hakyll.Core.Identifier’
instance Eq Identifier -- Defined in ‘Hakyll.Core.Identifier’
instance Ord Identifier -- Defined in ‘Hakyll.Core.Identifier’
instance Show Identifier -- Defined in ‘Hakyll.Core.Identifier’
What magic incantation should I use to create html that will appear "/", and how should I have investigated this better to make it less mysterious?
解决方案 The create
function requires a list of Identifiers
. For the case of a single element, just surround it with brackets ([]
). And Identifier
is a member of the IsString
class so assuming you have enabled -XOverloadedStrings
you can build one with just a regular quoted string literal ("index.html"
).
So to create a file that is served at the root you would write:
create ["index.html"] $ do
route idRoute
compile $ pandocCompiler
>>= loadAndApplyTemplate "templates/default.html" defaultContext
>>= relativizeUrls
Reminder when a path is requested without an explicit file name (e.g. http://www.example.com/
) the contents of the file index.html
are returned (Unless the server is configured in some other way, but this is the standard.)
这篇关于Hakyll网站的根源是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!