question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`page.data.url` disappears when `page.addData` is called

See original GitHub issue

Description of the bug

When you set processor or preprocessor to call page.addData, page.data.url will be lost.

Reproduction procedure

  1. Create index.md at the root directory of the project.
  2. Create _config.ts as following:
import lume from "lume/mod.ts";
import { Page, Site } from "lume/core.ts";

const site = lume();

site.use((site: Site) => site.process([".html"], (page: Page) => page.addData({ foo: "bar" })));
// OR: site.use((site: Site) => site.preprocess([".html"], (page: Page) => page.addData({ foo: "bar" })));

site.use((site: Site) => site.addEventListener("afterBuild", () => site.pages.forEach((page) => console.log(page.data))));

export default site;
  1. You’ll get the following result:
{ tags: [], content: "index\n", date: 2022-01-10T09:35:35.019Z, foo: "bar" }

Commenting out the processor registration, or passing a function with no side effect as a processor will create the desired output:

{ tags: [], content: "index\n", date: 2022-01-10T09:35:35.019Z, url: "/" }

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
oscaroterocommented, Jan 10, 2022

It’s public because it’s used by an external class the Source class but prepending with _ is a good idea.

0reactions
aiottercommented, Jan 30, 2022

Nice work! Thanks 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Appended content disappears after the change of URL
I am hoping for this behaviour - somewhere on the page there is a div, after clicking #button , the content changes and...
Read more >
Data URLs - HTTP - MDN Web Docs - Mozilla
Data URLs, URLs prefixed with the data: scheme, allow content creators to embed small files inline in documents. They were formerly known as ......
Read more >
Printer option disappears when printer is selected in AutoCAD
When selecting a printer name from the plot dialog box drop-down, the printer name disappears. The option reverts to "none."
Read more >
** Troubleshooting ** Message "Please wait, loading the ... - IBM
Cause. Internet Explorer settings/configuration is blocking access to the required Report Server website/components. There are several potential ...
Read more >
Data variables - SAP AppGyver Documentation
A data variable is essentially the same a page variable that exists in ... and disappears if the page is removed from the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found