# Using Netlify Edge Functions to transform RDFa (text/html) into Turtle

**URL:** <https://forum.solidproject.org/t/using-netlify-edge-functions-to-transform-rdfa-text-html-into-turtle/5765>\
**Category:** Linked Data\
**Created:** [October 30, 2022, 11:00pm UTC](https://forum.solidproject.org/t/using-netlify-edge-functions-to-transform-rdfa-text-html-into-turtle/5765 "2022-10-30T23:00:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ThisIsMissEm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/thisismissem/32/3166_2.png) [@ThisIsMissEm](https://forum.solidproject.org/u/ThisIsMissEm)\
**Post date:** [October 30, 2022, 11:00pm UTC](https://forum.solidproject.org/t/using-netlify-edge-functions-to-transform-rdfa-text-html-into-turtle/5765/1 "2022-10-30T23:00:14Z")

</div>

A little Sunday night hack: @Virginia writes her website with RDFa in the HTML, and we wanted to be able to query it as a Solid Dataset, without needing to move it to a solid server. Sure, you can query RDFa through comunica and other tools, but ~175 lines of code and a lot of cursing at [Deno](https://deno.land/) later, and we have her site content negotiating to `text/turtle`.

Try it out:

```auto
curl -i -H 'Accept: text/turtle' https://virginiabalseiro.com/

```

Code: [A small netlify edge function to transform text/html documents with RDFa in them into text/turtle, see: https://forum.solidproject.org/t/using-netlify-functions-to-transform-rdfa-text-html-into-turtle/5765 · GitHub](https://gist.github.com/ThisIsMissEm/13e623b91b6d89e7886dd8c731efaa9b)

This leverages the packages that @rubensworks and contributors have written for working with RDFa, RDF, and turtle. It’s deployed using [Netlify Edge Functions](https://www.netlify.com/blog/edge-functions-explained/), but with a few modifications, you could almost definitely deploy similar on Cloudflare Workers or any other edge runtime.

There were some issues where the packages that handle parsing and serialising rely on Node.js types, and this trips Deno up, so we don’t quite have full type safety in the code, but that’s a minor issue (it did work with the types in development, just not when we went to build for production).

---

<div class="post-metadata">

**Author:** ![ThisIsMissEm](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.solidproject.org/thisismissem/32/3166_2.png) [@ThisIsMissEm](https://forum.solidproject.org/u/ThisIsMissEm)\
**Post date:** [October 31, 2022, 5:41pm UTC](https://forum.solidproject.org/t/using-netlify-edge-functions-to-transform-rdfa-text-html-into-turtle/5765/2 "2022-10-31T17:41:47Z")

</div>

Update: the code now supports json-ld and more, thanks to @RubenVerborgh & @jeswr pointing me in the direction of [https://www.npmjs.com/package/rdf-serialize](https://www.npmjs.com/package/rdf-serialize)

I’ve updated the code accordingly: [A small netlify edge function to transform text/html documents with RDFa in them into text/turtle, see: https://forum.solidproject.org/t/using-netlify-functions-to-transform-rdfa-text-html-into-turtle/5765 · GitHub](https://gist.github.com/ThisIsMissEm/13e623b91b6d89e7886dd8c731efaa9b)

You could also use a similar approach if you had `.ttl` that you wanted as json-ld or json-ld as turtle.
