-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can a query string be read by the destination view? #268
Comments
The thing to remember here is that anywhere you have C# code (a Razor view, in a pipeline or module, etc.) that code has already been executed by the time any sort of client request is made. This is key to static generation: the code is run and the "static" site assets (I.e. HTML pages, images, JavaScript files, etc.) are all produced and finalized beforehand. This paradigm is quite different to a server-side web framework like ASP.NET where you have access to request-time things like query strings in the code. While the ASP.NET context is provided in Statiq Razor views for compatibility, anything that has to do with a live web request is null or uninitialized. This means that if you want to interact with anything the client is doing during a request (such as the query strings they're using), you have to do it using JavaScript.
One way to do this would be to generate all the topics on the page, but then use JavaScript to control their display. I personally love Vue.js for stuff like this, but there are plenty of libraries for jQuery and vanilla JavaScript that can display and sort/filter a set of data as well. Then get the query string using JavaScript, and if one is provided, filter the list of topics on the client. Does that make sense?
This definitely isn't a known issue and is certainly some kind of bug that I haven't observed before. The Statiq website itself is generated multiple times a day from a fresh environment via GitHub Actions and, as far as I know, it's never not output a file. Are you able to discern any kind of pattern to the missing files? Is it always the same ones (maybe there's some sort of weird cycle going on where it won't generate file B until file A is on disk)? |
Hi Dave, |
Hi Dave,
I want to pass a query string from a view with a list of for example
A B C
topics to a view with a list of A by passing a query string in the url i.e. localhost:5080/letter?query=AI would normally get this from the context however the query string field is null when using Statiq.
We are using Statiq.Docs V1.0.0-beta.13 to produce an updated documentation website
A little assistance would be greatly appreciated :)
There is an issue also but you may know about this -:
if you use dotnet run once then there is a few files which are not generated, if you then use dotnet run -l Debug all the files are then generated the first run it states 0 files already existed the second time it states that all but 6 in my case existed and the site operates as expected.
the same applies if you run dotnet run -- preview there is always files missing, then go to any file and add a white space to any file in the input folder, the site is built again and has no issues all the files are generated.
The text was updated successfully, but these errors were encountered: