Giter Club home page Giter Club logo

lume's People

Contributors

adb-sh avatar aiotter avatar bglw avatar bryophyta avatar cawa-93 avatar ewired avatar fserb avatar imjamesb avatar jerluc avatar jrson83 avatar kidonng avatar kuboon avatar kwaa avatar laura-rubio avatar levirs565 avatar marcosantonastasi avatar naiyerasif avatar ngdangtu-vn avatar not-my-profile avatar officialrajdeepsingh avatar oscarotero avatar paulrobertlloyd avatar pluiedev avatar probins avatar scarf005 avatar shadowtime2000 avatar tobiasschmidt89 avatar tristanisham avatar valtlai avatar wangbinyq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lume's Issues

Changes in Pug layout files not updating (with `lume --serve`)

Example:

//- _layout.pug

html.no-js(lang="en")
   head
      meta(charset='utf-8')
   body
      div A message from `_layout.pug`
      block pageContent


//- home.pug

extends _layout.pug
block pageContent
   h1 Home

Making a change in home.pug triggers an update. Making a change in _layout.pug does not trigger an update.

When making a change in _layout.pug, the cli does say "Changes detected. Building... Done", but the browser does not reload and Lume doesn't seem to actually rebuild (manually reloading the browser does not show the update).

Date format does not behave as expected (off by one day)

I have a template with the date specified as e.g., 2021-04-08.

I would expect this formatting:

post.data.date | date('PPP')

To return:

April 8th, 2021

However, it returns:

April 7th, 2021

If I format with the ATOM format, I can see that the issue seems to be related to stripping off the timezone, or something.

post.data.date | date(`ATOM')
=> "2021-04-07T20:00:00-04:00"

(I'm in GMT-4)

Multi-command scripts

I've been trying out the script runner. I have what's probably a common setup, where I convert md files to html, and then want to run other scripts to create other parts of the site. So the script looks something like:

mkdir newdir
cd newdir/
deno run xxx

I put this in a separate .sh file, which works fine. But I would prefer to include this in the Lume config file, and I can't find a way to do this. If I put the cmds in one line separated by ;, then it makes dirs called newdir;, cd, etc. The same with separating the cmds with &&. I also tried using the sequential option, but it looks like it tries to cd before mkdir has completed, so that doesn't work either.

Any ideas?

How should `search.pages("foo,bar")` work?

Should search.pages("foo,bar") find the pages having both a foo and bar tag (like tags&=foo,bar) or the pages having a foo,bar tag (like tags*=foo,bar)? The latter is the current behavior.

Outputting extensionless file (like `_headers`) from template

I would like to dynamically generate a _headers file to configure HTTP headers for Netlify. (And I’m going to do something similar with _redirects too.)

There’s no way to output a file named _headers from a template (i.e. without using site.copy()). Setting slugifyUrls: false in the config file and url: /_headers in a front matter results a file _headers/index.html (or _headers.html if prettyUrls: false).

The problem is that the _headers file has no file extension and Lume adds .html for missing one.

Should we stop adding the extension and only add index.html if url has a trailing slash? Then url: /foo would output /foo and url: /foo/ would output /foo/index.html. Or should there be an option (such as forceExtensions: false) for this behavior?

Replace denopkg?

I see you're using denopkg to load your fork of denjucks. I'd suggest using https://www.jsdelivr.com/ instead, as it caches and serves via cdn, which will be more efficient than simply downloading the raw source files from Github as denopkg does. (I tend to use statically.io, as it also handles GitLab as well as Github, but jsdelivr is well-established.)

Using `site.copy()` with glob

I have a directory with both .svg and other files. I would like to copy the files with site.copy("./assets"), but then the .svg files inside are copied without going through the plugin. If site.copy() would support globs, I could do site.copy("./assets/**/*.!(svg)") to copy all but the .svg files in the directory.

If this gets implemented, maybe site.ignore() should support globs too.

Configuring `markdown-it`

It should be possible to configure markdown-it, for example, to add plugins or to modify renderers.

Maybe something like:

import lume from "https://deno.land/x/lume/mod.js";
import markdown from "https://deno.land/x/lume/plugins/markdown.js";
import markdownItContainer from "https://jspm.dev/markdown-it-container";
  
const site = lume();

site.use(markdown({
  modify (md) {
    // Add a markdown-it plugin
    md.use(markdownItContainer);

    // Customize a renderer
    md.renderer.rules.link_open = (tokens, idx, options, env, self) => {
	// ...
    };
  }
}));

export default site;

index.pug file changes not being written on index.html in --serve mode

I have this folder structure:

_dist
_includes
	head.pug
config.js
index.pug
pug.pug

I noticed that changes made to the pug.pug file are detected and also written on _dest/pug/index.html, while changes made to index.pug file are detected, but not actually written on _dest/index.html file

_config.js:

import lume from "https://deno.land/x/[email protected]/mod.js";
import pug from "https://deno.land/x/lume/plugins/pug.js";

const site = lume({
    dest: "_dist",
    prettyurls: true,
  });
site.use(pug());

export default site;

index.pug:

//- index.pug
doctype html
html
  include _includes/head.pug
  body
    h1 My Site!
    p Welcome to my super lame site!

pug.pug:

//- pug.pug
doctype html
html
  include _includes/head.pug
  body
    h1 Pug

_includes/head.pug

head
    title Hello Pug

P.S.
I noticed everything works just fine if the index is a markdown file, the problem gets out only on index.pug file

The `svgo` dependancy (for the `svg` plugin) is causing `lume` to fail

lume isn't working today for some reason. It seems the svgo dependency is to blame.

This is what happens when I try to use lume...

$ lume
Download https://jspm.dev/svgo/plugins/convertEllipseToCircle.js
Download https://jspm.dev/svgo/plugins/removeUnknownsAndDefaults.js
Download https://jspm.dev/svgo/plugins/collapseGroups.js
Download https://jspm.dev/svgo/plugins/convertShapeToPath.js
Download https://jspm.dev/svgo/plugins/convertColors.js
Download https://jspm.dev/svgo/plugins/removeEmptyText.js
Download https://jspm.dev/svgo/plugins/cleanupAttrs.js
Download https://jspm.dev/svgo/plugins/removeDesc.js
Download https://jspm.dev/svgo/plugins/cleanupNumericValues.js
Download https://jspm.dev/svgo/plugins/removeMetadata.js
Download https://jspm.dev/svgo/plugins/minifyStyles.js
Download https://jspm.dev/svgo/plugins/removeHiddenElems.js
Download https://jspm.dev/svgo/plugins/removeUselessDefs.js
Download https://jspm.dev/svgo/plugins/mergePaths.js
Download https://jspm.dev/svgo/plugins/inlineStyles.js
Download https://jspm.dev/svgo/plugins/cleanupEnableBackground.js
Download https://jspm.dev/svgo/plugins/removeUnusedNS.js
Download https://jspm.dev/svgo/plugins/removeXMLProcInst.js
Download https://jspm.dev/svgo/plugins/removeTitle.js
Download https://jspm.dev/svgo/plugins/removeEmptyContainers.js
Download https://jspm.dev/svgo/plugins/removeUselessStrokeAndFill.js
Download https://jspm.dev/svgo/plugins/removeEditorsNSData.js
Download https://jspm.dev/svgo/plugins/removeEmptyAttrs.js
Download https://jspm.dev/svgo/plugins/removeViewBox.js
Download https://jspm.dev/svgo/plugins/removeNonInheritableGroupAttrs.js
Download https://jspm.dev/svgo/plugins/moveGroupAttrsToElems.js
Download https://jspm.dev/svgo/plugins/sortAttrs.js
Download https://jspm.dev/svgo/plugins/sortDefsChildren.js
Download https://jspm.dev/svgo/plugins/removeDoctype.js
Download https://jspm.dev/svgo/plugins/cleanupIDs.js
Download https://jspm.dev/svgo/plugins/moveElemsAttrsToGroup.js
Download https://jspm.dev/npm:css-tree@1/dist/csstree.min.js!cjs
lume: Import 'https://jspm.dev/svgo/plugins/convertEllipseToCircle.js' failed: 404 Not Found
    at https://deno.land/x/[email protected]/deps/svgo.js:34:0
TypeError: Import 'https://jspm.dev/svgo/plugins/convertEllipseToCircle.js' failed: 404 Not Found
    at https://deno.land/x/[email protected]/deps/svgo.js:34:0
    at async buildSite (https://deno.land/x/[email protected]/cli/utils.js:15:19)
    at async Module.run (https://deno.land/x/[email protected]/cli/build.js:44:16)
    at async maybeRun (https://deno.land/x/[email protected]/cli.js:109:28)
    at async cli (https://deno.land/x/[email protected]/cli.js:117:5)
    at async https://deno.land/x/[email protected]/cli.js:56:5
$ lume
Download https://jspm.dev/svgo/plugins/convertColors.js
Download https://jspm.dev/svgo/plugins/removeNonInheritableGroupAttrs.js
Download https://jspm.dev/svgo/plugins/removeViewBox.js
Download https://jspm.dev/svgo/plugins/removeUnusedNS.js
Download https://jspm.dev/svgo/plugins/cleanupNumericValues.js
Download https://jspm.dev/svgo/plugins/collapseGroups.js
Download https://jspm.dev/svgo/plugins/removeTitle.js
Download https://jspm.dev/svgo/plugins/removeMetadata.js
Download https://jspm.dev/svgo/plugins/cleanupIDs.js
Download https://jspm.dev/svgo/plugins/mergePaths.js
Download https://jspm.dev/svgo/plugins/removeDesc.js
Download https://jspm.dev/svgo/plugins/removeHiddenElems.js
Download https://jspm.dev/svgo/plugins/cleanupAttrs.js
Download https://jspm.dev/svgo/plugins/removeDoctype.js
Download https://jspm.dev/svgo/plugins/convertEllipseToCircle.js
Download https://jspm.dev/svgo/plugins/removeEditorsNSData.js
Download https://jspm.dev/svgo/plugins/sortDefsChildren.js
Download https://jspm.dev/svgo/plugins/removeUnknownsAndDefaults.js
Download https://jspm.dev/svgo/plugins/convertShapeToPath.js
Download https://jspm.dev/svgo/plugins/removeEmptyAttrs.js
Download https://jspm.dev/svgo/plugins/removeEmptyContainers.js
Download https://jspm.dev/svgo/plugins/minifyStyles.js
Download https://jspm.dev/svgo/plugins/removeXMLProcInst.js
Download https://jspm.dev/svgo/plugins/inlineStyles.js
Download https://jspm.dev/svgo/plugins/sortAttrs.js
Download https://jspm.dev/svgo/plugins/removeUselessStrokeAndFill.js
Download https://jspm.dev/svgo/plugins/moveElemsAttrsToGroup.js
Download https://jspm.dev/svgo/plugins/moveGroupAttrsToElems.js
Download https://jspm.dev/svgo/plugins/cleanupEnableBackground.js
Download https://jspm.dev/svgo/plugins/removeUselessDefs.js
Download https://jspm.dev/svgo/plugins/removeEmptyText.js
Download https://jspm.dev/npm:css-tree@1/dist/csstree.min.js!cjs
lume: Import 'https://jspm.dev/svgo/plugins/convertColors.js' failed: 404 Not Found
    at https://deno.land/x/[email protected]/deps/svgo.js:20:0
TypeError: Import 'https://jspm.dev/svgo/plugins/convertColors.js' failed: 404 Not Found
    at https://deno.land/x/[email protected]/deps/svgo.js:20:0
    at async buildSite (https://deno.land/x/[email protected]/cli/utils.js:15:19)
    at async Module.run (https://deno.land/x/[email protected]/cli/build.js:44:16)
    at async maybeRun (https://deno.land/x/[email protected]/cli.js:109:28)
    at async cli (https://deno.land/x/[email protected]/cli.js:117:5)
    at async https://deno.land/x/[email protected]/cli.js:56:5
$ lume
Download https://jspm.dev/svgo/plugins/moveElemsAttrsToGroup.js
Download https://jspm.dev/svgo/plugins/convertEllipseToCircle.js
Download https://jspm.dev/svgo/plugins/cleanupEnableBackground.js
Download https://jspm.dev/svgo/plugins/removeEmptyText.js
Download https://jspm.dev/svgo/plugins/inlineStyles.js
Download https://jspm.dev/svgo/plugins/removeXMLProcInst.js
Download https://jspm.dev/svgo/plugins/removeUselessDefs.js
Download https://jspm.dev/svgo/plugins/removeEmptyContainers.js
Download https://jspm.dev/svgo/plugins/minifyStyles.js
Download https://jspm.dev/svgo/plugins/convertColors.js
Download https://jspm.dev/svgo/plugins/removeMetadata.js
Download https://jspm.dev/svgo/plugins/collapseGroups.js
Download https://jspm.dev/svgo/plugins/mergePaths.js
Download https://jspm.dev/svgo/plugins/removeEditorsNSData.js
Download https://jspm.dev/svgo/plugins/cleanupAttrs.js
Download https://jspm.dev/svgo/plugins/convertShapeToPath.js
Download https://jspm.dev/svgo/plugins/removeTitle.js
Download https://jspm.dev/svgo/plugins/sortDefsChildren.js
Download https://jspm.dev/svgo/plugins/cleanupNumericValues.js
Download https://jspm.dev/svgo/plugins/removeEmptyAttrs.js
Download https://jspm.dev/svgo/plugins/removeViewBox.js
Download https://jspm.dev/svgo/plugins/removeNonInheritableGroupAttrs.js
Download https://jspm.dev/svgo/plugins/removeUnusedNS.js
Download https://jspm.dev/svgo/plugins/cleanupIDs.js
Download https://jspm.dev/svgo/plugins/removeHiddenElems.js
Download https://jspm.dev/svgo/plugins/removeUnknownsAndDefaults.js
Download https://jspm.dev/svgo/plugins/removeUselessStrokeAndFill.js
Download https://jspm.dev/svgo/plugins/removeDoctype.js
Download https://jspm.dev/svgo/plugins/removeDesc.js
Download https://jspm.dev/svgo/plugins/sortAttrs.js
Download https://jspm.dev/svgo/plugins/moveGroupAttrsToElems.js
Download https://jspm.dev/npm:css-tree@1/dist/csstree.min.js!cjs
lume: Import 'https://jspm.dev/svgo/plugins/moveElemsAttrsToGroup.js' failed: 404 Not Found
    at https://deno.land/x/[email protected]/deps/svgo.js:29:0
TypeError: Import 'https://jspm.dev/svgo/plugins/moveElemsAttrsToGroup.js' failed: 404 Not Found
    at https://deno.land/x/[email protected]/deps/svgo.js:29:0
    at async buildSite (https://deno.land/x/[email protected]/cli/utils.js:15:19)
    at async Module.run (https://deno.land/x/[email protected]/cli/build.js:44:16)
    at async maybeRun (https://deno.land/x/[email protected]/cli.js:109:28)
    at async cli (https://deno.land/x/[email protected]/cli.js:117:5)
    at async https://deno.land/x/[email protected]/cli.js:56:5

Move slugifyUrls to a plugin

The url slugification can be done with a preprocessor, and a plugin brings more flexibility and simplify the core of Lume.

Refactor CLI to use "commands"

First, this project is great. Keep up the good work.

This is a proposal for a redesign of the CLI interface. I'd be happy to put in a PR for if it seems like a good thing to do.

A Proposal

Redesign the CLI interface to use "commands" instead of options.

$ lume --help

  🔥lume v0.14.0
  A static site generator for Deno

  Docs:

    https://lumeland.github.io

  Usage:

    lume [OPTIONS] COMMAND

  Options:

    -h, --help     - Show this help.
    -V, --version  - Show the version number for this program.

  Commands:

    build [config]  - build the site
    init            - create a _config.js file for a new site
    serve           - Build the site and start a web server that refreshes automatically for every change
    upgrade         - Upgrade local lume install to the latest version
    update          - Update the lume version imported in _config.js to the latest

Each command would have its own --help output as well, specifying the relevant options for that command


If this looks like a good direction for lume I can get a PR ready sometime this week

Terser processor/plugin

Following the discussion in other issues, I've created a _config.js to run all js files through the Terser minifier:

import lume from "https://deno.land/x/lume/mod.js";
import textLoader from "https://deno.land/x/lume/loaders/text.js";
import "https://cdn.jsdelivr.net/npm/terser/dist/bundle.min.js";

const site = lume({
  src: "lib",
  dest: "outlib",
  prettyUrls: false
});

site.loadAssets([".js"], textLoader);
site.process([".js"], processor);

async function processor (file) {
  let content = file.content;

  let opts = {
    module: true,
    compress: true,
    mangle: true
  };

  let output = await globalThis.Terser.minify(content, opts);

  file.content = output.code;
}

export default site;

I've not thorougly tested the output yet, but in principle it works well. It's not a 'static site' in the traditional sense, but is using Lume as a file processor to minify all files in lib/ into outlib/. Like Denopack, it imports the browser version of Terser, which creates the Terser global. Specifying globalThis is not strictly necessary, but makes it clear where this Terser reference is coming from.

So, I can either document this as an example of what can be done, or create a processor and/or plugin for general use. Another issue mentions passing options to plugins, and this would also be useful here, for example, whether to generate sourcemaps (the appropriate module would have to be imported to support this, of course).

Updating post content with lume --serve generate incomplete index.html

Hello, I don't think this is the expected behavior, when updating a post while lume --serve is running, the index.html generated for the article is missing the whole template. I can reproduce this with the base-blog.

Steps to reproduce:

  1. run lume --serve
  2. Go to http://localhost:3000
  3. Click on a post
  4. Edit the .md for that post
  5. Reload the browser window
  6. => The file contains only the html of the article without the template/layout html
2021-03-05.23-21-16_Trim.mp4

Anyway, lume is still awesome 🚀🦕

Outward Facing Types

Deno has builtin Typescript support so I was a little surprised to see this written in JS. I can understand not wanting to use Typescript, but I think this should have files like the plugins and the site written in typescript so people can use ts if they want it without writing there own types. We could then keep the internals of it written in JS. I could do this.

update matches different ignore file than build

if you have a example.njk file and a site.ignore('example').

lume build will build example.njk correctly.

But if you run lume build --serve, it will detect the change, but not rebuild the file, because it will match the ignored list.

Image processing plugin

It would be nice to have a plugin that can take a source image and output various optimized formats, leveraging srcset and the like to enable responsive images.

As far as I can tell, this is blocked by lovell/sharp#2583 which is blocked by upstream Deno support.

Allowing empty front matter?

Should we allow the front matter to be empty (or whitespace-only)?

For example:

---
---

Content

or

---

---

Content

Bug: nunjucks not respecting filename case

0.16.0 introduced a file-naming bug. Up until 0.15.4, a file called myFile.js.njk would be correctly transformed into myFile.js, but since 0.16.0 is transformed into myfile.js. I assume this is linked to the 'slugifier' introduced in 0.16.0

Nunjucks for js files

In #11, I mentioned being able to use templates with js files, so I can for example populate an array from shared data. You can do this In Jekyll (and can define layout: null for non-html files). I hoped that if I specified a _data.json with templateEngine: njk it would work, but it ignores the directory. If I rename the js file to *.njk, then it creates an output html, but doesn't parse the templates.

In the particular case I'm working on, I can get around this by including the js in the html file, but that's not very efficient if I have several html pages that use the same js.

async filters

Nunjucks allows to use async filters but they need to be specified on register:

env.addFilter(name, func, [async])

So, we need to add this argument to lume, with site.filter(name, func, [async]) and check if it works fine.

Suggestion: use Github releases

Main advantage: I get a Github notification when there's a new release, but I don't get one if commits/tags are pushed to the repo. Doesn't have to say very much; can just refer to the Changelog.

Performance observability

As you start your TypeScript journey (or even before!) I suggest adding some observability across all the major pipeline steps. For example, if I have 100 pages being generated but 5 of them take 95% of time to generate, we should be able to see that when the pages are being tracked. For large sites some parts of site take much longer to generate so the developer should be responsible for caching those pages but she'd need to be told which ones they are.

Something like this?

🔥 Deno prepare (900ms)
🔥 /images /images (copy: 25ms)
🔥 /index.html /index.tmpl.ts (load: 1025ms, render: 255ms, process: 190ms, etc: ??)
🔥 /styles.css /styles.css (??)

🍾 Site built into ./_site (1255ms)

It would be good to build OpenTelemetry and OpenMetrics (Prometheus) into Lume so that large sites can fine tune performance through observability.

Nunjucks in md files

I'm converting an old Jekyll site to Lume, and one issue I'm running into is that the md files contain {{ ... }}, but it looks like these are not being parsed. https://lumeland.github.io/plugins/nunjucks/ says "just place the .njk or .html file outside the _includes folder", but in my case these are .md files, not .html. I tried a simple test with a layout which includes an md file with {{ content | safe }}: if I put {{ myData }} in the layout file, it is parsed correctly, but if I put it in the md file, it is included unparsed in the output html. Is this intentional, or a bug of some sort? Or do I have to define something else to get the Nunjucks variables in md files parsed?

Benchmarks

It would be great to see some build time benchmarks compared to popular SSGs such as Jekyll and 11ty. @probins did share the speed increase in his sites build time compared to Jeykll.

Broken pipe (os error 32)

Occasionally while making some changes the dev server will response with Changes couldn't be sent to browser due "Broken pipe (os error 32)"

njk filter returns empty if there's another async filter

here's the case.
If you have a config: site.filter('x', async () => "hello", true);
and a page A that uses {{ x }}.

If you need to render content from page A into page B: {{ A.page.content }} (pre rendered content) will work. But {{ A.page.content | njk }} will return empty.

This is useful to render content of RSS feeds, where you don't want A.content (the full rendered page) but still want to resolve the templates.

I think the problem is that the njk plugin/filter should either assume it's async by default or have an option to become so.

Make `url` settable and replace `permalink` with it

Pages already have the url property, so if we could make it settable, the permalink property could be removed in favor of it. I think it would be nice if the getter (currently url) and setter (currently permalink) had a same name. Also that’s how date works.

This would be a breaking change, but we’re at v0.x so maybe it doesn’t matter. However, we can always make permalink an alias of url and possibly remove that later.

Allow Options Passed to Template Engine Plugins

I see that every plugin is a closure that takes no arguments. I was wondering if we could option it up to have options passed to them for template engines and such so users can configure stuff.

Compilation of Layouts for Faster Builds

Many template engines (like Eta) support compilation of a template into a function which can make it faster. What if we allowed compilation with layouts to allow faster builds? Some template engines don't support this, so we could still keep the run every time rendering open as an option.

new filters

There are some filters that I'd like to add to lume:

  • inline: to inline content in the html (css, javascript, svg, etc). Example:
<style>
    {{ "/css/my-styles.css" | inline | safe }}
</style>

This will return the content of the css file.

  • css: The css plugin could register the css filter, so we can not only inline css but also transform it:
<style>
    {{ "/css/my-styles.css" | inline | css | safe }}
</style>
  • bundle: We can do the same with the bundler plugin, to transform javascript/typescript.
  • svg: We can do the same with the svg plugin, to transform svg.

Error on install: unable to parse import map JSON

I have deno 1.10.3 installed and working properly with other modules. I'm trying to install Lume, so I run the standard installation command:

deno run -A https://deno.land/x/lume/install.js

After deno finishes downloading the files, I get this error:

error: Unable to parse import map JSON
  • I've tried re-installing deno.
  • I've installed other packages that use import_map.json with no problems.
  • Being new to deno, I'm not sure how to troubleshoot from here.

How to generate output in same directory structure as src?

I'm wanting to convert a simple metalsmith site to run on deno, and Lume looks like a reasonable fit. One thing I'm stuck on is the structure of the output site. I want to convert src/abc.md to site/abc.html and src/xyz.md to site/xyz.html, but it puts each src file in its own directory, which I don't want. I tried using the permalink variable, but this makes no difference. Seems to be in site.js but I can't see any way to define this.

Url as function throws error in shared data file

I'm trying to use a url as function for pages in a certain directory (as shown in the example here).

This is the code in my _data.js file.

export const type = "shoot";
export const layout = "layouts/shoot.njk";

export function url(page) {
  return `./${page.data.title}/`
}

This is giving me the error shown below.

Error: The url variable must start with "/", "./" or "../"      
page: \shoots\good-boy-plays-with-toy.md
url: ./Good Boy plays with toy/

I have been using the slugifyUrls plugin, but enabling/disabling it did not resolve the error. It only happens when using the url as function export from _data.js in that folder

Tags don't propagate on layouts

I'm not sure if this is a feature request or a bug.

if you have:

_include/mylayout.njk

---
tags: mytag
---

page.njk

---
layout: mylayout.njk
---

Then I'd expect that page.njk would be part of mytag. Other data seems to propagate properly, but tags seem to be ignored. When used like this:

---
renderOrder: 1
---
{%- for post in search.pages('mytag') -%}

Pug support

Would love to test out and use lume, but not without it supporting Pug (the thought of writing actual HTML after using Pug makes me shiver).

Is this currently possible?

Relative URLs to root of project

I have a site (same data) that will be served from multiple locations. Therefore, it's not great to use absolute URLs there.

The problem is: I'm trying to generate a page data that points to the root, so I can, for example have a link pointing to: {{ root }}/assets/x.png that correctly resolves for all internal pages, no matter how deep their URLs is.

I was able to do something like this with:

site.data("rootPath", function() {
  return this.ctx.url.split('/').filter(x => x).map(_ => '..').join('/') || '.';
});

that mostly solves my problem but:

  1. I didn't see any documentation on this.ctx and I'm worried this will break in the future. Should we make site.data() callbacks receives a context?

  2. I know there's site.process plugins, but it would be great if there was a plugin mechanism to transform the data before rendering, so something like this could also be implemented.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.