This is a github action to export a configurable portion of a Logseq graph to RDF. Some basic validation is also done on the exported rdf file. This action can also be run as a CLI.
By default, this action is configured to export the portion of your Logseq graph that:
- has class pages with properties
type:: [[Class]]
- has property pages with properties
type:: [[Property]]
- has pages with properties
type:: [[X]]
where X are pages withtype:: [[Class]]
For an example of such a graph, see https://github.com/logseq/docs. If you would like to organize your graph differently, you can configure it.
To setup this action, add the file .github/workflows/ci.yml
to your graph's
github repository with the following content:
on: [push]
jobs:
rdf-export:
runs-on: ubuntu-latest
name: Test rdf export
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Export graph as RDF
uses: logseq/rdf-export@main
That's it! This job will then run on future git pushes and build RDF files from your graph.
NOTE: The above example defaults to picking up new changes. If you'd prefer to stay on a stable version use the format logseq/rdf-export@VERSION
e.g. logseq/rdf-export@v0.1.0
. See CHANGELOG.md for released versions.
This action can take inputs e.g.:
- name: Export graph as RDF
uses: logseq/rdf-export@main
with:
rdfFile: my-graph-name.ttl
directory: logseq-graph-directory
This action has the following inputs:
Required: Name of the exported rdf file. Defaults to test.ttl
.
Optional: The directory of the graph to rdf. Defaults to .
.
Since this action produces a valid RDF file, it is easy to save this file for later usage using upload-artifact:
...
- name: Export graph as RDF
uses: logseq/rdf-export@main
with:
rdfFile: my-graph.ttl
- uses: actions/upload-artifact@v3
with:
name: Exported RDF
path: my-graph.ttl
To use this as a CLI locally, first install babashka and clojure. Then:
$ git clone https://github.com/logseq/rdf-export
$ cd rdf-export && yarn install
$ yarn global add $PWD
Then use it from any logseq graph directory!
$ logseq-rdf-export docs.ttl
Parsing 301 files...
...
Writing 295 triples to file docs.ttl
To configure how and what is exported to RDF, create a .rdf-export/config.edn
file in your graph's directory. It's recommended to configure the :base-url
key so that urls point to your Logseq graph. To configure what is exported,
knowledge of advanced
queries is required. See
the config
file
for the full list of configuration keys.
This github action use nbb-logseq and the graph-parser library to export a Logseq graph from its database.
See LICENSE.md
- https://github.com/logseq/graph-validator - Github action that this one is modeled after
- https://github.com/Matdata-eu/logseq-rdf-export-docker - Docker image of this repository which also supports GitLab use
- https://github.com/rdfjs/N3.js - Library that handles the rdf exporting
- https://github.com/logseq/docs - Logseq graph that uses this action