-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
161 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import * as dotenv from 'dotenv' | ||
dotenv.config() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import './env.mjs' | ||
import { LiveExporter, toKebabCase } from '@inkdropapp/live-export' | ||
|
||
const { INKDROP_USERNAME, INKDROP_PASSWORD, INKDROP_PORT, INKDROP_BOOKID } = | ||
process.env | ||
|
||
const liveExport = new LiveExporter({ | ||
username: INKDROP_USERNAME, | ||
password: INKDROP_PASSWORD, | ||
port: Number(INKDROP_PORT) | ||
}) | ||
|
||
const basePath = `./src/pages/posts` | ||
const publicPath = `./public/posts` | ||
|
||
await liveExport.start({ | ||
live: true, | ||
bookId: INKDROP_BOOKID, | ||
preProcessNote: ({ note, frontmatter, tags }) => { | ||
frontmatter.layout = '../../layouts/BlogPost.astro' | ||
frontmatter.title = note.title | ||
frontmatter.createdAt = note.createdAt | ||
frontmatter.updatedAt = note.updatedAt | ||
frontmatter.tags = tags.map(t => t.name) | ||
frontmatter.heroImage = '/astrojs.jpg' | ||
if (!frontmatter.slug) frontmatter.slug = toKebabCase(note.title) | ||
}, | ||
pathForNote: ({ frontmatter }) => { | ||
if (frontmatter.public) { | ||
return `${basePath}/${frontmatter.slug}.md` | ||
} else return false | ||
}, | ||
urlForNote: ({ note, frontmatter }) => { | ||
if (frontmatter.public) { | ||
if (!frontmatter.slug) frontmatter.slug = toKebabCase(note.title) | ||
return `/posts/${frontmatter.slug}` | ||
} else return false | ||
}, | ||
pathForFile: ({ mdastNode, /* note, file, */ extension, frontmatter }) => { | ||
if (mdastNode.alt) { | ||
const fn = `${frontmatter.slug}_${toKebabCase(mdastNode.alt)}${extension}` | ||
const res = { | ||
filePath: `${publicPath}/${fn}`, | ||
url: `/posts/${fn}` | ||
} | ||
if (mdastNode.alt === 'thumbnail') { | ||
frontmatter.heroImage = res.url | ||
} | ||
return res | ||
} else return false | ||
}, | ||
postProcessNote: ({ md }) => { | ||
// Remove the thumbnail from the note body | ||
const md2 = md.replace(/\!\[thumbnail\]\(.*\)\n/, '') | ||
return md2 | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -429,6 +429,21 @@ | |
resolved "https://registry.yarnpkg.com/@humanwhocodes/object-schema/-/object-schema-1.2.1.tgz#b520529ec21d8e5945a1851dfd1c32e94e39ff45" | ||
integrity sha512-ZnQMnLV4e7hDlUvw8H+U8ASL02SS2Gn6+9Ac3wGGLIe7+je2AeAOxPY+izIPJDfFDb7eDjev0Us8MO1iFRN8hA== | ||
|
||
"@inkdropapp/live-export@^0.1.8": | ||
version "0.1.8" | ||
resolved "https://registry.yarnpkg.com/@inkdropapp/live-export/-/live-export-0.1.8.tgz#ba3548729d79142efa16b9596f075949bfb4acb5" | ||
integrity sha512-RTMDbgHr6iHVft9BiUUgbgjX/1o3MyQP9Uj1t3A1jWkaw/b5ZcKtjigef+RBmleqQH1hDSq296xZplXfq5ZFxA== | ||
dependencies: | ||
ajv "^8.11.0" | ||
debug "^4.3.4" | ||
inkdrop-model "^2.7.1" | ||
js-yaml "^4.1.0" | ||
remark-frontmatter "^4.0.1" | ||
remark-parse "^10.0.1" | ||
remark-stringify "^10.0.2" | ||
unified "^10.1.2" | ||
unist-util-visit "^4.1.1" | ||
|
||
"@jridgewell/gen-mapping@^0.1.0": | ||
version "0.1.1" | ||
resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz#e5d2e450306a9491e3bd77e323e38d7aff315996" | ||
|
@@ -785,6 +800,16 @@ ajv@^6.10.0, ajv@^6.12.4: | |
json-schema-traverse "^0.4.1" | ||
uri-js "^4.2.2" | ||
|
||
ajv@^8.11.0: | ||
version "8.11.0" | ||
resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.11.0.tgz#977e91dd96ca669f54a11e23e378e33b884a565f" | ||
integrity sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg== | ||
dependencies: | ||
fast-deep-equal "^3.1.1" | ||
json-schema-traverse "^1.0.0" | ||
require-from-string "^2.0.2" | ||
uri-js "^4.2.2" | ||
|
||
ansi-align@^3.0.1: | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/ansi-align/-/ansi-align-3.0.1.tgz#0cdf12e111ace773a86e9a1fad1225c43cb19a59" | ||
|
@@ -1371,6 +1396,11 @@ doctrine@^3.0.0: | |
dependencies: | ||
esutils "^2.0.2" | ||
|
||
dotenv@^16.0.2: | ||
version "16.0.2" | ||
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.2.tgz#0b0f8652c016a3858ef795024508cddc4bffc5bf" | ||
integrity sha512-JvpYKUmzQhYoIFgK2MOnF3bciIZoItIIoryihy0rIA+H4Jy0FmgyKYAHCTN98P5ybGSJcIFbh6QKeJdtZd1qhA== | ||
|
||
dset@^3.1.2: | ||
version "3.1.2" | ||
resolved "https://registry.yarnpkg.com/dset/-/dset-3.1.2.tgz#89c436ca6450398396dc6538ea00abc0c54cd45a" | ||
|
@@ -1773,6 +1803,13 @@ fastq@^1.6.0: | |
dependencies: | ||
reusify "^1.0.4" | ||
|
||
fault@^2.0.0: | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/fault/-/fault-2.0.1.tgz#d47ca9f37ca26e4bd38374a7c500b5a384755b6c" | ||
integrity sha512-WtySTkS4OKev5JtpHXnib4Gxiurzh5NCGvWrFaZ34m6JehfTUhKZvn9njTfw48t6JumVQOmrKqpmGcdwxnhqBQ== | ||
dependencies: | ||
format "^0.2.0" | ||
|
||
fetch-blob@^3.1.2, fetch-blob@^3.1.4: | ||
version "3.2.0" | ||
resolved "https://registry.yarnpkg.com/fetch-blob/-/fetch-blob-3.2.0.tgz#f09b8d4bbd45adc6f0c20b7e787e793e309dcce9" | ||
|
@@ -1832,6 +1869,11 @@ flatted@^3.1.0: | |
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787" | ||
integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ== | ||
|
||
format@^0.2.0: | ||
version "0.2.2" | ||
resolved "https://registry.yarnpkg.com/format/-/format-0.2.2.tgz#d6170107e9efdc4ed30c9dc39016df942b5cb58b" | ||
integrity sha512-wzsgA6WOq+09wrU1tsJ09udeR/YZRaeArL9e1wPbFg3GG2yDnC2ldKpxs4xunpFF9DgqCqOIra3bc1HWrJ37Ww== | ||
|
||
formdata-polyfill@^4.0.10: | ||
version "4.0.10" | ||
resolved "https://registry.yarnpkg.com/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz#24807c31c9d402e002ab3d8c720144ceb8848423" | ||
|
@@ -2191,6 +2233,11 @@ ini@~1.3.0: | |
resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.8.tgz#a29da425b48806f34767a4efce397269af28432c" | ||
integrity sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew== | ||
|
||
inkdrop-model@^2.7.1: | ||
version "2.7.1" | ||
resolved "https://registry.yarnpkg.com/inkdrop-model/-/inkdrop-model-2.7.1.tgz#d50eafbd08848f87ad91d2a670c23343abaf9913" | ||
integrity sha512-9Y7L04Y83Y1KAwuqZrsmXbsqV6OcgS8/sDeR9HCOQE6exiMw22uh55FBSLL6Xbc6EwT/dwkDPeAZg5PL1jyXJQ== | ||
|
||
[email protected]: | ||
version "0.1.1" | ||
resolved "https://registry.yarnpkg.com/inline-style-parser/-/inline-style-parser-0.1.1.tgz#ec8a3b429274e9c0a1f1c4ffa9453a7fef72cea1" | ||
|
@@ -2347,6 +2394,11 @@ json-schema-traverse@^0.4.1: | |
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" | ||
integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== | ||
|
||
json-schema-traverse@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" | ||
integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== | ||
|
||
json-stable-stringify-without-jsonify@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651" | ||
|
@@ -2499,6 +2551,13 @@ mdast-util-from-markdown@^1.0.0: | |
unist-util-stringify-position "^3.0.0" | ||
uvu "^0.5.0" | ||
|
||
mdast-util-frontmatter@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/mdast-util-frontmatter/-/mdast-util-frontmatter-1.0.0.tgz#ef12469379782e4a0fd995fed60cc3b871e6c819" | ||
integrity sha512-7itKvp0arEVNpCktOET/eLFAYaZ+0cNjVtFtIPxgQ5tV+3i+D4SDDTjTzPWl44LT59PC+xdx+glNTawBdF98Mw== | ||
dependencies: | ||
micromark-extension-frontmatter "^1.0.0" | ||
|
||
mdast-util-gfm-autolink-literal@^1.0.0: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/mdast-util-gfm-autolink-literal/-/mdast-util-gfm-autolink-literal-1.0.2.tgz#4032dcbaddaef7d4f2f3768ed830475bb22d3970" | ||
|
@@ -2654,6 +2713,15 @@ micromark-core-commonmark@^1.0.0, micromark-core-commonmark@^1.0.1: | |
micromark-util-types "^1.0.1" | ||
uvu "^0.5.0" | ||
|
||
micromark-extension-frontmatter@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/micromark-extension-frontmatter/-/micromark-extension-frontmatter-1.0.0.tgz#612498e6dad87c132c95e25f0918e7cc0cd535f6" | ||
integrity sha512-EXjmRnupoX6yYuUJSQhrQ9ggK0iQtQlpi6xeJzVD5xscyAI+giqco5fdymayZhJMbIFecjnE2yz85S9NzIgQpg== | ||
dependencies: | ||
fault "^2.0.0" | ||
micromark-util-character "^1.0.0" | ||
micromark-util-symbol "^1.0.0" | ||
|
||
micromark-extension-gfm-autolink-literal@^1.0.0: | ||
version "1.0.3" | ||
resolved "https://registry.yarnpkg.com/micromark-extension-gfm-autolink-literal/-/micromark-extension-gfm-autolink-literal-1.0.3.tgz#dc589f9c37eaff31a175bab49f12290edcf96058" | ||
|
@@ -3565,6 +3633,16 @@ rehype@^12.0.1: | |
rehype-stringify "^9.0.0" | ||
unified "^10.0.0" | ||
|
||
remark-frontmatter@^4.0.1: | ||
version "4.0.1" | ||
resolved "https://registry.yarnpkg.com/remark-frontmatter/-/remark-frontmatter-4.0.1.tgz#84560f7ccef114ef076d3d3735be6d69f8922309" | ||
integrity sha512-38fJrB0KnmD3E33a5jZC/5+gGAC2WKNiPw1/fdXJvijBlhA7RCsvJklrYJakS0HedninvaCYW8lQGf9C918GfA== | ||
dependencies: | ||
"@types/mdast" "^3.0.0" | ||
mdast-util-frontmatter "^1.0.0" | ||
micromark-extension-frontmatter "^1.0.0" | ||
unified "^10.0.0" | ||
|
||
remark-gfm@^3.0.1: | ||
version "3.0.1" | ||
resolved "https://registry.yarnpkg.com/remark-gfm/-/remark-gfm-3.0.1.tgz#0b180f095e3036545e9dddac0e8df3fa5cfee54f" | ||
|
@@ -3603,6 +3681,20 @@ remark-smartypants@^2.0.0: | |
retext-smartypants "^5.1.0" | ||
unist-util-visit "^4.1.0" | ||
|
||
remark-stringify@^10.0.2: | ||
version "10.0.2" | ||
resolved "https://registry.yarnpkg.com/remark-stringify/-/remark-stringify-10.0.2.tgz#50414a6983f5008eb9e72eed05f980582d1f69d7" | ||
integrity sha512-6wV3pvbPvHkbNnWB0wdDvVFHOe1hBRAx1Q/5g/EpH4RppAII6J8Gnwe7VbHuXaoKIF6LAg6ExTel/+kNqSQ7lw== | ||
dependencies: | ||
"@types/mdast" "^3.0.0" | ||
mdast-util-to-markdown "^1.0.0" | ||
unified "^10.0.0" | ||
|
||
require-from-string@^2.0.2: | ||
version "2.0.2" | ||
resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" | ||
integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== | ||
|
||
resolve-from@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-4.0.0.tgz#4abcd852ad32dd7baabfe9b40e00a36db5f392e6" | ||
|
@@ -4269,7 +4361,7 @@ unist-util-visit-parents@^5.0.0, unist-util-visit-parents@^5.1.1: | |
"@types/unist" "^2.0.0" | ||
unist-util-is "^5.0.0" | ||
|
||
unist-util-visit@^4.0.0, unist-util-visit@^4.1.0: | ||
unist-util-visit@^4.0.0, unist-util-visit@^4.1.0, unist-util-visit@^4.1.1: | ||
version "4.1.1" | ||
resolved "https://registry.yarnpkg.com/unist-util-visit/-/unist-util-visit-4.1.1.tgz#1c4842d70bd3df6cc545276f5164f933390a9aad" | ||
integrity sha512-n9KN3WV9k4h1DxYR1LoajgN93wpEi/7ZplVe02IoB4gH5ctI1AaF2670BLHQYbwj+pY83gFtyeySFiyMHJklrg== | ||
|