Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
play

GitHub Action

Logseq RDF Export

v0.1.0

Logseq RDF Export

play

Logseq RDF Export

Exports a subset of a Logseq graph to RDF

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Logseq RDF Export

uses: logseq/rdf-export@v0.1.0

Learn more about this action in logseq/rdf-export

Choose a version

Description

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.

Usage

Setup

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 with type:: [[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.

Github Action

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.

Action Inputs

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:

rdfFile

Required: Name of the exported rdf file. Defaults to test.ttl.

directory

Optional: The directory of the graph to rdf. Defaults to ..

Use with other actions

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

CLI

To use this as a CLI locally, first install it:

$ 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

Configuration

To configure how and what is exported to RDF, create a .export-rdf/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.

LICENSE

See LICENSE.md

Additional Links