Skip to content

Commit 6db04a9

Browse files
authored
feat: add example project (#8)
This commit adds an /example/ folder that contains a logseq graph and its export in the form of Hugo page
1 parent 03e5782 commit 6db04a9

File tree

22 files changed

+674
-3
lines changed

22 files changed

+674
-3
lines changed

.github/workflows/hugo.yml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Sample workflow for building and deploying a Hugo site to GitHub Pages
2+
name: Deploy Hugo example to Pages
3+
4+
on:
5+
# Runs on pushes targeting the default branch
6+
push:
7+
branches:
8+
- main
9+
- example
10+
11+
# Allows you to run this workflow manually from the Actions tab
12+
workflow_dispatch:
13+
14+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
21+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
22+
concurrency:
23+
group: "pages"
24+
cancel-in-progress: false
25+
26+
# Default to bash
27+
defaults:
28+
run:
29+
shell: bash
30+
31+
jobs:
32+
# Build job
33+
build:
34+
runs-on: ubuntu-latest
35+
env:
36+
HUGO_VERSION: 0.116.1
37+
steps:
38+
- name: Install Hugo CLI
39+
run: |
40+
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
41+
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
42+
- name: Install Dart Sass
43+
run: sudo snap install dart-sass
44+
- name: Checkout
45+
uses: actions/checkout@v3
46+
# with:
47+
# submodules: recursive
48+
# fetch-depth: 0
49+
- name: Setup Pages
50+
id: pages
51+
uses: actions/configure-pages@v3
52+
# - name: Install Node.js dependencies
53+
# run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
54+
- name: Build with Hugo
55+
env:
56+
# For maximum backward compatibility with Hugo modules
57+
HUGO_ENVIRONMENT: production
58+
HUGO_ENV: production
59+
run: |
60+
cd example/logseq-export-example
61+
hugo mod get -u
62+
hugo \
63+
--gc \
64+
--minify \
65+
--baseURL "${{ steps.pages.outputs.base_url }}/"
66+
- name: Upload artifact
67+
uses: actions/upload-pages-artifact@v1
68+
with:
69+
path: ./example/logseq-export-example/public
70+
71+
# Deployment job
72+
deploy:
73+
environment:
74+
name: github-pages
75+
url: ${{ steps.deployment.outputs.page_url }}
76+
runs-on: ubuntu-latest
77+
needs: build
78+
steps:
79+
- name: Deploy to GitHub Pages
80+
id: deployment
81+
uses: actions/deploy-pages@v2

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
logseq-export
22
export-*
33
test/test-output
4+
example/logseq-export-example/public

Makefile

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
SHELL = /bin/bash
2+
.SILENT: # comment this one out if you need to debug the Makefile
13
APP=logseq-export
24

35
.PHONY: build
@@ -9,10 +11,39 @@ build:
911
test:
1012
go test ./...
1113

12-
.PHONY: watch
13-
watch:
14-
fswatch --exclude 'test/test-output' -o ./ | xargs -n1 -I{} go test ./...
14+
.PHONY: watch-test
15+
watch-test:
16+
fswatch \
17+
--exclude '.git' \
18+
--exclude 'logseq-export$$' \
19+
--exclude 'test/test-output' \
20+
--exclude 'example/' \
21+
-o . | \
22+
xargs -n1 -I{} go test ./...
1523

1624
.PHONY: clean
1725
clean:
1826
go clean
27+
28+
.PHONY: example
29+
example:
30+
$(MAKE) build
31+
tmp_export_folder=$$(mktemp -d); \
32+
./logseq-export \
33+
--logseqFolder "$(CURDIR)/example/logseq-graph" \
34+
--outputFolder "$$tmp_export_folder"; \
35+
./import_to_hugo.sh "$$tmp_export_folder" "$(CURDIR)/example/logseq-export-example"
36+
37+
.PHONY: watch-example
38+
watch-example:
39+
fswatch \
40+
--exclude '.git' \
41+
--exclude 'logseq-export$$' \
42+
--exclude 'test/test-output' \
43+
--exclude 'example/logseq-export-example/content/graph' \
44+
--exclude 'example/logseq-export-example/static/assets/graph' \
45+
-xn . | \
46+
while read file event; do \
47+
echo "File $$file has changed, Event: $$event"; \
48+
$(MAKE) example; \
49+
done

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Tool to export raw [Logseq](https://github.com/logseq/logseq) Markdown pages (wi
55
- Takes Logseq page properties (`title:: Hello world`) and turns them into [Front Matter properties](https://gohugo.io/content-management/front-matter/) `title: Hello World`.
66
- Changes the Markdown syntax to remove the top-level bullet points.
77

8+
See an **example of a deployed graph** on [viktomas.github.io/logseq-export](https://viktomas.github.io/logseq-export/). The graph and the [Hugo](https://gohugo.io/) project can be found in the [example](/example/) folder. Run the example locally with ``
9+
810
**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.**
911

1012
## Install
@@ -113,3 +115,13 @@ have
113115

114116
Multi-line strings
115117
~~~
118+
119+
## Local development
120+
121+
- Have golang installed
122+
- Use unix or WSL2 on Windows
123+
- `make build` - builds the binary
124+
- `make test` - tests the project
125+
- `make watch-test` - (only on macOS) - run test on every file change
126+
- `make example` - export the example Logseq graph into the example Hugo site
127+
- `make watch-example` (only on macOS) - run `make example` on any file change

example/logseq-export-example/.hugo_build.lock

Whitespace-only changes.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: "{{ replace .Name "-" " " | title }}"
3+
date: {{ .Date }}
4+
draft: true
5+
---
6+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
languageCode: 'en-us'
3+
title: 'Logseq-Export example site'
4+
menu:
5+
main:
6+
- name: "<u>H</u>ome"
7+
url: /
8+
weight: 1
9+
module:
10+
imports:
11+
- path: github.com/barklan/hugo-dead-simple
12+
# Even though this setting is deprecated, I have to put it in here because GitHub pages
13+
# prepend the project name (/logseq-export/) to the whole site and the relative links
14+
# in the graph Markdown files are pointing to /graph/page instead of /logseq-export/graph/page
15+
# this setting prepends the `baseURL` to each of the links
16+
canonifyURLs: true
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
date: 2022-09-25
3+
public: true
4+
slug: test-page
5+
title: "Test page"
6+
---
7+
8+
This is an example paragraph
9+
10+
- Second level means bullet points
11+
- `logseq-export` also supports multi-level bullet points
12+
13+
```ts
14+
const v = "Hello world"
15+
```
16+
17+
You can
18+
also
19+
have
20+
21+
Multi-line strings
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
---
2+
public: true
3+
slug: _index
4+
title: "Index"
5+
---
6+
7+
## Welcome
8+
9+
Welcome to this example page.
10+
11+
This site is generated from a [Logseq](https://logseq.com/) graph using [logseq-export](https://github.com/viktomas/logseq-export)
12+
13+
## See other pages
14+
15+
Se how we can link to other pages [Most important page](/graph/most-important-page)
16+
17+
Or see the [Test page](/graph/test-page)
18+
19+
## Credit
20+
21+
This example site uses [Hugo](https://gohugo.io/) with [barklan/hugo-dead-simple](https://github.com/barklan/hugo-dead-simple) theme.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
public: true
3+
slug: most-important-page
4+
title: "Most important page"
5+
---
6+
7+
This page seems quite important
8+
9+
Here is a picture of a cute shabby dog
10+
11+
![dog-316598_1280.jpg](/assets/graph/dog-316598_1280_1690970151376_0.jpg)
12+
13+
Continue to the [Test page](/graph/test-page)

0 commit comments

Comments
 (0)