Elderjs / elderjs

Elder.js is an opinionated static site generator and web framework for Svelte built with SEO in mind.

Home Page:https://elderguide.com/tech/elderjs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do you stop prefix from prefixing the distDir?

eight04 opened this issue · comments

commented

I want to build index.html as docs/index.html, while mounting the page in a subfolder.

If I set prefix to fancy-t-spin, the path will be resolved correctly:

<link rel="prefetch" href="/fancy-t-spin/_elderjs/svelte/components/Link.30b50837.js" as="script">

However, index.html will be built into docs/fancy-t-spin/index.html.

In https://github.com/Elderjs/elderjs/pull/128/files, it seems that there is a variable $$internal.serverPrefix but defining it in elder.config.js has no effect.

The server prefix is added to all output files including the components, css, and html.

Something I have considered is allowing a customPrefix defined at the route level and adjusting how the prefix works in the wrapPremalinkFn.ts.

Another option is allowing a request object to have a permalink defined during a route's all function. This would bypass the use of the permalink function for the route.

The drawback to both of these is they undermine the usage of helpers.permalinks[routeName] in the templates which is something we use heavily and I can see lots of users using as well.

Open to continue this discussion. As I know some people have had issues hosting on gitlab due to this pattern of using the prefix on all files emitted.

commented

Currently I use a buildComplete hook moving files under ${distDir}/${prefix} back to distDir:
https://github.com/eight04/fancy-t-spin/blob/e1a4085cc7ec608825ebfb9fe801b6f026d35feb/src/hooks.js#L27-L39