Compare commits

...
26 Commits
Author SHA1 Message Date
qwqcode 92ff757efc chore: fix docker build ci workflow 2023-12-28 21:43:17 +08:00
github-actions[bot]andqwqcode 63165599ce chore: release v2.7.3 (#726)
* chore: release v2.7.3

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: qwqcode <22412567+qwqcode@users.noreply.github.com>
2023-12-28 17:06:57 +08:00
qwqcode a5b428d1ec refactor(test/ui): add more ui api tests 2023-12-28 16:56:00 +08:00
qwqcode cf3f9b1ac3 chore: patch pacakge.json for i18n exports 2023-12-28 15:43:30 +08:00
qwqcode c212d67f49 perf(ui/build): better dts generation (#689)
* chore: move types as a subfolder of src

* perf(ui/build): better dts generation

* chore: update pnpm-lock.yaml

* chore: fix env variable on windows

* fix i18n types
2023-12-28 15:25:01 +08:00
qwqcode b00a257699 docs: update ui api documentation 2023-12-26 22:18:43 +08:00
3698c0c593 refactor(ui/conf): better handling of mutable config (#722)
* fix(ui): mergeDeep causes some configurations to be overridden by the default configuration

* fix: config always get override by defaults

Signed-off-by: Frost Ming <me@frostming.com>

* refactor(ui/conf): better handling of mutable config

* chore: fix path issue on win env

* fix: mergeDeep avoid prototype pollution

BREAKING CHANGE: Directly referencing `artalk.conf` and `artalk.$root` is deprecated. Please use functions instead: `artalk.getConf()` and `artalk.getEl()`.

---------

Signed-off-by: Frost Ming <me@frostming.com>
Co-authored-by: syfxlin <i@ixk.me>
Co-authored-by: Frost Ming <me@frostming.com>
2023-12-26 22:13:37 +08:00
qwqcode 32a398609c chore(tsconfig): modify moduleResolution to bundler 2023-12-26 00:30:50 +08:00
qwqcode 54729fbafc chore(build): use vite internal mergeConfig func 2023-12-26 00:06:21 +08:00
qwqcode b74e5cf94c refactor(ui/test): add vitest for unit testing 2023-12-26 00:03:08 +08:00
Frost Ming 475dd933fe fix(ui/init): stack overflow when merging with config defaults (#717)
Close #716
2023-12-23 21:40:18 +08:00
qwqcode 60e0e7e61a chore(ci): fixed tag version for git checkout branch 2023-12-23 01:32:19 +08:00
qwqcode e4a42d3a90 refactor(docker): add --build-arg argument to skip ui build 2023-12-22 23:54:32 +08:00
qwqcode d86cd73ea6 refactor(ci): better release workflow 2023-12-22 22:06:09 +08:00
qwqcode 67280f2ca2 feat(ci): add dry-run mode for build workflow 2023-12-22 02:30:54 +08:00
qwqcode a8bcd41f36 refactor(ui): refactor directory structure (#712)
* refactor(ui): refactor directory structure

* update config files

* update github workflows

* update vscode settings.json

* update docs

* update build scripts

* tidy up

* fix docs build
2023-12-21 23:51:26 +08:00
qwqcode 04cf137a74 feat(cmd): support cli flag for creating admin account 2023-12-21 22:35:10 +08:00
qwqcode d542e98581 chore(eslint): fix sidebar eslint configuration 2023-12-21 22:28:24 +08:00
qwqcode dfaf95bf1d chore(docs): bump Artalk to v2.7.2 2023-12-21 01:51:36 +08:00
github-actions[bot] 0a89426c93 chore: release v2.7.2 2023-12-20 17:20:40 +00:00
qwqcode 7a026ef0e2 fix(sidebar): sidebar language switch and config save issue (#708) 2023-12-21 01:14:49 +08:00
qwqcode 855f6c261f docs(i18n): add translation for open button 2023-12-20 23:35:58 +08:00
qwqcode 7099598a92 fix(ui): add referrerpolicy attribute for iframe (#687) (#707) 2023-12-20 23:34:46 +08:00
qwqcode ad8851ea94 fix(ui/pagination): auto switch page by url hashtag issue (#693) 2023-12-20 21:44:06 +08:00
qwqcode def9dc2707 fix(ui/sidebar): refactor settings and fix save issue (#677) (#706) 2023-12-20 20:53:04 +08:00
Mr.Hopeandqwqcode 91228a9446 docs(refactor): organize the pkgs and fix some issues (#702)
* docs: rebuild docs

* chore: fix eslint

* ci: add docs build test

* update test-docs.yml

* fix script

* add netlify.toml

* fix docs:patch

---------

Co-authored-by: qwqcode <qwqcode@gmail.com>
2023-12-19 21:55:04 +08:00
390 changed files with 9851 additions and 10758 deletions

No files matched your search

+1
View File
@@ -0,0 +1 @@
node_modules
+1 -1
View File
@@ -8,7 +8,7 @@ coverage
vite*.config*
# ignore all js files
**/*.js
**/*.*js
# ignore all config files
*.config.ts
+2 -2
View File
@@ -5,7 +5,7 @@ module.exports = {
parser: '@typescript-eslint/parser',
env: { browser: true },
parserOptions: {
project: ['./packages/*/tsconfig.json'],
project: ['./ui/*/tsconfig.json'],
tsconfigRootDir: __dirname,
},
extends: [
@@ -40,7 +40,7 @@ module.exports = {
settings: {
'import/resolver': {
typescript: {
project: ['packages/artalk/tsconfig.json'].map((p) =>
project: ['ui/artalk/tsconfig.json'].map((p) =>
path.resolve(__dirname, p),
),
},
+25
View File
@@ -0,0 +1,25 @@
name: Comment issue
description: Create comment on a issue
inputs:
issue_number:
required: true
description: The issue number you want to comment
content:
required: true
description: The content of comment
runs:
using: "composite"
steps:
- uses: actions/github-script@v7
env:
STDOUT: ${{ inputs.content }}
with:
script: |
github.rest.issues.createComment({
issue_number: ${{ inputs.issue_number }},
owner: context.repo.owner,
repo: context.repo.repo,
body: process.env.STDOUT
})
+21 -19
View File
@@ -1,13 +1,18 @@
name: Build App
run-name: Build Go App and Publish
on:
repository_dispatch:
types: [artalk-release]
workflow_call:
inputs:
version:
required: true
type: string
dry_run:
required: true
type: boolean
env:
GO_VERSION: '1.21.3'
PKG_NAME: 'github.com/ArtalkJS/Artalk'
GO_VERSION: 1.21.3
PKG_NAME: github.com/ArtalkJS/Artalk
DOCKER_IMG: ghcr.io/goreleaser/goreleaser-cross
CACHE_DIR: /tmp/cache/docker-image
@@ -17,18 +22,12 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Checkout latest tag
run: |
# fetch tags
git fetch --prune --unshallow --tags -f
# checkout latest version
VERSION=$(git describe --tags --abbrev=0)
git checkout ${VERSION}
echo "VERSION=${VERSION}" >> $GITHUB_ENV
uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
# `go-releaser` will read the semver version from git tag name
# `git-chglog` will diff the tag and generate changelog
fetch-depth: 0
# disable cache because the err `no space left on device`
# - name: Docker Image Cache
@@ -64,11 +63,14 @@ jobs:
echo "GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}" > local/.release-env
# changelog
git-chglog --config .github/chglog/config.yml ${VERSION} > local/release-notes.md
git-chglog --config .github/chglog/config.yml ${{ inputs.version }} > local/release-notes.md
# copy config file
cp conf/artalk.example.yml artalk.yml
- name: Print Relase Notes
run: cat local/release-notes.md
- name: Build and Release
run: |
docker run \
@@ -81,4 +83,4 @@ jobs:
-e CGO_ENABLED=1 \
--env-file local/.release-env \
ghcr.io/goreleaser/goreleaser-cross:v${GO_VERSION} \
release --release-notes local/release-notes.md
release --release-notes local/release-notes.md ${{ inputs.dry_run && '--skip=publish' || '' }}
+45 -73
View File
@@ -1,9 +1,17 @@
name: Build Docker
run-name: Build Docker Image and Publish
on:
repository_dispatch:
types: [artalk-release]
workflow_call:
inputs:
version:
required: true
type: string
dry_run:
required: true
type: boolean
target:
required: true
type: string
env:
DOCKER_IMG: artalk/artalk-go
@@ -14,58 +22,14 @@ jobs:
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Checkout latest tag
run: |
# fetch tags
git fetch --prune --unshallow --tags -f
# checkout latest version
VERSION=$(git describe --tags --abbrev=0)
git checkout ${VERSION}
VERSION_SHORT="$(cut -d '.' -f 1,2 <<< ${VERSION#v})" # (i.e "v1.2.3" -> "1.2")
COMMIT_HASH="$(git rev-parse --short HEAD)"
COMMIT_HASH_FULL="$(git rev-parse HEAD)"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
echo "VERSION_SHORT=${VERSION_SHORT}" >> $GITHUB_ENV
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV
echo "COMMIT_HASH_FULL=${COMMIT_HASH_FULL}" >> $GITHUB_ENV
# https://github.com/docker/login-action
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
uses: actions/checkout@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# https://github.com/docker/setup-qemu-action
- name: Setup QEMU
id: qemu
uses: docker/setup-qemu-action@v2
with:
platforms: 'amd64,arm64'
# https://github.com/docker/setup-buildx-action
- name: Setup Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
ref: ${{ inputs.version }}
# https://github.com/docker/metadata-action
- name: Gen docker meta
id: meta
uses: docker/metadata-action@v4
uses: docker/metadata-action@v5
with:
context: git
images: |
@@ -77,34 +41,42 @@ jobs:
type=semver,pattern={{major}}.{{minor}}
type=sha
# https://github.com/docker/login-action
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# https://github.com/docker/setup-qemu-action
- name: Setup QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: ${{ inputs.target }}
# https://github.com/docker/setup-buildx-action
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
# Build UI outside of Docker to speed up cross-platform builds
- name: Build UI
run: |
make build-frontend
# https://github.com/docker/build-push-action
- name: Build and Push
id: docker_build
uses: docker/build-push-action@v4
id: build
uses: docker/build-push-action@v5
with:
builder: ${{ steps.buildx.outputs.name }}
context: ./
push: ${{ !inputs.dry_run }}
context: .
file: ./Dockerfile
platforms: 'linux/amd64,linux/arm64'
push: true
build-args: |
APP_VERSION=${{ inputs.version }}
SKIP_UI_BUILD=true
platforms: ${{ inputs.target }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
- name: Comment build info in commit
uses: actions/github-script@v6
env:
STDOUT: "🐳 Published new docker image: [${{ env.DOCKER_IMG }}](https://hub.docker.com/r/${{ env.DOCKER_IMG }}) (${{ env.VERSION }} / sha-${{ env.COMMIT_HASH }})"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.repos.createCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: process.env.COMMIT_HASH_FULL, // context.sha
body: process.env.STDOUT
})
- name: Print image digest
run: echo ${{ steps.docker_build.outputs.digest }}
run: echo ${{ steps.build.outputs.digest }}
+31
View File
@@ -0,0 +1,31 @@
name: Build Done
on:
workflow_call:
inputs:
version:
required: true
type: string
dry_run:
required: true
type: boolean
issue_number:
required: true
type: number
jobs:
done:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Comment done info
uses: ./.github/actions/comment
if: ${{ inputs.issue_number != 0 }}
with:
issue_number: ${{ inputs.issue_number }}
content: |-
🎉 Finished build and publish ${{ inputs.version }} ([NPM Package](https://www.npmjs.com/package/artalk?activeTab=versions) / [Docker Image](https://hub.docker.com/r/artalk/artalk-go/tags) / [Github Release](https://github.com/ArtalkJS/Artalk/releases/tag/${{ inputs.version }})).
-58
View File
@@ -1,58 +0,0 @@
name: Build Frontend
run-name: Build Frontend and Publish
on:
repository_dispatch:
types: [artalk-release]
jobs:
build_publish:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./ui # set for building frontend
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Checkout latest tag
run: |
git fetch --prune --unshallow --tags -f
git checkout $(git describe --tags --abbrev=0)
- name: Use pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
cache: 'pnpm'
cache-dependency-path: './ui/pnpm-lock.yaml'
- name: Install dependencies
run: pnpm install
- name: Build
run: pnpm build
- name: Publish
run: pnpm publish -F artalk --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# GitHub Packages
#
# Setup .npmrc file to publish to GitHub Packages
# - uses: actions/setup-node@v2
# with:
# registry-url: 'https://npm.pkg.github.com'
# # Publish to GitHub Packages
# - run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+60
View File
@@ -0,0 +1,60 @@
name: Build Pre Tagging
on:
workflow_call:
inputs:
dry_run:
required: true
type: boolean
issue_number:
required: true
type: number
outputs:
version:
description: 'Version'
value: ${{ jobs.tagging.outputs.version }}
jobs:
tagging:
runs-on: ubuntu-latest
steps:
- name: Get release version
run: |
# `github.head_ref` only exists for pull_request events
REF="${{ github.head_ref || github.ref }}"
VERSION="${REF#release/}"
VERSION="${VERSION#refs/tags/}"
echo "Version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_ENV
if [[ ! "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format: $VERSION, please check git ref or tag."
exit 1
fi
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create Tag
run: |
if [ ! $(git tag -l "${VERSION}") ]; then
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git tag -a $VERSION -m "Release $VERSION"
git push origin $VERSION
else
echo "Skip creating tag $VERSION, already exists."
fi
- name: Comment tag info to PR
uses: ./.github/actions/comment
if: ${{ inputs.issue_number != 0 }}
with:
issue_number: ${{ inputs.issue_number }}
content: |-
🔖 Tagged version [${{ env.VERSION }}](https://github.com/ArtalkJS/Artalk/tree/${{ env.VERSION }}) and updated the [CHANGELOG.md](https://github.com/ArtalkJS/Artalk/blob/master/CHANGELOG.md).
outputs:
version: ${{ env.VERSION }}
+55
View File
@@ -0,0 +1,55 @@
name: Build UI
on:
workflow_call:
inputs:
version:
required: true
type: string
dry_run:
required: true
type: boolean
jobs:
build_publish:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ inputs.version }}
- name: Use pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Publish
run: pnpm publish -F artalk --no-git-checks ${{ inputs.dry_run && '--dry-run' || '' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# GitHub Packages
#
# Setup .npmrc file to publish to GitHub Packages
# - uses: actions/setup-node@v4
# with:
# registry-url: 'https://npm.pkg.github.com'
# # Publish to GitHub Packages
# - run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+82
View File
@@ -0,0 +1,82 @@
name: Build and Publish
run-name: Build and Publish (${{ github.head_ref || github.ref }}) ${{ inputs.dry_run && '(🧪 Dry-Run)' || '' }}
on:
pull_request:
branches: [master]
types: [closed]
workflow_dispatch:
inputs:
dry_run:
description: 'Dry run'
type: boolean
default: true
build_items:
description: 'Build items'
type: string
default: 'ui,app,docker'
jobs:
# Tag the release version code before building
# Getting the version code from the branch name or git ref.
tagging:
# Only run on manual trigger
# or when a PR is merged into master.
# (which the branch name start with `relase/`)
if: |
github.event_name == 'workflow_dispatch' ||
(github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/'))
uses: ./.github/workflows/build-tagging.yml
with:
issue_number: ${{ github.event.pull_request.number || 0 }}
dry_run: ${{ inputs.dry_run || false }}
secrets: inherit
# Build the UI
ui:
if: inputs.build_items == '' || contains(inputs.build_items, 'ui')
needs: tagging
uses: ./.github/workflows/build-ui.yml
with:
version: ${{ needs.tagging.outputs.version }}
dry_run: ${{ inputs.dry_run || false }}
secrets: inherit
# Build the Docker image
docker:
if: inputs.build_items == '' || contains(inputs.build_items, 'docker')
needs: tagging
uses: ./.github/workflows/build-docker.yml
# Parallel build the multi-arch docker image
strategy:
matrix:
# since docker push actions will override the previous images,
# so need to build `linux/amd64` and push first,
# then build `linux/amd64` twice with other archs (build very slow so keep it last).
target: ["linux/amd64", "linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6"]
with:
version: ${{ needs.tagging.outputs.version }}
dry_run: ${{ inputs.dry_run || false }}
target: ${{ matrix.target }}
secrets: inherit
# Build the binary app
app:
if: inputs.build_items == '' || contains(inputs.build_items, 'app')
needs: tagging
uses: ./.github/workflows/build-app.yml
with:
version: ${{ needs.tagging.outputs.version }}
dry_run: ${{ inputs.dry_run || false }}
secrets: inherit
# All builds are complete
done:
needs: [tagging, ui, docker, app]
uses: ./.github/workflows/build-done.yml
with:
version: ${{ needs.tagging.outputs.version }}
issue_number: ${{ github.event.pull_request.number || 0 }}
dry_run: ${{ inputs.dry_run || false }}
secrets: inherit
+1 -1
View File
@@ -38,7 +38,7 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
+23 -41
View File
@@ -13,50 +13,32 @@ jobs:
runs-on: ubuntu-latest
defaults:
run:
# set for building docs
working-directory: ./docs
steps:
# - name: Wait for other docs build to succeed
# uses: lewagon/wait-on-check-action@v1.2.0
# with:
# running-workflow-name: 'Docs CN Mirror Deploy'
# check-name: 'Build Docs'
# ref: ${{ github.ref }}
# repo-token: ${{ secrets.GITHUB_TOKEN }}
# allowed-conclusions: success,skipped,cancelled
# wait-interval: 10
- name: Checkout
uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v3
- name: Use pnpm
uses: pnpm/action-setup@v2
- name: Use pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18
cache: "pnpm"
- name: Setup node
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Install dependencies
run: pnpm install
- name: Build Docs
run: pnpm build:docs
- name: Build Docs
run: pnpm docs:build
- name: Deploy
uses: TencentCloud/cos-action@v1
with:
secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
cos_bucket: ${{ secrets.DOCS_CN_COS_BUCKET }}
cos_region: ${{ secrets.DOCS_CN_COS_REGION }}
local_path: .vitepress/dist/
remote_path: /
clean: true
- name: Deploy
uses: TencentCloud/cos-action@v1
with:
secret_id: ${{ secrets.TENCENT_CLOUD_SECRET_ID }}
secret_key: ${{ secrets.TENCENT_CLOUD_SECRET_KEY }}
cos_bucket: ${{ secrets.DOCS_CN_COS_BUCKET }}
cos_region: ${{ secrets.DOCS_CN_COS_REGION }}
local_path: .vitepress/dist/
remote_path: /
clean: true
+46 -52
View File
@@ -1,5 +1,5 @@
name: 📦 Release New Version
run-name: 📦 Release ${{ inputs.custom || inputs.semver }} by @${{ github.actor }}
name: 0x📦 Release New Version
run-name: 📦 Release ${{ inputs.semver }} by @${{ github.actor }} ${{ inputs.dry_run && '(🧪 Dry-Run)' || '' }}
on:
workflow_dispatch:
@@ -12,49 +12,40 @@ on:
- minor
- major
required: true
# custom:
# description: 'Custom tag name (i.e v1.0.0-rc.1)'
# required: false
# default: ''
env:
REPO_DISPATCH_EVENT_TYPE: 'artalk-release'
UI_NPM_PKG_FILE: 'ui/packages/artalk/package.json'
dry_run:
description: 'Dry run?'
type: boolean
default: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Git Fetch
run: git fetch --prune --unshallow --tags -f
uses: actions/checkout@v4
with:
ref: master
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18.x
registry-url: https://registry.npmjs.org/
- name: Setup semver
run: npm install -g semver
- name: Handle Version Number
run: |
if [ ! -z "${{ inputs.custom }}" ]; then
next_version="${{ inputs.custom }}"
else
npm install -g semver
prev_version="$(git describe --tags --abbrev=0)"
echo "prev_version: ${prev_version}"
next_version="v$(semver --increment ${{ inputs.semver }} ${prev_version})"
fi
PREV_VERSION="$(git describe --tags --abbrev=0)"
NEXT_VERSION="v$(semver --increment ${{ inputs.semver }} ${PREV_VERSION})"
if [[ ! "${next_version}" =~ ^v.* ]]; then
echo "[err] custom tag name must be v*."
exit 1
fi
echo "PREV_VERSION=${PREV_VERSION}" >> $GITHUB_ENV
echo "VERSION=${NEXT_VERSION}" >> $GITHUB_ENV
echo "next_version: ${next_version}"
echo "VERSION=${next_version}" >> $GITHUB_ENV
- name: Print Next Version
run: echo "${VERSION}"
- name: Setup git-chglog
run: |
@@ -62,32 +53,35 @@ jobs:
| grep -oP '"https://.+linux_amd64.tar.gz"' | tr -d \") | tar -C /usr/local/bin -xz git-chglog
git-chglog --version
- name: Version Changelog and Tagging
- name: Version Changelog
run: |
if [ ! $(git tag -l "${VERSION}") ]; then
# prepend changelog
changelog=$(git-chglog --config .github/chglog/config.yml --next-tag "${VERSION}" "${VERSION}")
echo -e "${changelog}\n" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md
# prepend changelog
changelog=$(git-chglog --config .github/chglog/config.yml --next-tag "${VERSION}" "${VERSION}")
echo -e "${changelog}\n" | cat - CHANGELOG.md > temp && mv temp CHANGELOG.md
# modify the version of `package.json`
perl -i -pe 's/"version": ".*?"/"version": "'${VERSION#v}'"/g' "${UI_NPM_PKG_FILE}"
# modify the version of `package.json`
perl -i -pe 's/"version": ".*?"/"version": "'${VERSION#v}'"/g' ui/artalk/package.json
# modify the version in docs
perl -pi -e 's#"latest"(\W+)?:(\W+)?".*?"#"latest": "'${VERSION#v}'"#g' docs/code/ArtalkVersion.json
# modify the version in docs
perl -pi -e 's#"latest"(\W+)?:(\W+)?".*?"#"latest": "'${VERSION#v}'"#g' docs/docs/code/ArtalkVersion.json
# git commit and push
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git add .
git commit -m "chore: release ${VERSION}"
git tag "${VERSION}"
- name: Print Git Diff
run: git diff
git push origin master "${VERSION}"
else
echo "skipped because git tag already exists."
fi
- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v2
- name: Create Pull Request
uses: peter-evans/create-pull-request@v5
if: ${{ !inputs.dry_run }}
with:
event-type: ${{ env.REPO_DISPATCH_EVENT_TYPE }}
branch: "release/${{ env.VERSION }}"
commit-message: "chore: release ${{ env.VERSION }}"
title: "chore: release ${{ env.VERSION }}"
labels: release
body: |
## Release ${{ env.VERSION }} 📦🚀
This PR is auto-generated, please check the changelog and confirm the release. 😀
The build workflow will be triggered after the PR is merged.
committer: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
assignees: ${{ github.actor }}
+31
View File
@@ -0,0 +1,31 @@
name: Test Docs
on:
push:
paths: ['docs/**']
pull_request:
paths: ['docs/**']
branches: ['!release/*']
jobs:
test_docs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Use pnpm
uses: pnpm/action-setup@v2
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
cache: pnpm
- name: Install dependencies
run: pnpm install
- name: Build Docs
run: pnpm build:docs
+11 -14
View File
@@ -2,11 +2,10 @@ name: Test Frontend
on:
push:
paths:
- 'ui/**'
paths: ['ui/**']
pull_request:
paths:
- 'ui/**'
paths: ['ui/**']
branches: ['!release/*']
jobs:
test_ui:
@@ -17,13 +16,9 @@ jobs:
runs-on: ${{ matrix.os }}
defaults:
run:
working-directory: ./ui
steps:
- name: Checkout Code
uses: actions/checkout@v3
uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
@@ -34,14 +29,16 @@ jobs:
with:
node-version: ${{ matrix.node }}
cache: pnpm
cache-dependency-path: './ui/pnpm-lock.yaml'
- name: Install Dependencies
run: pnpm --dir ./ui install --frozen-lockfile
run: pnpm install --frozen-lockfile
- name: Package Build Test
run: pnpm build:all
# TODO: Add unit test
# - name: Unit test
# run: pnpm test
- name: Unit test
run: pnpm test
# https://github.com/arethetypeswrong/arethetypeswrong.github.io
- name: 'arethetypeswrong test'
run: pnpm -F artalk attw
View File
File renamed without changes.
View File
File renamed without changes.
-1
View File
@@ -1,5 +1,4 @@
{
"eslint.workingDirectories": ["./ui"],
"cSpell.words": [
"akismet",
"artalk",
+60
View File
@@ -1,4 +1,64 @@
## [v2.7.3](https://github.com/ArtalkJS/Artalk/compare/v2.7.2...v2.7.3) (2023-12-28)
### Features
* **ci:** add dry-run mode for build workflow
* **cmd:** support cli flag for creating admin account
### Bug Fixes
* **ui/init:** stack overflow when merging with config defaults ([#717](https://github.com/ArtalkJS/Artalk/issues/717))
### Performance Improvements
* **ui/build:** better dts generation ([#689](https://github.com/ArtalkJS/Artalk/issues/689))
### Code Refactoring
* **ci:** better release workflow
* **docker:** add `--build-arg` argument to skip ui build
* **test/ui:** add more ui api tests
* **ui:** refactor directory structure ([#712](https://github.com/ArtalkJS/Artalk/issues/712))
* **ui/conf:** better handling of mutable config ([#722](https://github.com/ArtalkJS/Artalk/issues/722))
* **ui/test:** add vitest for unit testing
### Documentation
* update ui api documentation
### BREAKING CHANGE
Directly referencing `artalk.conf` and `artalk.$root` is deprecated. Please use functions instead: `artalk.getConf()` and `artalk.getEl()`.
## [v2.7.2](https://github.com/ArtalkJS/Artalk/compare/v2.7.1...v2.7.2) (2023-12-20)
### Features
* patch `locale` config from `zh-cn` to `zh-CN` ([#678](https://github.com/ArtalkJS/Artalk/issues/678))
### Bug Fixes
* **sidebar:** sidebar language switch and config save issue ([#708](https://github.com/ArtalkJS/Artalk/issues/708))
* **ui:** add `referrerpolicy` attribute for iframe ([#687](https://github.com/ArtalkJS/Artalk/issues/687)) ([#707](https://github.com/ArtalkJS/Artalk/issues/707))
* **ui/dark-mode:** potential memory leak issue in auto mode ([#688](https://github.com/ArtalkJS/Artalk/issues/688))
* **ui/pagination:** auto switch page by url hashtag issue ([#693](https://github.com/ArtalkJS/Artalk/issues/693))
* **ui/sidebar:** refactor settings and fix save issue ([#677](https://github.com/ArtalkJS/Artalk/issues/677)) ([#706](https://github.com/ArtalkJS/Artalk/issues/706))
### Code Refactoring
* **ui:** move window references into function scope ([#675](https://github.com/ArtalkJS/Artalk/issues/675))
* **ui/api:** losing coupling between `Api` and `User`
* **ui/user:** user class no longer globally singleton
### Documentation
* **i18n:** add translation for `open` button
* **refactor:** organize the pkgs and fix some issues ([#702](https://github.com/ArtalkJS/Artalk/issues/702))
## [v2.7.1](https://github.com/ArtalkJS/Artalk/compare/v2.7.0...v2.7.1) (2023-12-17)
### Bug Fixes
+4 -4
View File
@@ -41,9 +41,9 @@ The backend program will run by default on port `23366`. You can access it throu
### Build Frontend
First, you need to install the dependencies for the frontend. Simply run the `cd ui && pnpm install` command to install the dependencies.
First, you need to install the dependencies for the frontend. Simply run the `pnpm install` command to install the dependencies.
Then, run the `cd ui && pnpm dev` to build and run the frontend, and you can pass startup parameters to the program using `ARGS="--port 5173" pnpm dev`.
Then, run the `pnpm dev` to build and run the frontend, and you can pass startup parameters to the program using `ARGS="--port 5173" pnpm dev`.
The frontend program will run by default on port `5173`, and you can access it in a browser at `http://localhost:5173`. The frontend testing client will, by default, request the backend on port `23366`, so it's essential to keep the backend on this port.
@@ -51,9 +51,9 @@ The frontend program is divided into the main program and a sidebar program, wit
### Development Workflow
In most cases, to set up a complete development instance, you need to navigate to the Artalk Repo directory and then execute `make dev`. This will run the backend on port `23366`. Then, execute `cd ui && pnpm dev`, which will run the frontend on port `5173`. You can optionally execute `pnpm dev:sidebar` to run the sidebar frontend on port `23367`. For frontend development, you need to access `http://localhost:5173` in your browser to perform your development and testing.
In most cases, to set up a complete development instance, you need to navigate to the Artalk Repo directory and then execute `make dev`. This will run the backend on port `23366`. Then, execute `pnpm dev`, which will run the frontend on port `5173`. You can optionally execute `pnpm dev:sidebar` to run the sidebar frontend on port `23367`. For frontend development, you need to access `http://localhost:5173` in your browser to perform your development and testing.
When you make changes to the frontend code, you can build the complete frontend program using `cd ui && pnpm build:all`. The JavaScript and CSS code can be found in `ui/packages/artalk/dist`.
When you make changes to the frontend code, you can build the complete frontend program using `pnpm build:all`. The JavaScript and CSS code can be found in `ui/artalk/dist`.
When you make changes to the backend code, running `make all` will build the complete backend program. Note that since the backend program also embeds the frontend code, the `scripts/build-frontend.sh` script will run during backend program building, which includes the embedded frontend main program and sidebar frontend program. If you are interested, you can explore the complete frontend build process in the `Makefile` code.
+22 -5
View File
@@ -5,8 +5,7 @@ WORKDIR /source
# install tools
RUN set -ex \
&& apk add --no-cache make git gcc musl-dev nodejs bash npm\
&& npm install -g pnpm@8.12.1
&& apk add --no-cache make git gcc musl-dev bash
# download go deps
# (cache by separating the downloading of deps)
@@ -16,10 +15,28 @@ RUN go mod download
# copy source code
COPY . .
# build
## build UI
ARG SKIP_UI_BUILD=false
# install ui build toolchain
RUN set -ex \
&& export VERSION=$(git describe --tags --abbrev=0) \
&& export COMMIT_SHA=$(git rev-parse --short HEAD) \
&& if [ "$SKIP_UI_BUILD" = "false" ]; then \
apk add --no-cache nodejs npm \
&& npm install -g pnpm@8.12.1 \
;fi
RUN set -ex \
&& if [ "$SKIP_UI_BUILD" = "false" ]; then \
make build-frontend \
;fi
## build App
ARG APP_VERSION=""
ARG APP_COMMIT_HASH=""
RUN set -ex \
&& if [[ ! -z "$APP_VERSION" ]]; then export VERSION=$APP_VERSION ;fi \
&& if [[ ! -z "$APP_COMMIT_HASH" ]]; then export COMMIT_HASH=$APP_COMMIT_HASH ;fi \
&& make build
### build final image
+2 -3
View File
@@ -1,8 +1,7 @@
PKG_NAME := github.com/ArtalkJS/Artalk
BIN_NAME := ./bin/artalk
VERSION ?= $(shell git describe --tags --abbrev=0)
COMMIT_HASH := $(shell git rev-parse --short HEAD)
DEV_VERSION := dev-$(COMMIT_HASH)
COMMIT_HASH ?= $(shell git rev-parse --short HEAD)
HAS_RICHGO := $(shell which richgo)
GOTEST ?= $(if $(HAS_RICHGO), richgo test, go test)
@@ -13,7 +12,7 @@ all: install build
install:
go mod tidy
build: build-frontend
build:
go build \
-ldflags "-s -w -X $(PKG_NAME)/internal/config.Version=$(VERSION) \
-X $(PKG_NAME)/internal/config.CommitHash=$(COMMIT_HASH)" \
+15 -3
View File
@@ -25,9 +25,17 @@ func NewAdminCommand(app *ArtalkCmd) *cobra.Command {
fmt.Println(" " + i18n.T("Create admin account"))
fmt.Println("--------------------------------")
username, email, password, err := credentials()
if err != nil {
log.Fatal(err)
// get from flags
username, _ := cmd.Flags().GetString("name")
email, _ := cmd.Flags().GetString("email")
password, _ := cmd.Flags().GetString("password")
if username == "" || email == "" || password == "" {
var err error
username, email, password, err = credentials()
if err != nil {
log.Fatal(err)
}
}
findUser := app.Dao().FindUser(username, email)
@@ -62,6 +70,10 @@ func NewAdminCommand(app *ArtalkCmd) *cobra.Command {
},
}
flag(adminCmd, "name", "", i18n.T("Username"))
flag(adminCmd, "email", "", i18n.T("Email"))
flag(adminCmd, "password", "", i18n.T("Password"))
return adminCmd
}
-3
View File
@@ -1,3 +0,0 @@
/.vitepress/dist/
/.vitepress/cache/
/public/http-api.html
-2
View File
@@ -1,2 +0,0 @@
shamefully-hoist=true
auto-install-peers=true
-211
View File
@@ -1,211 +0,0 @@
import { defineConfig } from 'vitepress'
import iterator from 'markdown-it-for-inline'
import * as Version from '../code/ArtalkVersion.json'
export default defineConfig({
title: 'Artalk',
description: '一款简洁的自托管评论系统',
lang: 'zh-CN',
head: [
['link', { rel: 'icon', href: '/favicon.png' }],
['meta', { name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi' }],
// artalk
// ['link', { href: `https://npm.elemecdn.com/artalk@${Version.latest}/dist/Artalk.css`, rel: 'stylesheet' }],
['link', { href: `https://artalk.qwqaq.com/dist/Artalk.css`, rel: 'stylesheet' }],
// ['script', { src: ArtalkCDN.JS }],
// light gallery
['link', { href: 'https://npm.elemecdn.com/lightgallery@2.3.0/css/lightgallery.css', rel: 'stylesheet' }],
['script', { src: 'https://npm.elemecdn.com/lightgallery@2.3.0/lightgallery.min.js' }],
// katex
// ['link', { href: "https://npm.elemecdn.com/katex@0.15.3/dist/katex.min.css", rel: 'stylesheet' }],
// ['script', { src: 'https://npm.elemecdn.com/katex@0.15.3/dist/katex.min.js' }],
// ['script', { src: 'https://npm.elemecdn.com/@artalkjs/plugin-katex/dist/artalk-plugin-katex.js' }],
],
lastUpdated: true,
markdown: {
// @link https://github.com/shikijs/shiki
theme: {
light: 'github-light',
dark: 'github-dark',
},
config: (md) => {
md.use(iterator, 'artalk_version', 'text', function (tokens, idx) {
tokens[idx].content = tokens[idx].content.replace(/:ArtalkVersion:/g, Version.latest)
});
md.use(iterator, 'artalk_version_link', 'link_open', (tokens, idx) => {
const href = tokens[idx].attrGet('href')
tokens[idx].attrSet('href', href.replace(/:ArtalkVersion:/g, Version.latest))
});
},
},
locales: {
root: {
label: '简体中文',
lang: 'zh'
},
en: {
label: 'English',
lang: 'en',
link: 'https://artalk-js-org.translate.goog/guide/intro?_x_tr_sl=auto&_x_tr_tl=en-US&_x_tr_hl=en-US&_x_tr_pto=wapp'
// link: '/en/'
}
},
themeConfig: {
sidebar: {
"/guide/": [
{
text: "快速开始",
collapsed: false,
items: [
{ text: '项目介绍', link: '/guide/intro.md' },
{ text: '程序部署', link: '/guide/deploy.md' },
{ text: '数据迁移', link: '/guide/transfer.md' },
]
},
{
text: "核心指南",
collapsed: false,
items: [
{ text: '侧边栏', link: '/guide/frontend/sidebar.md' },
{ text: '邮件通知', link: '/guide/backend/email.md' },
{ text: '多元推送', link: '/guide/backend/admin_notify.md' },
{ text: '评论审核', link: '/guide/backend/moderator.md' },
{ text: '验证码', link: '/guide/backend/captcha.md' },
{ text: '图片上传', link: '/guide/backend/img-upload.md' },
{ text: '账户与多站点', link: '/guide/backend/multi-site.md' },
{ text: '解析相对路径', link: '/guide/backend/relative-path.md' },
{ text: '如何配置界面', link: '/guide/backend/fe-control.md' },
{ text: 'English (i18n)', link: '/guide/frontend/i18n.md' },
]
},
{
text: "进阶指南",
collapsed: false,
items: [
{ text: '表情包', link: '/guide/frontend/emoticons.md' },
{ text: '浏览量统计', link: '/guide/frontend/pv.md' },
{ text: 'Latex', link: '/guide/frontend/latex.md' },
{ text: '图片灯箱', link: '/guide/frontend/lightbox.md' },
{ text: 'IP 归属地', link: '/guide/frontend/ip-region.md' },
{ text: '精简版本', link: '/guide/frontend/artalk-lite.md' },
{ text: '置入博客', link: '/guide/frontend/import-blog.md' },
{ text: '置入框架', link: '/guide/frontend/import-framework.md' },
{ text: '前端 API', link: '/develop/fe-api.md', },
{ text: '开发文档', link: '/develop/index.md', },
],
},
{
text: "配置文档",
collapsed: true,
items: [
{ text: '后端配置', link: '/guide/backend/config.md' },
{ text: '前端配置', link: '/guide/frontend/config.md' },
]
},
{
text: "部署说明",
collapsed: true,
items: [
{ text: '守护进程', link: '/guide/backend/daemon.md' },
{ text: '反向代理', link: '/guide/backend/reverse-proxy.md' },
{ text: '编译构建', link: '/guide/backend/build.md' },
{ text: '程序升级', link: '/guide/backend/update.md' },
{ text: 'Docker', link: '/guide/backend/docker.md' },
]
},
{
text: '更多内容',
collapsed: true,
items: [
{ text: '安全防范', link: '/guide/security.md' },
{ text: '扩展阅读', link: '/guide/extras.md' },
{ text: '案例展示', link: '/guide/cases.md' },
{ text: '关于我们', link: '/guide/about.md' },
]
}
],
"/develop/": [
{
text: '开发文档',
items: [
{ text: '开发说明', link: '/develop/index.md', },
{ text: '前端 API', link: '/develop/fe-api.md', },
{ text: '前端 Event', link: '/develop/event.md', },
{ text: '插件开发', link: '/develop/plugs.md' },
{ text: '🔬 HTTP API', link: 'https://artalk.js.org/http-api.html', },
{ text: '📖 Contributing Guide', link: 'https://github.com/ArtalkJS/Artalk/blob/master/CONTRIBUTING.md' },
{ text: '🔖 Code of Conduct', link: 'https://github.com/ArtalkJS/Artalk/blob/master/CODE_OF_CONDUCT.md' },
]
}
]
},
nav: [
// NavbarItem
{
text: '介绍',
link: '/guide/intro',
},
{
text: '部署',
link: '/guide/deploy',
},
{
text: '配置',
link: '/guide/backend/config',
},
{
text: '迁移',
link: '/guide/transfer',
},
{
text: '案例',
link: '/guide/cases',
},
{
text: '开发',
link: '/develop/',
},
// NavbarGroup
{
text: '传送',
items: [
{
text: '代码仓库',
link: 'https://github.com/ArtalkJS/Artalk',
},
{
text: '文档镜像 (国内)',
link: 'https://artalk-docs.qwqaq.com'
}
],
},
],
socialLinks: [
{ icon: 'github', link: 'https://github.com/ArtalkJS/Artalk' }
],
search: {
provider: 'algolia',
options: {
appId: '2WNJ32WVTY',
apiKey: '6c6ebc345a87b738264f19095b78c91c',
indexName: 'artalk-js',
searchParameters: {
facetFilters: ['lang:zh-CN']
}
}
},
editLink: {
pattern: 'https://github.com/ArtalkJS/Artalk/edit/master/docs/:path',
text: '完善文档'
},
}
})
-3
View File
@@ -1,3 +0,0 @@
{
"latest": "2.7.1"
}
+2
View File
@@ -0,0 +1,2 @@
.vitepress/dist/**
.vitepress/cache/**
+253
View File
@@ -0,0 +1,253 @@
import { defineConfig } from "vitepress";
import iterator from "markdown-it-for-inline";
import * as Version from "../code/ArtalkVersion.json";
export default defineConfig({
title: "Artalk",
description: "一款简洁的自托管评论系统",
lang: "zh-CN",
head: [
["link", { rel: "icon", href: "/favicon.png" }],
[
"meta",
{
name: "viewport",
content:
"width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi",
},
],
// artalk
// ['link', { href: `https://npm.elemecdn.com/artalk@${Version.latest}/dist/Artalk.css`, rel: 'stylesheet' }],
[
"link",
{ href: `https://artalk.qwqaq.com/dist/Artalk.css`, rel: "stylesheet" },
],
// ['script', { src: ArtalkCDN.JS }],
// light gallery
[
"link",
{
href: "https://npm.elemecdn.com/lightgallery@2.3.0/css/lightgallery.css",
rel: "stylesheet",
},
],
[
"script",
{
src: "https://npm.elemecdn.com/lightgallery@2.3.0/lightgallery.min.js",
},
],
// katex
// ['link', { href: "https://npm.elemecdn.com/katex@0.15.3/dist/katex.min.css", rel: 'stylesheet' }],
// ['script', { src: 'https://npm.elemecdn.com/katex@0.15.3/dist/katex.min.js' }],
// ['script', { src: 'https://npm.elemecdn.com/@artalkjs/plugin-katex/dist/artalk-plugin-katex.js' }],
],
lastUpdated: true,
markdown: {
// @link https://github.com/shikijs/shiki
theme: {
light: "github-light",
dark: "github-dark",
},
config: (md) => {
md.use(iterator, "artalk_version", "text", function (tokens, idx) {
tokens[idx].content = tokens[idx].content.replace(
/:ArtalkVersion:/g,
Version.latest
);
});
md.use(iterator, "artalk_version_link", "link_open", (tokens, idx) => {
const href = tokens[idx].attrGet("href");
tokens[idx].attrSet(
"href",
href.replace(/:ArtalkVersion:/g, Version.latest)
);
});
},
},
locales: {
root: {
label: "简体中文",
lang: "zh",
link: "https://artalk.js.org/",
},
en: {
label: "English",
lang: "en",
link: "https://artalk-js-org.translate.goog/guide/intro?_x_tr_sl=auto&_x_tr_tl=en-US&_x_tr_hl=en-US&_x_tr_pto=wapp",
},
},
themeConfig: {
sidebar: {
"/guide/": [
{
text: "快速开始",
collapsed: false,
items: [
{ text: "项目介绍", link: "/guide/intro.md" },
{ text: "程序部署", link: "/guide/deploy.md" },
{ text: "数据迁移", link: "/guide/transfer.md" },
],
},
{
text: "核心指南",
collapsed: false,
items: [
{ text: "侧边栏", link: "/guide/frontend/sidebar.md" },
{ text: "邮件通知", link: "/guide/backend/email.md" },
{ text: "多元推送", link: "/guide/backend/admin_notify.md" },
{ text: "评论审核", link: "/guide/backend/moderator.md" },
{ text: "验证码", link: "/guide/backend/captcha.md" },
{ text: "图片上传", link: "/guide/backend/img-upload.md" },
{ text: "账户与多站点", link: "/guide/backend/multi-site.md" },
{ text: "解析相对路径", link: "/guide/backend/relative-path.md" },
{ text: "如何配置界面", link: "/guide/backend/fe-control.md" },
{ text: "English (i18n)", link: "/guide/frontend/i18n.md" },
],
},
{
text: "进阶指南",
collapsed: false,
items: [
{ text: "表情包", link: "/guide/frontend/emoticons.md" },
{ text: "浏览量统计", link: "/guide/frontend/pv.md" },
{ text: "Latex", link: "/guide/frontend/latex.md" },
{ text: "图片灯箱", link: "/guide/frontend/lightbox.md" },
{ text: "IP 归属地", link: "/guide/frontend/ip-region.md" },
{ text: "精简版本", link: "/guide/frontend/artalk-lite.md" },
{ text: "置入博客", link: "/guide/frontend/import-blog.md" },
{ text: "置入框架", link: "/guide/frontend/import-framework.md" },
{ text: "前端 API", link: "/develop/fe-api.md" },
{ text: "开发文档", link: "/develop/index.md" },
],
},
{
text: "配置文档",
collapsed: true,
items: [
{ text: "后端配置", link: "/guide/backend/config.md" },
{ text: "前端配置", link: "/guide/frontend/config.md" },
],
},
{
text: "部署说明",
collapsed: true,
items: [
{ text: "守护进程", link: "/guide/backend/daemon.md" },
{ text: "反向代理", link: "/guide/backend/reverse-proxy.md" },
{ text: "编译构建", link: "/guide/backend/build.md" },
{ text: "程序升级", link: "/guide/backend/update.md" },
{ text: "Docker", link: "/guide/backend/docker.md" },
],
},
{
text: "更多内容",
collapsed: true,
items: [
{ text: "安全防范", link: "/guide/security.md" },
{ text: "扩展阅读", link: "/guide/extras.md" },
{ text: "案例展示", link: "/guide/cases.md" },
{ text: "关于我们", link: "/guide/about.md" },
],
},
],
"/develop/": [
{
text: "开发文档",
items: [
{ text: "开发说明", link: "/develop/index.md" },
{ text: "前端 API", link: "/develop/fe-api.md" },
{ text: "前端 Event", link: "/develop/event.md" },
{ text: "插件开发", link: "/develop/plugs.md" },
{
text: "🔬 HTTP API",
link: "https://artalk.js.org/http-api.html",
},
{
text: "📖 Contributing Guide",
link: "https://github.com/ArtalkJS/Artalk/blob/master/CONTRIBUTING.md",
},
{
text: "🔖 Code of Conduct",
link: "https://github.com/ArtalkJS/Artalk/blob/master/CODE_OF_CONDUCT.md",
},
],
},
],
},
nav: [
// NavbarItem
{
text: "介绍",
link: "/guide/intro",
},
{
text: "部署",
link: "/guide/deploy",
},
{
text: "配置",
link: "/guide/backend/config",
},
{
text: "迁移",
link: "/guide/transfer",
},
{
text: "案例",
link: "/guide/cases",
},
{
text: "开发",
link: "/develop/",
},
// NavbarGroup
{
text: "传送",
items: [
{
text: "代码仓库",
link: "https://github.com/ArtalkJS/Artalk",
},
{
text: "文档镜像 (国内)",
link: "https://artalk-docs.qwqaq.com",
},
],
},
],
socialLinks: [
{ icon: "github", link: "https://github.com/ArtalkJS/Artalk" },
],
search: {
provider: "algolia",
options: {
appId: "2WNJ32WVTY",
apiKey: "6c6ebc345a87b738264f19095b78c91c",
indexName: "artalk-js",
searchParameters: {
facetFilters: ["lang:zh-CN"],
},
},
},
editLink: {
pattern: "https://github.com/ArtalkJS/Artalk/edit/master/docs/:path",
text: "完善文档",
},
},
vite: {
server: {
open: "/guide/intro.html",
},
},
});
@@ -1,13 +1,11 @@
<template>
<ClientOnly>
<div ref="el" style="margin-top: 20px;"></div>
</ClientOnly>
<div ref="el" style="margin-top: 20px;"></div>
</template>
<script setup lang="ts">
import { watch, nextTick, ref, onMounted, onUnmounted } from 'vue'
import { useData, useRouter } from 'vitepress'
import type Artalk from 'artalk'
import Artalk from 'artalk'
const el = ref<HTMLElement | null>(null)
@@ -17,10 +15,12 @@ const page = useData().page
let artalk: Artalk
onMounted(() => {
initArtalk(getConfByPage())
nextTick(() => {
initArtalk(getConfByPage())
})
})
watch(() => router.route.data.relativePath, () => {
watch(() => router.route.path, () => {
nextTick(() => {
artalk.update(getConfByPage())
artalk.reload()
@@ -32,23 +32,21 @@ onUnmounted(() => {
})
function initArtalk(conf: any) {
import('artalk').then(({ default: Artalk }) => {
artalk = Artalk.init({
el: el.value,
emoticons: '/assets/emoticons/default.json',
gravatar: {
mirror: 'https://cravatar.cn/avatar/'
},
...conf
})
}).then(() => {
loadExtraFuncs()
artalk = Artalk.init({
el: el.value,
emoticons: '/assets/emoticons/default.json',
gravatar: {
mirror: 'https://cravatar.cn/avatar/'
},
...conf
})
loadExtraFuncs()
}
function getConfByPage() {
return {
pageKey: 'https://artalk.js.org'+location.pathname,
pageKey: 'https://artalk.js.org'+router.route.path,
pageTitle: page.value.title,
server: 'https://artalk.qwqaq.com',
site: 'ArtalkDocs',
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+7 -6
View File
@@ -1,19 +1,20 @@
## Artalk Documentation
# Artalk Documentation
> The Documentation of Artalk
[![Netlify Status](https://api.netlify.com/api/v1/badges/6580cce0-4b27-465e-8d73-1e6a832942e9/deploy-status)](https://app.netlify.com/sites/artalk/deploys)
Documentation of Artalk
## Build
```bash
pnpm docs:dev
pnpm docs:build
pnpm dev:docs
pnpm build:docs
```
## Deploy
[![Netlify Status](https://api.netlify.com/api/v1/badges/6580cce0-4b27-465e-8d73-1e6a832942e9/deploy-status)](https://app.netlify.com/sites/artalk/deploys)
文档通过 [Netlify](https://www.netlify.com/) 对 master 分支进行自动部署。
## Licensed
CC BY-NC-SA 4.0
File renamed without changes.
File renamed without changes.
+3
View File
@@ -0,0 +1,3 @@
{
"latest": "2.7.3"
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -30,7 +30,7 @@
| `sidebar-hide` | 侧边栏隐藏 |
事件声明代码:[@ArtalkJS/Artalk - types/event.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/types/event.ts)
事件声明代码:[@ArtalkJS/Artalk - types/event.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/types/event.ts)
## 添加事件监听
@@ -157,3 +157,23 @@ artalk.setDarkMode(true)
## 浏览量组件 `loadCountWidget`
详情见:[浏览量统计](../guide/frontend/pv.md)
## 获取配置 `getConf`
获取当前 Artalk 配置。
```js
const artalk = Artalk.init({ ... })
const conf = artalk.getConf()
```
## 获取挂载元素 `getEl`
获取当前 Artalk 挂载的 DOM 元素。
```js
const artalk = Artalk.init({ ... })
const el = artalk.getEl()
```
@@ -19,10 +19,10 @@
由于 Artalk 正处于开发阶段,使用此文档中 `API`、`Event` 前请务必检查时效性。
- `API` 部分参考源码
* [@ArtalkJS/Artalk - src/api/](https://github.com/ArtalkJS/Artalk/tree/master/ui/packages/artalk/src/api)
* [@ArtalkJS/Artalk - src/api/](https://github.com/ArtalkJS/Artalk/tree/master/ui/artalk/src/api)
* [@ArtalkJS/Artalk - server/server.go](https://github.com/ArtalkJS/Artalk/blob/master/server/server.go)
- `UI` 及 `Event` 部分参考源码
* [@ArtalkJS/Artalk - src/artalk.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/src/artalk.ts)
* [@ArtalkJS/Artalk - types/event.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/types/event.ts)
* [@ArtalkJS/Artalk - src/artalk.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/artalk.ts)
* [@ArtalkJS/Artalk - types/event.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/types/event.ts)
通过 Artalk 提供的 `API` 和 `Event`,你可以实现很多高级功能,比如编写评论管理机器人、评论提醒推送插件等。Artalk 并不为此提供技术指导,但鼓励你参考此处的文档自行定制。
@@ -46,7 +46,7 @@ Context 对象包含了 Artalk 的上下文信息。
Context API 目前仍不稳定,开发可能会有变动,升级请关注 CHANGELOG。
:::
参考:[@artalk/types/context.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/types/context.ts)
参考:[@artalk/types/context.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/types/context.ts)
Artalk 拥有完整的 TypeScript 类型定义,你可以通过编辑器的自动补全来查看 API。
@@ -54,11 +54,11 @@ Artalk 拥有完整的 TypeScript 类型定义,你可以通过编辑器的自
Artalk 有很多内置的插件,你可以参考它们的源码来开发自己的插件。
[@ArtalkJS/Artalk - src/plugins](https://github.com/ArtalkJS/Artalk/tree/master/ui/packages/artalk/src/plugins)
[@ArtalkJS/Artalk - src/plugins](https://github.com/ArtalkJS/Artalk/tree/master/ui/artalk/src/plugins)
我们还提供了一些外置的插件,同样可以参考:
| 插件 | 说明 |
| --- | --- |
| [@artalk/plugin-katex](https://github.com/ArtalkJS/Artalk/tree/master/ui/packages/plugin-katex) | LaTeX 公式插件 |
| [@artalk/plugin-lightbox](https://github.com/ArtalkJS/Artalk/tree/master/ui/packages/plugin-lightbox) | 图片灯箱插件 |
| [@artalk/plugin-katex](https://github.com/ArtalkJS/Artalk/tree/master/ui/plugin-katex) | LaTeX 公式插件 |
| [@artalk/plugin-lightbox](https://github.com/ArtalkJS/Artalk/tree/master/ui/plugin-lightbox) | 图片灯箱插件 |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -6,8 +6,8 @@ const artalk = Artalk.init({ ... })
artalk.update({ ... })
```
- 默认配置:[defaults.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/src/defaults.ts)
- 声明文件:[config.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/types/config.ts)
- 默认配置:[defaults.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/defaults.ts)
- 声明文件:[config.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/types/config.ts)
## 轻松配置
@@ -179,7 +179,7 @@ JS DELIVR 在中国大陆的 [ICP 牌照已被吊销](https://github.com/jsdeliv
artalk.setDarkMode(true)
```
> 参考代码:“[index.html](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/index.html#L97-L150)”
> 参考代码:“[index.html](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/index.html#L97-L150)”
可设置为 `"auto"`,Artalk 将监听 `(prefers-color-scheme: dark)` 根据用户操作系统判断自动切换夜间模式。
File renamed without changes.
@@ -22,7 +22,7 @@ locale 配置项格式遵循 Unicode BCP 47 规范,默认为 "zh-CN" (简体
|翻译内容|语言文件目录|模板文件|
|-|-|-|
|后端程序|[/i18n/[LANG].yml](https://github.com/ArtalkJS/Artalk/tree/master/i18n)|[zh-CN.yml](https://github.com/ArtalkJS/Artalk/blob/master/i18n/zh-CN.yml)|
|前端界面|[/ui/packages/artalk/src/i18n/[LANG].ts](https://github.com/ArtalkJS/Artalk/tree/master/ui/packages/artalk/src/i18n)|[zh-CN.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/src/i18n/zh-CN.ts)|
|前端界面|[/ui/artalk/src/i18n/[LANG].ts](https://github.com/ArtalkJS/Artalk/tree/master/ui/artalk/src/i18n)|[zh-CN.ts](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/i18n/zh-CN.ts)|
|配置文件|[/conf/artalk.example.[LANG].yml](https://github.com/ArtalkJS/Artalk/tree/master/conf)|[artalk.example.zh-CN.yml](https://github.com/ArtalkJS/Artalk/blob/master/conf/artalk.example.zh-CN.yml)
|说明文档|[/docs/[LANG]/**\/*.md](https://github.com/ArtalkJS/Artalk/tree/master/docs)|[/docs/**\/*.md](https://github.com/ArtalkJS/Artalk/tree/master/docs)
@@ -52,7 +52,7 @@ Artalk.init({
### 前端自定义 locale 内容
在前端可传入 Object 类型,按照 [模板文件](https://github.com/ArtalkJS/Artalk/blob/master/ui/packages/artalk/src/i18n/zh-CN.ts) 中的 Keys 编写自定义 locale 内容。
在前端可传入 Object 类型,按照 [模板文件](https://github.com/ArtalkJS/Artalk/blob/master/ui/artalk/src/i18n/zh-CN.ts) 中的 Keys 编写自定义 locale 内容。
```js
Artalk.init({
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -18,7 +18,7 @@ Artalk LightBox 插件能帮助你将网站**现有的图片灯箱**功能自动
目前自动集成支持:[LightGallery](https://github.com/sachinchoolur/lightGallery) [v2.5.0] / [FancyBox](https://github.com/fancyapps/fancybox) [v4.0.27] / [lightbox2](https://github.com/lokesh/lightbox2) [v2.11.3]
对于还未适配的图片灯箱,欢迎提交 PR -> [查看代码](https://github.com/ArtalkJS/Artalk/blob/master/packages/plugin-lightbox/main.ts)
对于还未适配的图片灯箱,欢迎提交 PR -> [查看代码](https://github.com/ArtalkJS/Artalk/blob/master/ui/plugin-lightbox/main.ts)
::: details 附:图片灯箱依赖 CDN 资源
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loaded 100 of 390 files, more files were not shown because too many files have changed in this diff. Show more