eleventy icon indicating copy to clipboard operation
eleventy copied to clipboard

Problems with Eleventy server, passthrough copy, and pathPrefix

Open azangru opened this issue 1 year ago • 0 comments

Operating system

macOS Sonoma Version 14.2.1

Eleventy

2.0.1

Describe the bug

Hi. Sorry for reporting several issues in one — they all are related to my repro case.

  • If Eleventy server is started with the --ignore-initial option (e.g. using the eleventy --ignore-initial --incremental --serve command), then the page that lists elements of a collection (e.g. the index page for a blog) will not show the collection items. It seems that the --ignore-initial option prevents the full collection from being read. If this is the expected behavior, I do not think it is reflected in the documentation.
  • The passthrough copy emulation (enabled with eleventyConfig.setServerPassthroughCopyBehavior("passthrough");) does not seem to work. The default behavior, which is copy, works correctly
  • Eleventy does not detect changes in passthrough files.
  • If I add a pathPrefix to eleventyConfig, the dev sever redirects to a page without the prefix if the url does not have a trailing slash. For example:
    • No prefix set in the config; url /blog/2023-article-one/ (with a trailing slash) shows the page correctly
    • No prefix set in the config; url /blog/2023-article-one (without a trailing slash) redirects to /blog/2023-article-one/ and shows the page correctly
    • Prefix set in the config; url /prefix/blog/2023-article-one/ (with a trailing slash) shows the page correctly
    • (BUG) Prefix set in the config; url /prefix/blog/2023-article-one (without a trailing slash) redirects to /blog/2023-article-one/ (prefix lost), and shows a 404 page

Reproduction steps

For the problem with --ignore-initial:

  1. Copy the reproduction repo, install node modules, and run npm start (this will run eleventy --ignore-initial --incremental --serve)
  2. Update the src/blog.njk file
  3. Navigate to /blog
  4. You will see the "Blog" heading, without any links to the articles. Expected the blog index page to contain a list of articles.

For the problem with passthrough copy:

  1. Make sure the build directory has been deleted
  2. In .eleventy.js file, uncomment the line eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
  3. Run npm start (this will run eleventy --ignore-initial --incremental --serve)
  4. Save src/blog/2023/article-one/index.md file to get it picked up by the dev server
  5. Open /blog/2023-article-one/
  6. (Problem): You will see that the image does not get served
  7. Stop the dev server
  8. In .eleventy.js file, comment the line `eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
  9. Run npm start
  10. Visit /blog/2023-article-one/ again
  11. You will see that the image has been copied correctly
  12. Update styles in the src/blog/2023/article-one/styles.css file
  13. In the terminal, you will see the message "Copied 1 file / Wrote 0 files (skipped 5) in 0.02 seconds (v2.0.1)"
  14. (Problem): However, the dev server will continue serving the old file.

For the problem with pathPrefix:

  1. In .eleventy.js, uncomment the line pathPrefix: '/prefix/'
  2. Run npm start to start the server
  3. Visit /prefix/blog/2023-article-one/. You should see the blog article page.
  4. Delete the trailing slash from /prefix/blog/2023-article-one/ in the url bar and press enter
  5. (Problem): Instead of redirecting back to /prefix/blog/2023-article-one/, dev server will redirect to /blog/2023-article-one/ (without the prefix), and you will see a 404 page.

Reproduction URL

https://github.com/azangru/eleventy-blog-bugs-repro

Screenshots

No response

azangru avatar Jan 01 '24 00:01 azangru