You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: rewrite to export into universal folder + support linking
This commit rewrites logseq-export to be more opinionated with the idea that you'll dedicate a whole folder to all your interlinked notes instead of trying to transform logseq notes into customised blog articles.
New features
- supports interlinking - If you link between pages with [[title]], this will be transformed into [title](/logseq-pages/slug) in your pages
- more opinionated about where the files will go - the idea is that each CMS system will require a small bash script that will move the files in the right place. I tried to decouple this tool from Hugo, but I haven't tried any other static site generators
- better Windows support
BREAKING CHANGE: complete rewrite, use version `0.0.3` for the old functionality.
Copy file name to clipboardExpand all lines: README.md
+44-23Lines changed: 44 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,18 +1,28 @@
1
1
# logseq-export
2
2
3
-
Tool to export raw [Logseq](https://github.com/logseq/logseq) Markdown files (with `public::` page property) into Markdown blog posts with front matter.
3
+
Tool to export raw [Logseq](https://github.com/logseq/logseq) Markdown pages (with `public::` page property) into Markdown blog posts with front matter.
4
4
5
5
- Takes Logseq page properties (`title:: Hello world`) and turns them into [Front Matter properties](https://gohugo.io/content-management/front-matter/)`title: Hello World`.
6
6
- Changes the Markdown syntax to remove the top-level bullet points.
7
7
8
+
**Note: I completely reworked `logseq-export` to be a bit more versatile and universal. See the [version `v0.0.3`](https://github.com/viktomas/logseq-export/tree/v0.0.3) if you are not ready to move on.**
9
+
8
10
## Install
9
11
10
12
- Download the latest binary for your OS in the [Releases](https://github.com/viktomas/logseq-export/releases) page
11
13
-`go install github.com/viktomas/logseq-export@latest` if you have Go installed
12
14
13
15
## Usage
14
16
15
-
### Command
17
+
The `logseq-export` utility will export the pages into an export folder that can then be imported into your static site generator.
EF --"import_to_hugo.sh"--> HU[Hugo static site generator]
23
+
```
24
+
25
+
### Export
16
26
17
27
```
18
28
logseq-export
@@ -22,65 +32,76 @@ logseq-export
22
32
[MANDATORY] Path to the root of your logseq graph containing /pages and /journals directories.
23
33
```
24
34
25
-
This command also expects you have a file called `export.yaml` in your logseq folder.
35
+
*Optional* configuration is in a file called `export.yaml` in your logseq folder.
26
36
27
37
```yml
38
+
# list of logseq page properties that won't be quoted in the markdown front matter
28
39
unquotedProperties:
29
40
- date
30
41
- tags
31
-
assetsRelativePath: "static/images/logseq"
32
-
webAssetsPathPrefix: "/images/logseq"
33
42
```
34
43
35
-
- `assetsRelativePath` relative path within blogFolder where the assets (images) should be stored (e.g. 'static/images/logseq'). Default is logseq-images (default "logseq-images")
36
-
- `webAssetsPathPrefix`path that the images are going to be served on on the web (e.g. '/public/images/logseq'). Default is /logseq-images (default "/logseq-images")
37
-
- `unquotedProperties`list of logseq page properties that won't be quoted in the markdown frontmatter
This will take my logseq notes and copies them to blog, it will also copy all the images to `/Users/tomas/workspace/private/blog/static/images/logseq`, but the image links themselves are going to have `/images/logseq` prefix (``).
54
+
This will take my logseq notes and copies them to the export folder, it will also copy all the images to `/tmp/logseq-export/logseq-assets`, but the image links themselves are going to have `/logseq-asstes/` prefix (``).
55
+
56
+
#### Constraints
57
+
58
+
-`logseq-export` assumes that all the pages you want to export are in `pages/` folder inside your `logseqFolder`.
59
+
60
+
61
+
### Import
62
+
63
+
```sh
64
+
# these environment variables are optional
65
+
# the values in this example are default values
66
+
export BLOG_CONTENT_FODLER="/graph"
67
+
export BLOG_IMAGES_FOLDER="/assets/graph"
68
+
69
+
# copies pages from `/tmp/logseq/export/logseq-pages` to `~/workspace/private/blog/content/graph`
70
+
# copies assets from `/tmp/logseq/export/logseq-assets` to `~/workspace/private/blog/static/assets/graph`
71
+
# replaces all `/logseq-assets` in all image URLs with `/assets/graph`
72
+
./import_to_hugo.sh \
73
+
/tmp/logseq-export
74
+
~/workspace/private/blog
75
+
```
50
76
51
77
### Logseq page properties with a special meaning (all optional)
52
78
53
79
-`public` - as soon as this page property is present (regardless of value), the page gets exported
80
+
-`title` - either the `title::` is present and used as `title:` front matter attribute, or the page file name is unescaped (e.g. `%3A` changes to `:`) and used as the `title:`
54
81
-`slug` used as a file name
55
82
-`date` it's used as a file name prefix
56
-
- `folder`the page is going to be exported in this subfolder e.g. `content/posts`
57
-
- the `folder` property always uses `/` (forward slash) but on Windows, it gets translated to `\` in folder path
58
-
- if the base export folder is `a` and the `folder` page property is `b/c`, then the resulting page will be in `a/b/c` folder
59
-
- `image`The value of this property behaves the same way as all Markdown images.
60
-
- if the `image` property contains `../assets/post-image.jpg`, and we run the `logseq-extract` with `--webAssetsPathPrefix /images/logseq -assetsRelativePath static/images/logseq` flags, the resulting Markdown post will have front-matter attribute `image: /images/logseq/post-image.jpg` and the image will be copied to `static/images/logseq/post-image.jpg` in the blog folder.
83
+
- if your logseq `date::` attributes contains the link brackets e.g. `[[2023-07-30]]`, `logseq-export` will remove them
61
84
62
85
## From
63
86
64
87

0 commit comments