Skip to content
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

Share data between backend and frontend #376

Open
humitos opened this issue Sep 19, 2024 · 1 comment
Open

Share data between backend and frontend #376

humitos opened this issue Sep 19, 2024 · 1 comment
Labels
Needed: design decision A core team decision is required

Comments

@humitos
Copy link
Member

humitos commented Sep 19, 2024

We've been using Cloudflare Worker to inject some data coming from the backend into the HTML that's useful/required for the frontend:

  • project slug
  • version slug
  • resolver filename
  • http response status code

In #373 (review), @agjohnson raised the idea about serializing the Response object somehow, but also mentioned that we may want to serialize a custom object at this point. Instead of using multiple meta HTML elements we could use a single script:

<script id="readthedocs-data" type="application/json">
  {
    "project": {
      "slug": "docs"
    },
    "version": {
      "slug": "latest"
    },
    "resolver": {
      "filename": "/en/latest/info.html"
    },
    "response": {
      "status": 200
    }
  }
</script>

This will give us more flexibility over time and easier to read/maintain.

@humitos humitos added the Needed: design decision A core team decision is required label Sep 19, 2024
@github-project-automation github-project-automation bot moved this to Planned in 📍Roadmap Sep 19, 2024
@ericholscher
Copy link
Member

ericholscher commented Nov 19, 2024

This is quite similar to what we did in the old extension, as well:

https://github.com/readthedocs/readthedocs-sphinx-ext/blob/13edf78bab374f51e314e4994c319fadbab806f2/readthedocs_ext/_templates/readthedocs-insert.html.tmpl#L23

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needed: design decision A core team decision is required
Projects
Status: Planned
Development

No branches or pull requests

2 participants