import { Model } from 'objection' import { find, get, has, initial, isEmpty, isString, last, pick } from 'lodash-es' import { Type as JSBinType } from 'js-binary' import { generateHash, getFileExtension, injectPageMetadata } from '../helpers/page.mjs' import path from 'node:path' import fse from 'fs-extra' import yaml from 'js-yaml' import striptags from 'striptags' import emojiRegex from 'emoji-regex' import he from 'he' import CleanCSS from 'clean-css' import TurndownService from 'turndown' import { gfm as turndownPluginGfm } from '@joplin/turndown-plugin-gfm' import cheerio from 'cheerio' import { Locale } from './locales.mjs' import { PageLink } from './pageLinks.mjs' import { Tag } from './tags.mjs' import { User } from './users.mjs' const pageRegex = /^[a-zA0-90-9-_/]*$/ const aliasRegex = /^[a-zA0-90-9-_]*$/ const frontmatterRegex = { html: /^()?(?:\n|\r)*([\w\W]*)*/, legacy: /^(