首页 > 解决方案 > 试图从 metalsmith-simple-search 中排除特定文件

问题描述

我正在尝试使用 match 属性从 metalsmith-simple-search 中排除 2 个特定页面。例子:

.use(simpleSearch({
    "destinationJs": "./assets/js/simple-search.min.js",
    "destinationJson": "./assets/js/search.json",
    "index": {
        "title": true,
        "keywords": true,
        "description": true,
        "contents": "html"
    },
    //"match": "**/*.{htm,html}",
    "match": "!(error-404|search)**/*.{htm,html}", 
    "matchOptions": {},
    "skipSearchJs": false
}))

默认"**/*.{htm,html}"匹配网站上的每个页面,但我不想包含自定义 404 页面或搜索页面本身。

// example file directory
index.html                               // homepage should include
error-404/index.html                     // exclude  
our-services/index.html                  // include
our-services/business/index.html         // include
search/index.html                        // exclude

我的修改"!(error-404|search)**/*.{htm,html}"删除了不需要的页面,但也删除了网站的主页。我所有恢复主页的尝试都没有添加错误 404 和搜索,但都失败了。

有没有人足够熟悉这里的模式如何匹配来帮助我?

标签: globmetalsmith

解决方案


推荐阅读