问题标签 [wintersmith]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
745 浏览

blogs - How can I have articles in Wintersmith not in their own subdirectory?

In Wintersmith, the default blog template generates posts from content/articles/<article>/index.md. This is fine as it allows associated files like images to be included with the article. But in practice, most "blog posts" are just text content associated with a template. Having to create subdirs is a minor annoyance, and if editing multiple entries in a tabbed editor, it's annoying having everything named index.md.

The site generator will spit out articles/basic-post.html files, but does not include these in the generated index or archive pages. How can I get the latter to work without breaking anything?

This may or may not be a simple problem, but I'm new to Wintersmith and haven't seen how to do this. I'm not sure it's as trivial as editing the default paginator (and I am not that used to CoffeeScript, which maybe it's time to address that :)

In paginator.coffee:

This looks like the place, however it seems like a bad idea to directly edit a plugin, for potential future updates to work.

Wintersmith is pretty awesome btw.

0 投票
1 回答
497 浏览

coffeescript - 如何自定义 Wintersmith 分页器?

我一直在与 Wintersmith 建立一个站点,并且大部分时间都喜欢它,但我无法理解一些引擎盖下的机制。我从添加 paginator.coffee 插件的“博客”框架开始。

这个问题需要一些细节,所以最重要的是,我想要完成的是:

  1. 任何文件(markdown、html、json 元数据)都将在 /contents/article/<file> 或 /contents/articles/<subdir>/<file> 中获取
  2. 输出文件位于 /articles/YYYY/MM/DD/title-slug/
  3. /blog.html 列出所有文章,分页。
  4. /contents 下的文件(不在文章中)不被视为博客文章。Markdown 和 JSON 元数据仍然被处理,但没有永久链接的 URL,不包含在博客列表中,文件/目录结构被更直接地复制过来。

所以,我用这个建议解决了#1:我怎样才能让 Wintersmith 中的文章不在他们自己的子目录中?到目前为止,很好,#3 正在工作——分页列表包括所有帖子。#4 不是问题,这是默认行为。

在#2我找到了这个解决方案:http ://andrewphilipclark.com/2013/11/08/removing-the-boilerplate-from-wintersmith-blog-posts/ 。正如作者所提到的,他的解决方案(某种程度上)随后被合并到 Wintersmith 大师中,所以我尝试相应地设置 filenameTemplate。不幸的是,这适用于所有内容,而不仅仅是 /articles 下的内容,所以我的网站的其余部分都被冲洗掉了(中断 #4)。于是我尝试了作者的方法,使用他的代码添加了一个 blogpost.coffee 插件。这会将 /contents/articles 中的所有文件生成正确的永久链接 URL,但是由于某种原因,分页器现在将不再直接看到 /articles 下的文件(第 1 点)。

我已经尝试了很多排列和黑客攻击。尝试更改首先加载哪个插件的顺序。尝试让 PaginatorPage 扩展 BlogpostPage 而不是 Page。尝试了很多东西。我终于意识到,即使在检查了 Wintersmith 源代码中的许多核心类之后,我也不明白发生了什么。

具体来说,我无法弄清楚 contents['articles']._.pages 和 .directories 是如何设置的,这似乎是相关的。我也不明白那个下划线是什么。

归根结底,Jade/CoffeeScript/Markdown 是一个很好的组合,可以最大限度地减少编码并提高清晰度,除了当您想了解幕后发生的事情并且您不了解这些语言时。我花了一点时间来了解 Jade 和 CoffeeScript 的基础知识(Markdown 当然是微不足道的),足以了解正在发生的事情。当我不得不深入挖掘 Wintersmith 的来源时,它变得更深了。我承认我也是一个 node.js 新手,但我认为这里的大问题只是一个神奇的框架。例如,如果一些核心“插件”包含在骨架站点中而不是埋在 node_modules 中,这将是有帮助的,这样好奇的黑客就可以更快地看到事物是如何相互连接的。更详细的文档当然也会有所帮助。从概念上理解内容树、生成器、视图、模板等是一回事,但理解运行时的代码流和关系?我迷路了。

任何帮助表示赞赏。正如我所说,我爱温特史密斯,只是希望我能解除魔法。

0 投票
2 回答
1155 浏览

pug - 使用循环限制文章数量

在我的索引页面上,我想给出两个单独的文章列表(顺便说一下,我不介意使用分页插件),并且我想列出每个“类别”中的最后 5 个。但我不知道如何在循环中计数。

我已经试过了

但这没有用。

0 投票
1 回答
686 浏览

static-site - 如何让 Wintersmith 在子目录中生成带有博客的静态站点?

我正在研究 Wintersmith 化我的网站,该网站目前是手写的。我有几个页面:、、、index.htmlprojects.htmlgpg.html我想要一个blog/子目录,以便最终站点如下所示:

这可能吗?我搜索并查看了 Wintersmith 文档(甚至是由 Wintersmith 提供支持的特色站点),但一无所获。似乎唯一的方法是拥有两个 Wintersmith 或其他东西的实例,但似乎必须有更好的方法。

0 投票
1 回答
61 浏览

wintersmith - 如何在 Wintersmith 预览输出中去除空格

有没有一种简单的方法可以从 Wintersmith 的预览和构建输出中删除所有 HTML 空白,而无需编写插件?

0 投票
2 回答
502 浏览

node.js - 向 Wintersmith-jade 内容文件添加扩展/块时出现“意外标识符”

我正在使用 Wintersmith 以及wintersmith-styluswintersmith-jade插件制作一个静态网站。

我想在帮助页面中添加一个特定的 CSS 文件。帮助页面基于“布局”模板。当我尝试使用块将样式表插入 html 头部时,我收到以下错误:

布局.jade

帮助.jade

即使我将extends和移动到block head包含 的元数据块的顶部template: layout.jade,我仍然会收到相同的错误。在我的情况下,删除extends ./layout.jade导致错误线位置从 40 移动到 5。

我的猜测是该错误是由 wintersmith-jade 插件引起的,但即使是这种情况,我也不知道如何修复它。

0 投票
0 回答
765 浏览

dynamic - jade dynamic includes work around

I'm working in a node/wintersmith/jade stack and am attempting to loop through a series of markdown files and pull out metadata to create dynamic file paths. I've read Use a variable in a Jade include and realize that dynamic includes isn't possible in Jade but I'm curious if anyone has found any work around, I don't feel like the answers presented in the other post are appropriate.

0 投票
1 回答
105 浏览

wintersmith - Wintersmith:两个分页部分

在我的 Wintersmith 构建的站点中,我想要:

  • index.html 包含新闻提要
  • 包含博客索引的 blog.html

我将 paginator.coffee 复制到 newspaginator.coffee 中,对其进行了调整以返回“新闻”而不是“文章”,并进行了一些其他调整,它工作正常。

然后我尝试重新添加原始分页器,并在 config.json 中使用一些参数:

现在:我只获得第二个插件的 HTML 页面。如上所述,我得到 blog.html 但没有 index.html。如果我颠倒这两个插件的顺序,我会得到 index.html 但没有 blog.html。

我怎样才能做到这两点?

0 投票
1 回答
107 浏览

wintersmith - Wintersmith:通过内容树中页面外的循环进行简单的元数据访问

我正在尝试遍历我的内容树并从各种降价文件中提取元数据。我看到了 Paginator 插件示例,但我觉得我的用例比 Paginator 所需的要简单得多。

如果我的内容目录结构如下所示:

我想遍历我的内容并检索所有“标题”元数据属性。如果我在玉中尝试一个简单的循环,例如:

我记录未定义。

我尝试将这种逻辑移动到一个简单的插件中,灵感来自 Paginator(用 js 编写):

虽然我能够在记录的对象中看到我的元数据,但我不完全确定如何从这里访问它。有没有更简单的方法可以像这样从内容树中提取元数据?任何帮助深表感谢!

0 投票
1 回答
66 浏览

node.js - 启用 Wintersmith 的摘录

我无法让 Wintersmith 在index页面上生成摘录。

我看到这个:

但我不确定要调整什么长度。我尝试了 1、100、-1,但似乎没有任何东西触发more.