Giter VIP home page Giter VIP logo

Comments (7)

daveaglick avatar daveaglick commented on June 11, 2024 3

One final update: since ~~ was reserved for a totally different reason (it gets stripped if filename optimization is turned on), the final default prefix is ^, but it can also be changed by using a NetlifyRedirectPrefix setting.

With that, this is ready to ship in the next release once I clean up some Statiq Framework stuff I added to support it, add some more tests, and write documentation.

from statiq.web.

nils-a avatar nils-a commented on June 11, 2024 1

I feel netlify is at fault here and Statiq can not be expected to provide a solution.
I feel we could, however provide an easy workaround.

What if we created a module that would automatically redirect a whole folder based on a setting?

Say the user creates a folder named dotWellKnown/ and supplies the setting to redirect from .well-known/ to dotWellKnown/.

Statiq would then go its normal way of outputting the documents to the dotWellKnown/ folder, create redirect documents in the .well-known/ folder and, since we are on netlify also write the redirects into the _redirects file.

Now, when the deployment to netlify occurs, the documents in .well-known/ will not be deployed. This won't be a problem though, because the _redirects file will be deployed.

from statiq.web.

daveaglick avatar daveaglick commented on June 11, 2024 1

Small change of plans - the prefix for designating these is now a double tilde ~~ instead of underscores since underscore files are already ignored by Statiq by default and revising that would be a whole thing.

So as a revised example, for a .well-known folder, you'd name that ~~.well-known in your input folder, set NetlifyRedirects to true, and you're done.

from statiq.web.

daveaglick avatar daveaglick commented on June 11, 2024

I feel netlify is at fault here and Statiq can not be expected to provide a solution.

I generally agree, but the pragmatic side of me also feels like if there's something we can do, might as well do what we can.

The more I thought about this, the more I think automating essentially what you described might work. I.e. if a particular flag is set (something like NetlifyDotFolderRedirects, which we can set automatically when Netlify deployment is turned on, or user can set manually if deploying to Netlify externally) then we'll find dot folders, rename them, and add the correct _redirects entries.

Now the complication is that it looks like we're also skipping _redirects files, so I need to look into that first. Have a tiny bit of time so might end up hacking this whole feature together today if it's not too tough.

from statiq.web.

nils-a avatar nils-a commented on June 11, 2024

Now the complication is that it looks like we're also skipping _redirects files [...]

I think we're only skipping them when they are not automatically created. If "we" create them they do have a nice contentType associated and will be added to the output.

https://github.com/statiqdev/Statiq.Framework/blob/57dd8075157c7bc4b42e51fb22ac9d6f3cd73d98/src/core/Statiq.Core/Modules/Content/GenerateRedirects.cs#L111-L125

However, I feel that logic currently misses some way to define static redirects to be added. (Or rather add or modify the list of redirects)

from statiq.web.

daveaglick avatar daveaglick commented on June 11, 2024

I think we're only skipping them when they are not automatically created. If "we" create them they do have a nice contentType associated and will be added to the output.

Yep - went down a rabbit hole on this a bit this afternoon in preparation for making it work with dot files/folders. I wanted an existing _redirects file to carry over to output when NetlifyRedirects is true (which seemed like a reasonable signal for making sure a _redirects file makes it to output since it's a Netlify file convention). It now also makes sure that any redirects we generate are combined with an existing redirects file rather than overwriting it.

Now that that's done, I'll likely tackle the dot file/folders thing tomorrow.

from statiq.web.

daveaglick avatar daveaglick commented on June 11, 2024

Ended up not quite making this automatic. It was too hard to perform renaming of documents from other pipelines, so instead it works by generating content in the _redirects file for any file or folder that starts with a double underscore __. This behavior is automatically turned on when NetlifyRedirects is true (but can be turned off by setting NetlifyUnderscoreRedirects to false). A side benefit is that it'll work for any file or folder with a double underscore prefix just in case there are other situations like this where you can't upload or serve the asset in Netlify directly.

So as an example, for a .well-known folder, you'd name that __.well-known in your input folder, set NetlifyRedirects to true, and you're done.

from statiq.web.

Related Issues (20)

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.