Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This introduces a (temporary) alternative to the current website header, based around a Vue.js app that's injected into the regular Django context. The aim is to ease the transition to a prospective V2 frontend as well as make iterations on the header faster.
Features
The significant differences compared to the current version are as follows. Anything not listed here has remained, the current header functionality was ported in its entirety:
For a short overview of all the changes as well as the overall look and feel, see this video: https://streamable.com/1w0wm
Implementation
There are a few quirks to the implementation which are mostly due to the interplay between Vue.js and Django.
For minimal impact on the layout during page load, a "static" version of the header content is delivered with the standard layout template. This is then "hydrated" on the client-side and seamlessly replaced with a wholly interactive version.
The Vue.js application is built using the standard vue-cli tool, which uses webpack as an internal build system. Additionally, a metadata file pointing to the build results is automatically created. In order to ease development, the development server is configured such that it can be used straight from Django with hot reloading capabilities.
On the Django front, this uses django-webpack-loader in order to dynamically add the necessary resources as indicated by the previously generated metadata file. Because the Vue.js hydration algorithm is a little peculiar about what constitutes a matching element in the server-side markup, a custom space removal tag is also introduced. We could just have all the "dry" HTML in a single line, so this is mainly for developer comfort.
In order to use the hot reloadable header implementation during development,
yarn serve
is all that's required to run in thefrontend
directory.Deployment
Django is configured such that it picks up any production-ready outputs from the
frontend/dist
directory with thecollectstatic
command. The metadata also points at thecolleced-statics
URL. They are then automatically injected into the HTML just like during development.Building the Vue.js app for production only requires running the
yarn serve
command.I have a local Docker setup that I could share to ease testing further.