├── .editorconfig ├── .eslintrc.cjs ├── .gitignore ├── DEVELOP.md ├── Makefile ├── OWNERS ├── README.md ├── annotation-settings.yaml ├── build.gradle ├── env.d.ts ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── package.json ├── pnpm-lock.yaml ├── postcss.config.js ├── prettier.config.js ├── screenshot.jpg ├── settings.gradle ├── settings.yaml ├── src ├── alpine-data │ ├── color-scheme-switcher.ts │ ├── dropdown.ts │ ├── pagination.ts │ ├── post-util.ts │ └── search.ts ├── main.ts └── styles │ ├── main.css │ └── tailwind.css ├── tailwind.config.cjs ├── templates ├── archives.html ├── assets │ ├── dist │ │ ├── main.iife.js │ │ └── style.css │ └── images │ │ ├── computer.svg │ │ ├── crown.svg │ │ ├── default-avatar.svg │ │ ├── default-background.png │ │ ├── lightning.svg │ │ ├── model.svg │ │ ├── read.svg │ │ └── star.svg ├── categories.html ├── category.html ├── index.html ├── links.html ├── modules │ ├── category-filter.html │ ├── category-sub.html │ ├── category-tree.html │ ├── featured-post-card.html │ ├── footer.html │ ├── header.html │ ├── index │ │ ├── category-filter.html │ │ ├── popular-posts.html │ │ └── tag-filter.html │ ├── layout.html │ ├── post-card.html │ ├── sidebar.html │ ├── tag-filter.html │ └── widgets │ │ ├── categories.html │ │ ├── home.html │ │ ├── latest-comments.html │ │ ├── popular-posts.html │ │ ├── profile.html │ │ └── tags.html ├── page.html ├── post.html ├── tag.html └── tags.html ├── theme.yaml ├── tsconfig.json └── vite.config.ts /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig is awesome: https://EditorConfig.org 2 | 3 | # top-most EditorConfig file 4 | root = true 5 | 6 | [*] 7 | indent_style = space 8 | indent_size = 2 9 | end_of_line = lf 10 | charset = utf-8 11 | trim_trailing_whitespace = false 12 | insert_final_newline = false -------------------------------------------------------------------------------- /.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: "@typescript-eslint/parser", 4 | plugins: ["@typescript-eslint", "prettier"], 5 | extends: [ 6 | "eslint:recommended", 7 | "plugin:@typescript-eslint/eslint-recommended", 8 | "plugin:@typescript-eslint/recommended", 9 | "prettier", 10 | ], 11 | env: { 12 | node: true, 13 | }, 14 | }; 15 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | npm-debug.log* 5 | yarn-debug.log* 6 | yarn-error.log* 7 | pnpm-debug.log* 8 | lerna-debug.log* 9 | 10 | node_modules 11 | .DS_Store 12 | *.local 13 | 14 | # Editor directories and files 15 | .vscode/* 16 | !.vscode/extensions.json 17 | .idea 18 | *.suo 19 | *.ntvs* 20 | *.njsproj 21 | *.sln 22 | *.sw? 23 | 24 | .gradle 25 | build 26 | dist 27 | dist.zip 28 | 29 | -------------------------------------------------------------------------------- /DEVELOP.md: -------------------------------------------------------------------------------- 1 | ## 开发 2 | 3 | ```bash 4 | git clone git@github.com:f2ccloud/theme-ocean.git ~/halo2-dev/themes/theme-ocean 5 | ``` 6 | 7 | ```bash 8 | cd ~/halo2-dev/themes/theme-ocean 9 | ``` 10 | 11 | ```bash 12 | pnpm install 13 | ``` 14 | 15 | ```bash 16 | pnpm dev 17 | ``` 18 | 19 | 主题开发文档可查阅: 20 | 21 | ## 构建 22 | 23 | > 如果你使用的是 Windows 操作系统,请安装 `make` 命令并在 Git Bash 或 WSL 中执行。 24 | 25 | ```bash 26 | make build 27 | ``` 28 | 29 | 然后将 `dist` 目录压缩成 `ZIP` 格式压缩包即可在 Halo 后台上传安装。 30 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | build: clean 2 | echo "Building theme" 3 | pnpm install 4 | pnpm build 5 | echo "Theme built successfully!" 6 | echo "Collect theme dist" 7 | mkdir dist 8 | cp -r templates dist 9 | cp theme.yaml settings.yaml README.md dist 10 | zip -r dist.zip ./dist 11 | 12 | 13 | clean: 14 | echo "Clean dist folder" 15 | rm -rf dist 16 | rm -rf dist.zip 17 | -------------------------------------------------------------------------------- /OWNERS: -------------------------------------------------------------------------------- 1 | reviewers: 2 | - ruibaby 3 | - guqing 4 | - JohnNiang 5 | - lan-yonghui 6 | - wangzhen-fit2cloud 7 | 8 | approvers: 9 | - ruibaby 10 | - guqing 11 | - JohnNiang 12 | 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Theme Ocean - Halo 开源建站工具知识库主题 2 | 3 | [主题预览](https://kb.fit2cloud.com) 4 | 5 | Theme Ocean 是适用于开源建站工具 [Halo](https://halo.run) 的一款知识库主题,适合企业用于对外公开的产品知识库场景。 6 | 7 | 主题基于 Halo 默认主题 [Earth](https://github.com/halo-dev/theme-earth.git) 的基础上进行开发。 8 | 9 | ## 特性 10 | 11 | - 简洁大方的设计 12 | - 全局搜索支持 13 | - 亮色暗色模式切换 14 | - 丰富灵活的主题设置 15 | 16 | ## 使用方式 17 | 1. 下载,前往版本页面安装最新的版本即可,后续有更新也会在此页面发布。 18 | 2. 安装和更新方式可参考:https://docs.halo.run/user-guide/themes 19 | 20 | ## 其他 21 | - [开发相关](./DEVELOP.md) 22 | -------------------------------------------------------------------------------- /annotation-settings.yaml: -------------------------------------------------------------------------------- 1 | spec: 2 | targetRef: 3 | group: content.halo.run 4 | kind: Category 5 | formSchema: 6 | - $formkit: "color" 7 | name: "color" 8 | label: "字体颜色" 9 | apiVersion: v1alpha1 10 | kind: AnnotationSetting 11 | metadata: 12 | generateName: annotation- 13 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // This script is only for IntelliSense of thymeleaf. 2 | plugins { 3 | id 'java' 4 | } 5 | 6 | group 'run.halo' 7 | version '1.0' 8 | 9 | repositories { 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | implementation('org.thymeleaf:thymeleaf:3.0.12.RELEASE') 15 | } 16 | -------------------------------------------------------------------------------- /env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | import type { Alpine } from "alpinejs"; 3 | 4 | export {}; 5 | 6 | declare global { 7 | interface Window { 8 | Alpine: Alpine; 9 | SearchWidget: any; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxware-dev/theme-ocean/eb5f43d3882b86bf1c82a87316e73d5e473b1bfe/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@halo-dev/theme-ocean", 3 | "private": true, 4 | "version": "1.0.0", 5 | "description": "Knowledgebase theme of Halo 2.0", 6 | "scripts": { 7 | "dev": "vite build --watch", 8 | "build": "tsc && vite build", 9 | "lint": "eslint ./src --ext .js,.cjs,.mjs,.ts,.cts,.mts --ignore-path .gitignore", 10 | "prettier": "prettier --write './src/**/*.{js,ts,css,json,ml,yaml,html}' './templates/**/*.html'", 11 | "release": "release-it" 12 | }, 13 | "keywords": [ 14 | "halo", 15 | "halo-theme", 16 | "halo-template" 17 | ], 18 | "homepage": "https://github.com/f2ccloud/theme-ocean#readme", 19 | "bugs": { 20 | "url": "https://github.com/f2ccloud/theme-ocean/issues" 21 | }, 22 | "author": { 23 | "name": "Halo OSS Organization", 24 | "url": "https://github.com/halo-dev", 25 | "email": "hi@halo.run" 26 | }, 27 | "maintainers": [ 28 | { 29 | "name": "lan-yonghui", 30 | "url": "https://github.com/lan-yonghui" 31 | } 32 | ], 33 | "license": "GPL-3.0", 34 | "repository": { 35 | "url": "https://github.com/f2ccloud/theme-ocean", 36 | "type": "git" 37 | }, 38 | "devDependencies": { 39 | "@iconify-json/bx": "^1.1.4", 40 | "@iconify-json/gg": "^1.1.2", 41 | "@iconify-json/simple-icons": "^1.1.35", 42 | "@iconify-json/tabler": "^1.1.47", 43 | "@tailwindcss/aspect-ratio": "^0.4.2", 44 | "@tailwindcss/line-clamp": "^0.4.2", 45 | "@tailwindcss/typography": "^0.5.8", 46 | "@types/alpinejs": "^3.7.1", 47 | "@types/node": "18.11.9", 48 | "@typescript-eslint/eslint-plugin": "^5.44.0", 49 | "@typescript-eslint/parser": "^5.44.0", 50 | "autoprefixer": "^10.4.13", 51 | "eslint": "^8.28.0", 52 | "eslint-config-prettier": "^8.5.0", 53 | "eslint-plugin-prettier": "^4.2.1", 54 | "postcss": "8.4.31", 55 | "prettier": "^2.7.1", 56 | "prettier-plugin-tailwindcss": "^0.1.13", 57 | "release-it": "^15.5.0", 58 | "tailwindcss": "^3.2.4", 59 | "tailwindcss-plugin-icons": "^2.0.7", 60 | "axios": "1.6.0", 61 | "typescript": "4.9.3", 62 | "vite": "5.1.1" 63 | }, 64 | "dependencies": { 65 | "alpinejs": "^3.10.5", 66 | "tocbot": "^4.19.0" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: { 3 | tailwindcss: {}, 4 | autoprefixer: {}, 5 | }, 6 | } 7 | -------------------------------------------------------------------------------- /prettier.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [require("prettier-plugin-tailwindcss")], 3 | printWidth: 120, 4 | tabWidth: 2, 5 | useTabs: false, 6 | endOfLine: "lf", 7 | }; 8 | -------------------------------------------------------------------------------- /screenshot.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxware-dev/theme-ocean/eb5f43d3882b86bf1c82a87316e73d5e473b1bfe/screenshot.jpg -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'theme-ocean' 2 | -------------------------------------------------------------------------------- /settings.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1alpha1 2 | kind: Setting 3 | metadata: 4 | name: theme-ocean-setting 5 | spec: 6 | forms: 7 | - group: layout 8 | label: 布局 9 | formSchema: 10 | - $formkit: select 11 | name: post_list_layout 12 | label: 文章列表布局 13 | value: single 14 | options: 15 | - label: 单条 16 | value: single 17 | - label: 网格(一行两列) 18 | value: grid_2 19 | - label: 网格(一行三列) 20 | value: grid_3 21 | help: "选择单条时,文章卡片的图片将位于左侧" 22 | - $formkit: radio 23 | name: content_header 24 | label: 文章页顶部图片 25 | value: false 26 | options: 27 | - label: 显示 28 | value: true 29 | - label: 隐藏 30 | value: false 31 | - $formkit: radio 32 | name: hide_avatar 33 | id: hide_avatar 34 | key: hide_avatar 35 | label: 隐藏作者头像 36 | value: false 37 | options: 38 | - label: 是 39 | value: true 40 | - label: 否 41 | value: false 42 | - $formkit: radio 43 | name: hide_author 44 | id: hide_author 45 | key: hide_author 46 | label: 隐藏作者名称 47 | value: false 48 | options: 49 | - label: 是 50 | value: true 51 | - label: 否 52 | value: false 53 | - $formkit: text 54 | if: "$get(hide_author).value === false" 55 | name: common_author 56 | label: 统一作者名称 57 | help: "为空显示原文章作者" 58 | 59 | - group: banner 60 | label: Banner 61 | formSchema: 62 | - $formkit: text 63 | name: custom_title 64 | label: Banner标题 65 | - $formkit: text 66 | name: custom_sub_title 67 | label: Banner副标题 68 | - $formkit: select 69 | name: header_background_type 70 | id: header_background_type 71 | key: header_background_type 72 | label: Banner背景 73 | value: image 74 | options: 75 | - label: 手动设置 76 | value: manual 77 | - label: 图片 78 | value: image 79 | - $formkit: text 80 | if: "$get(header_background_type).value === manual" 81 | name: header_background 82 | id: header_background 83 | key: header_background 84 | label: Banner背景色 85 | help: "填写 16 进制颜色" 86 | - $formkit: attachment 87 | if: "$get(header_background_type).value === image" 88 | name: header_background_image 89 | id: header_background_image 90 | key: header_background_image 91 | label: Banner背景图片 92 | value: /themes/theme-ocean/assets/images/default-background.png 93 | - $formkit: radio 94 | name: search_method 95 | value: page 96 | label: 搜索形式 97 | options: 98 | - label: 页面 99 | value: page 100 | - label: 弹窗 101 | value: popup 102 | - label: 隐藏 103 | value: none 104 | - $formkit: tagCheckbox 105 | name: tags 106 | id: tags 107 | key: tags 108 | label: 热门查询 109 | help: "选择多于三个标签,自动隐藏超出标签" 110 | 111 | - group: index 112 | label: 首页 113 | formSchema: 114 | - $formkit: radio 115 | name: index_menu 116 | id: index_menu 117 | key: index_menu 118 | label: 是否显示模块一 119 | value: false 120 | options: 121 | - label: 显示 122 | value: true 123 | - label: 隐藏 124 | value: false 125 | - $formkit: text 126 | if: "$get(index_menu).value === true" 127 | name: module_one 128 | id: module_one 129 | key: module_one 130 | value: 模块一 131 | label: 模块一名称 132 | help: 默认显示前四个分类,字体颜色和stars数需配置分类元数据,增加 color 和 stars 133 | - $formkit: select 134 | if: "$get(index_menu).value === true" 135 | name: module_one_layout 136 | label: 模块一布局 137 | value: 4 138 | options: 139 | - label: 网格(一行三列) 140 | value: 3 141 | - label: 网格(一行四列) 142 | value: 4 143 | - label: 网格(一行五列) 144 | value: 5 145 | help: 默认显示一行四列 146 | - $formkit: radio 147 | name: index_theme 148 | id: index_theme 149 | key: index_theme 150 | label: 是否显示模块二 151 | value: false 152 | options: 153 | - label: 显示 154 | value: true 155 | - label: 隐藏 156 | value: false 157 | - $formkit: text 158 | if: "$get(index_theme).value === true" 159 | name: module_two 160 | id: module_two 161 | key: module_two 162 | value: 模块二 163 | label: 模块二名称 164 | help: "模块二图标需配置菜单元数据,增加 icon" 165 | - $formkit: menuRadio 166 | if: "$get(index_theme).value === true" 167 | name: menu 168 | id: menu 169 | key: menu 170 | label: 模块二数据 171 | help: 默认显示前四个一级菜单项 172 | - $formkit: radio 173 | name: index_tag 174 | id: index_tag 175 | key: index_tag 176 | label: 是否显示模块三 177 | value: false 178 | options: 179 | - label: 显示 180 | value: true 181 | - label: 隐藏 182 | value: false 183 | - $formkit: text 184 | if: "$get(index_tag).value === true" 185 | name: module_there 186 | id: module_there 187 | key: module_there 188 | value: 模块三 189 | label: 模块三名称 190 | - $formkit: select 191 | if: "$get(index_tag).value === true" 192 | name: index_recommend 193 | id: index_recommend 194 | key: index_recommend 195 | label: 模块三类型 196 | value: tag 197 | options: 198 | - label: 文章标签 199 | value: tag 200 | - label: 文章分类 201 | value: categories 202 | - $formkit: tagSelect 203 | if: "$get(index_tag).value === true && $get(index_recommend).value === tag" 204 | name: tag 205 | id: tag 206 | key: tag 207 | label: 模块三数据 208 | help: 默认显示选中标签的前六篇文章 209 | - $formkit: categorySelect 210 | if: "$get(index_tag).value === true && $get(index_recommend).value === categories" 211 | name: category 212 | id: category 213 | key: category 214 | label: 模块三数据 215 | help: 默认显示选中分类的前六篇文章 216 | - group: style 217 | label: 样式 218 | formSchema: 219 | - $formkit: radio 220 | name: color_scheme 221 | label: 默认配色 222 | value: light 223 | options: 224 | - label: 深色 225 | value: dark 226 | - label: 浅色 227 | value: light 228 | - $formkit: attachment 229 | name: dark_logo 230 | id: dark_logo 231 | key: dark_logo 232 | label: 深色Logo 233 | help: 默认使用站点Logo 234 | - $formkit: attachment 235 | name: light_logo 236 | id: light_logo 237 | key: light_logo 238 | label: 浅色Logo 239 | help: 默认使用站点Logo 240 | - $formkit: checkbox 241 | name: enable_change_color_scheme 242 | label: 允许访客切换配色 243 | value: true 244 | 245 | - $formkit: radio 246 | name: login_info 247 | id: login_info 248 | key: login_info 249 | label: 显示登录信息 250 | value: false 251 | options: 252 | - label: 显示 253 | value: true 254 | - label: 隐藏 255 | value: false 256 | 257 | - $formkit: radio 258 | if: "$get(login_info).value === true" 259 | name: show_content 260 | label: 显示内容 261 | value: all 262 | options: 263 | - label: 头像和名称 264 | value: all 265 | - label: 头像 266 | value: avatar 267 | - label: 名称 268 | value: user-name 269 | 270 | - group: sidebar 271 | label: 侧边栏 272 | formSchema: 273 | - $formkit: repeater 274 | name: widgets 275 | label: 小部件 276 | value: 277 | - value: categories 278 | - value: tags 279 | children: 280 | - $formkit: select 281 | name: value 282 | label: 部件 283 | options: 284 | - label: 站点资料 285 | value: profile 286 | - label: 热门文章 287 | value: popular-posts 288 | - label: 文章分类 289 | value: categories 290 | - label: 文章标签 291 | value: tags 292 | 293 | - $formkit: group 294 | name: profile 295 | value: 296 | logo: 297 | children: 298 | - $formkit: attachment 299 | name: logo 300 | label: 站点资料 Logo 301 | 302 | - $formkit: repeater 303 | name: social_media 304 | label: 社交媒体 305 | value: [] 306 | children: 307 | - $formkit: select 308 | name: icon 309 | label: 图标 310 | options: 311 | - label: 电子邮箱 312 | value: i-tabler-mail 313 | - label: 微信 314 | value: i-simple-icons-wechat 315 | - label: 腾讯 QQ 316 | value: i-simple-icons-tencentqq 317 | - label: 新浪微博 318 | value: i-simple-icons-sinaweibo 319 | - label: 知乎 320 | value: i-simple-icons-zhihu 321 | - label: 豆瓣 322 | value: i-simple-icons-douban 323 | - label: 哔哩哔哩 324 | value: i-simple-icons-bilibili 325 | - label: 抖音 / TikTok 326 | value: i-simple-icons-tiktok 327 | - label: Telegram 328 | value: i-simple-icons-telegram 329 | - label: Facebook 330 | value: i-simple-icons-facebook 331 | - label: Instagram 332 | value: i-simple-icons-instagram 333 | - label: LinkedIn 334 | value: i-simple-icons-linkedin 335 | - label: Twitter 336 | value: i-simple-icons-twitter 337 | - label: Slack 338 | value: i-simple-icons-slack 339 | - label: Discord 340 | value: i-simple-icons-discord 341 | - label: YouTube 342 | value: i-simple-icons-youtube 343 | - label: Steam 344 | value: i-simple-icons-steam 345 | - label: GitHub 346 | value: i-simple-icons-github 347 | - label: GitLab 348 | value: i-simple-icons-gitlab 349 | - $formkit: text 350 | name: name 351 | label: 名称 352 | - $formkit: text 353 | name: url 354 | label: 链接 355 | validation: "required" 356 | - $formkit: radio 357 | name: url_type 358 | label: 链接类型 359 | value: normal 360 | help: "如果选择了图片类型,那么在访客点击之后会使用弹框的形式加载" 361 | options: 362 | - label: 跳转链接 363 | value: normal 364 | - label: 图片 365 | value: image 366 | 367 | - group: footer 368 | label: 页脚 369 | formSchema: 370 | - $formkit: select 371 | name: style 372 | id: style 373 | key: style 374 | label: 页脚风格 375 | value: style_1 376 | options: 377 | - label: 风格一 378 | value: style_1 379 | - label: 风格二 380 | value: style_2 381 | - label: 风格三 382 | value: style_3 383 | - label: 风格四 384 | value: style_4 385 | - $formkit: attachment 386 | name: logo 387 | label: Logo 388 | help: 如果不设置,将使用站点设置的 Logo 389 | 390 | - $formkit: text 391 | name: title 392 | label: 标题 393 | help: 如果不设置,将使用站点设置的标题 394 | 395 | - $formkit: textarea 396 | rows: 3 397 | name: slogan 398 | id: slogan 399 | key: slogan 400 | if: "$get(style).value !== style_3" 401 | label: 标语 402 | 403 | - $formkit: menuRadio 404 | if: "$get(style).value === style_3" 405 | name: menu 406 | id: menu 407 | key: menu 408 | label: 右侧菜单 409 | 410 | - $formkit: repeater 411 | if: "$get(style).value !== style_3" 412 | name: menus 413 | id: menus 414 | key: menus 415 | label: 菜单组 416 | value: [] 417 | children: 418 | - $formkit: menuRadio 419 | name: name 420 | label: 菜单 421 | validation: "required" 422 | 423 | - $formkit: attachment 424 | if: "$get(style).value === style_4" 425 | name: qrcode 426 | label: Qrcode 427 | help: 关注二维码 428 | 429 | - $formkit: repeater 430 | name: social_media 431 | label: 社交媒体 432 | value: [] 433 | children: 434 | - $formkit: select 435 | name: icon 436 | label: 图标 437 | options: 438 | - label: 电子邮箱 439 | value: i-tabler-mail 440 | - label: 微信 441 | value: i-simple-icons-wechat 442 | - label: 腾讯 QQ 443 | value: i-simple-icons-tencentqq 444 | - label: 新浪微博 445 | value: i-simple-icons-sinaweibo 446 | - label: 知乎 447 | value: i-simple-icons-zhihu 448 | - label: 豆瓣 449 | value: i-simple-icons-douban 450 | - label: 哔哩哔哩 451 | value: i-simple-icons-bilibili 452 | - label: 抖音 / TikTok 453 | value: i-simple-icons-tiktok 454 | - label: Telegram 455 | value: i-simple-icons-telegram 456 | - label: Facebook 457 | value: i-simple-icons-facebook 458 | - label: Instagram 459 | value: i-simple-icons-instagram 460 | - label: LinkedIn 461 | value: i-simple-icons-linkedin 462 | - label: Twitter 463 | value: i-simple-icons-twitter 464 | - label: Slack 465 | value: i-simple-icons-slack 466 | - label: Discord 467 | value: i-simple-icons-discord 468 | - label: YouTube 469 | value: i-simple-icons-youtube 470 | - label: Steam 471 | value: i-simple-icons-steam 472 | - label: GitHub 473 | value: i-simple-icons-github 474 | - label: GitLab 475 | value: i-simple-icons-gitlab 476 | - $formkit: text 477 | name: name 478 | label: 名称 479 | - $formkit: text 480 | name: url 481 | label: 链接 482 | validation: "required" 483 | - $formkit: radio 484 | name: url_type 485 | label: 链接类型 486 | value: normal 487 | help: "如果选择了图片类型,那么在访客点击之后会使用弹框的形式加载" 488 | options: 489 | - label: 跳转链接 490 | value: normal 491 | - label: 图片 492 | value: image 493 | 494 | - group: beian 495 | label: 备案设置 496 | formSchema: 497 | - $formkit: text 498 | name: icp_text 499 | label: ICP备案号 500 | - $formkit: text 501 | name: icp_link 502 | label: ICP备案跳转链接 503 | value: https://beian.miit.gov.cn/ 504 | -------------------------------------------------------------------------------- /src/alpine-data/color-scheme-switcher.ts: -------------------------------------------------------------------------------- 1 | import { currentColorScheme } from "../main"; 2 | 3 | export default () => ({ 4 | colorSchemes: [ 5 | { label: "暗色", value: "dark", icon: "i-gg-moon" }, 6 | { label: "亮色", value: "light", icon: "i-gg-sun" }, 7 | ], 8 | currentValue: currentColorScheme, 9 | get colorScheme() { 10 | return this.colorSchemes.find((x) => x.value === this.currentValue); 11 | }, 12 | get nextColorScheme() { 13 | const index = this.colorSchemes.findIndex((x) => x.value === this.currentValue); 14 | return this.colorSchemes[(index + 1) % this.colorSchemes.length]; 15 | }, 16 | }); 17 | -------------------------------------------------------------------------------- /src/alpine-data/dropdown.ts: -------------------------------------------------------------------------------- 1 | export default () => ({ 2 | show: false, 3 | timer: 0, 4 | open: function () { 5 | if (this.timer) { 6 | window.clearTimeout(this.timer); 7 | } 8 | this.show = true; 9 | }, 10 | close: function () { 11 | this.timer = window.setTimeout(() => (this.show = false), 300); 12 | }, 13 | }); 14 | -------------------------------------------------------------------------------- /src/alpine-data/pagination.ts: -------------------------------------------------------------------------------- 1 | export default (page: number, totalPages: number, totalVisible: number) => ({ 2 | page: page, 3 | totalPages: totalPages, 4 | totalVisible: totalVisible, 5 | 6 | get items(): (string | number)[] { 7 | if (totalVisible === 0 || this.totalPages === 0) { 8 | return []; 9 | } 10 | 11 | const maxLength = Math.min(Math.max(0, this.totalVisible) || this.totalPages, this.totalPages); 12 | 13 | if (this.totalPages <= maxLength) { 14 | return this.range(1, this.totalPages); 15 | } 16 | 17 | const even = maxLength % 2 === 0 ? 1 : 0; 18 | const left = Math.floor(maxLength / 2); 19 | const right = this.totalPages - left + 1 + even; 20 | 21 | if (this.page > left && this.page < right) { 22 | const firstItem = 1; 23 | const lastItem = this.totalPages; 24 | const start = this.page - left + 2; 25 | const end = this.page + left - 2 - even; 26 | const secondItem = start - 1 === firstItem + 1 ? 2 : "..."; 27 | const beforeLastItem = end + 1 === lastItem - 1 ? end + 1 : "..."; 28 | 29 | return [1, secondItem, ...this.range(start, end), beforeLastItem, this.totalPages]; 30 | } else if (this.page === left) { 31 | const end = this.page + left - 1 - even; 32 | return [...this.range(1, end), "...", this.totalPages]; 33 | } else if (this.page === right) { 34 | const start = this.page - left + 1; 35 | return [1, "...", ...this.range(start, this.totalPages)]; 36 | } else { 37 | return [...this.range(1, left), "...", ...this.range(right, this.totalPages)]; 38 | } 39 | }, 40 | 41 | range(from: number, to: number) { 42 | const range = []; 43 | 44 | from = from > 0 ? from : 1; 45 | 46 | for (let i = from; i <= to; i++) { 47 | range.push(i); 48 | } 49 | 50 | return range; 51 | }, 52 | }); 53 | -------------------------------------------------------------------------------- /src/alpine-data/post-util.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | export default (postId: any, likeNum: string) => ({ 4 | postId: postId, 5 | likeNum: likeNum, 6 | loading: false, 7 | liked: false, 8 | noLiked: false, 9 | get upvote() { 10 | this.init(); 11 | if (this.loading || this.liked) return; 12 | 13 | this.loading = true; 14 | axios 15 | .post( 16 | "/apis/api.halo.run/v1alpha1/trackers/upvote", 17 | { 18 | group: "content.halo.run", 19 | plural: "posts", 20 | name: this.postId, 21 | }, 22 | { 23 | headers: { 24 | "Content-Type": "application/json; charset=utf-8", 25 | }, 26 | } 27 | ) 28 | .then(() => { 29 | this.liked = true; 30 | this.noLiked = false 31 | this.loading = false; 32 | localStorage.setItem("likeNum:" + this.postId, String(Number(this.likeNum) + 1)); 33 | this.likeNum = String(Number(this.likeNum) + 1); 34 | }) 35 | .catch(() => { 36 | this.loading = false; 37 | }); 38 | }, 39 | get downvote() { 40 | if (this.loading || !this.liked) return; 41 | 42 | this.loading = true; 43 | axios 44 | .post( 45 | "/apis/api.halo.run/v1alpha1/trackers/downvote", 46 | { 47 | group: "content.halo.run", 48 | plural: "posts", 49 | name: this.postId, 50 | }, 51 | { 52 | headers: { 53 | "Content-Type": "application/json; charset=utf-8", 54 | }, 55 | } 56 | ) 57 | .then(() => { 58 | let num = Number(this.likeNum) - 1; 59 | this.likeNum = String(num < 0 ? 0 : num); 60 | localStorage.removeItem("likeNum:" + this.postId); 61 | this.loading = false; 62 | this.liked = false; 63 | this.noLiked = true 64 | }) 65 | .catch(() => { 66 | this.loading = false; 67 | }); 68 | }, 69 | init() { 70 | if (this.likeNumExists(this.postId) !== null && Number(this.likeNumExists(this.postId)) > 0) { 71 | this.liked = true; 72 | } 73 | this.noLiked = false; 74 | return this.liked; 75 | }, 76 | likeNumExists(id: any) { 77 | return localStorage.getItem("likeNum:" + id); 78 | }, 79 | }); 80 | -------------------------------------------------------------------------------- /src/alpine-data/search.ts: -------------------------------------------------------------------------------- 1 | import axios from "axios"; 2 | 3 | export default () => ({ 4 | loading: false, 5 | isSearch: false, 6 | keys: "", 7 | searchData: {}, 8 | init() { 9 | this.searchData = {}; 10 | this.isSearch = false; 11 | }, 12 | get keywords() { 13 | if (this.loading || this.keys == "") { 14 | this.keyClear 15 | return; 16 | } 17 | this.loading = true; 18 | axios 19 | .get("/apis/api.halo.run/v1alpha1/indices/post", { 20 | params: { 21 | limit: 20, 22 | keyword: this.keys, 23 | highlightPreTag: "", 24 | highlightPostTag: "", 25 | }, 26 | headers: { 27 | "Content-Type": "application/json; charset=utf-8", 28 | }, 29 | }) 30 | .then((res) => { 31 | this.loading = false; 32 | this.searchData = res.data; 33 | this.isSearch = true; 34 | }) 35 | .catch(() => { 36 | this.isSearch = false; 37 | this.loading = false; 38 | }); 39 | }, 40 | get keyClear() { 41 | this.keys = ""; 42 | this.searchData = {}; 43 | this.isSearch = false; 44 | return; 45 | }, 46 | }); 47 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import "./styles/tailwind.css"; 2 | import "./styles/main.css"; 3 | import Alpine from "alpinejs"; 4 | import * as tocbot from "tocbot"; 5 | import dropdown from "./alpine-data/dropdown"; 6 | import colorSchemeSwitcher from "./alpine-data/color-scheme-switcher"; 7 | import pagination from "./alpine-data/pagination"; 8 | import postUtil from "./alpine-data/post-util"; 9 | import search from "./alpine-data/search"; 10 | 11 | window.Alpine = Alpine; 12 | 13 | Alpine.data("dropdown", dropdown); 14 | Alpine.data("colorSchemeSwitcher", colorSchemeSwitcher); 15 | // @ts-ignore 16 | Alpine.data("pagination", pagination); 17 | // @ts-ignore 18 | Alpine.data("postUtil", postUtil); 19 | // @ts-ignore 20 | Alpine.data("search", search); 21 | 22 | Alpine.start(); 23 | 24 | const onScroll = () => { 25 | const headerMenu = document.getElementById("header-menu"); 26 | if (window.scrollY > 0) { 27 | headerMenu?.classList.add("menu-sticky"); 28 | } else { 29 | headerMenu?.classList.remove("menu-sticky"); 30 | } 31 | }; 32 | 33 | window.addEventListener("scroll", onScroll); 34 | 35 | export function generateToc() { 36 | tocbot.init({ 37 | tocSelector: ".toc", 38 | contentSelector: "#content", 39 | headingSelector: "h1, h2, h3, h4", 40 | extraListClasses: "space-y-1 dark:border-zinc-500", 41 | extraLinkClasses: 42 | "group flex items-center justify-between rounded py-1 px-1.5 transition-all hover:bg-zinc-100 text-sm opacity-80 dark:hover:bg-zinc-700 dark:text-zinc-50", 43 | activeLinkClass: "is-active-link bg-zinc-100 dark:bg-zinc-600", 44 | collapseDepth: 6, 45 | headingsOffset: 100, 46 | scrollSmooth: true, 47 | scrollSmoothOffset: -100, 48 | }); 49 | } 50 | 51 | type ColorSchemeType = "system" | "dark" | "light"; 52 | 53 | export let currentColorScheme: ColorSchemeType = "system"; 54 | 55 | export function initColorScheme(defaultColorScheme: ColorSchemeType, enableChangeColorScheme: boolean) { 56 | let colorScheme = defaultColorScheme; 57 | 58 | if (enableChangeColorScheme) { 59 | colorScheme = (localStorage.getItem("color-scheme") as ColorSchemeType) || defaultColorScheme; 60 | } 61 | 62 | currentColorScheme = colorScheme; 63 | 64 | setColorScheme(colorScheme, false); 65 | } 66 | 67 | export function setColorScheme(colorScheme: ColorSchemeType, store: boolean) { 68 | if (colorScheme === "system") { 69 | const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches; 70 | document.documentElement.classList.add(prefersDark ? "dark" : "light"); 71 | document.documentElement.classList.remove(prefersDark ? "light" : "dark"); 72 | } else { 73 | document.documentElement.classList.add(colorScheme); 74 | document.documentElement.classList.remove(colorScheme === "dark" ? "light" : "dark"); 75 | } 76 | currentColorScheme = colorScheme; 77 | if (store) { 78 | localStorage.setItem("color-scheme", colorScheme); 79 | } 80 | } 81 | 82 | window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", function () { 83 | if (currentColorScheme === "system") { 84 | setColorScheme("system", false); 85 | } 86 | }); 87 | 88 | /*移除HTML标签代码*/ 89 | export function removeHTMLTag(str: String) { 90 | str = str.replace(/<.*?>/g, ""); //去除HTML tag 91 | str = str.replace(/<\/?[^>]*>/g, ""); //去除HTML tag 92 | str = str.replace(/[ | ]*\n/g, "\n"); //去除行尾空 93 | str = str.replace(/\n[\s| | ]*\r/g, "\n"); //去除多余空行 94 | str = str.replace(/ /gi, ""); //去掉 95 | // str = str.replace(/[a-zA-Z]+/g, ''); //去除字母 96 | return str; 97 | } 98 | 99 | /*阅读时间*/ 100 | export function readTime() { 101 | const contentHtml: HTMLElement | null = document.getElementById("content"); 102 | // @ts-ignore 103 | let str = contentHtml.innerHTML; 104 | return ( 105 | "文章共计 " + 106 | removeHTMLTag(str).length + 107 | " 个字,阅读完成需要 " + 108 | Math.ceil(removeHTMLTag(str).length / 400) + 109 | " 分钟" 110 | ); 111 | } 112 | 113 | // 快速返回顶部或底部 114 | const onScrollToTop = () => { 115 | const backToTop = document.getElementById("back-to-top"); 116 | const backToDown = document.getElementById("back-to-down"); 117 | if (window.scrollY < 100) { 118 | backToTop?.classList.add("hidden"); 119 | backToDown?.classList.add("hidden"); 120 | } else if (window.scrollY > 300) { 121 | backToTop?.classList.remove("hidden"); 122 | backToDown?.classList.add("hidden"); 123 | } else { 124 | backToTop?.classList.add("hidden"); 125 | backToDown?.classList.remove("hidden"); 126 | } 127 | }; 128 | 129 | window.addEventListener("scroll", onScrollToTop); 130 | -------------------------------------------------------------------------------- /src/styles/main.css: -------------------------------------------------------------------------------- 1 | body { 2 | font-family: ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji" !important; 3 | color: #3d3d3d; 4 | -webkit-font-smoothing: antialiased; 5 | -moz-osx-font-smoothing: grayscale; 6 | text-rendering: optimizeLegibility; 7 | overflow: overlay; 8 | } 9 | 10 | *::-webkit-scrollbar-track-piece { 11 | background-color: #f8f8f8; 12 | -webkit-border-radius: 2em; 13 | -moz-border-radius: 2em; 14 | border-radius: 2em; 15 | } 16 | 17 | *::-webkit-scrollbar { 18 | width: 8px; 19 | height: 8px; 20 | } 21 | 22 | *::-webkit-scrollbar-thumb { 23 | background-color: #ddd; 24 | background-clip: padding-box; 25 | -webkit-border-radius: 2em; 26 | -moz-border-radius: 2em; 27 | border-radius: 2em; 28 | } 29 | 30 | *::-webkit-scrollbar-thumb:hover { 31 | background-color: #bbb; 32 | } 33 | 34 | .menu-sticky { 35 | @apply fixed top-0 left-0 right-0 z-10 drop-shadow-md backdrop-blur-lg; 36 | } 37 | 38 | .toc-list-item > .toc-list { 39 | @apply my-3 ml-3 space-y-1 border-l pl-2; 40 | } 41 | 42 | .text-overflow { 43 | overflow: hidden; 44 | text-overflow: ellipsis; 45 | display: -webkit-box; 46 | -webkit-line-clamp: 1; 47 | -webkit-box-orient: vertical; 48 | } 49 | 50 | .text-overflow-2 { 51 | overflow: hidden; 52 | text-overflow: ellipsis; 53 | display: -webkit-box; 54 | -webkit-line-clamp: 2; 55 | -webkit-box-orient: vertical; 56 | } 57 | 58 | /*a标签增加指上下划线*/ 59 | .hover-within a { 60 | position: relative; 61 | } 62 | 63 | .hover-within a::after { 64 | --tw-bg-opacity: 1; 65 | background-color: rgb(255 255 255 / var(--tw-bg-opacity)); 66 | content: ""; 67 | display: block; 68 | height: 1px; 69 | margin-top: 2px; 70 | position: absolute; 71 | right: 0; 72 | transition: width 0.2s ease; 73 | -webkit-transition: width 0.2s ease; 74 | width: 0; 75 | } 76 | 77 | .hover-within a:hover::after { 78 | background: #3296ef; 79 | left: 0; 80 | width: 100%; 81 | } 82 | 83 | /*a标签增加指上下划线*/ 84 | -------------------------------------------------------------------------------- /src/styles/tailwind.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind utilities; 3 | @tailwind components; 4 | -------------------------------------------------------------------------------- /tailwind.config.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('tailwindcss').Config} */ 2 | const { Icons } = require("tailwindcss-plugin-icons"); 3 | const plugin = require('tailwindcss/plugin') 4 | module.exports = { 5 | content: ["./templates/**/*.html", "./src/main.ts"], 6 | darkMode: "class", 7 | theme: { 8 | extend: { 9 | lineClamp: { 10 | 7: "7", 11 | 8: "8", 12 | }, 13 | typography: { 14 | DEFAULT: { 15 | css: { 16 | h1 : { 17 | marginTop: '0.25em !important', 18 | marginBottom: '0.25em !important', 19 | }, 20 | h2 : { 21 | marginTop: '0.25em !important', 22 | marginBottom: '0.25em !important', 23 | }, 24 | h3 : { 25 | marginTop: '0.25em !important', 26 | marginBottom: '0.25em !important', 27 | }, 28 | h4 : { 29 | marginTop: '0.25em !important', 30 | marginBottom: '0.25em !important', 31 | }, 32 | ul : { 33 | marginTop: '0.25em !important', 34 | marginBottom: '0.25em !important', 35 | }, 36 | li : { 37 | marginTop: '0.25em !important', 38 | marginBottom: '0.25em !important', 39 | }, 40 | dl : { 41 | marginTop: '0.25em !important', 42 | marginBottom: '0.25em !important', 43 | }, 44 | p : { 45 | marginTop: '0.25em !important', 46 | marginBottom: '0.25em !important', 47 | }, 48 | img : { 49 | marginTop: '0.5em !important', 50 | marginBottom: '0.5em !important', 51 | }, 52 | dd : { 53 | marginTop: '0.25em !important', 54 | marginBottom: '0.25em !important', 55 | }, 56 | ol : { 57 | marginTop: '0.25em !important', 58 | marginBottom: '0.25em !important', 59 | }, 60 | pre : { 61 | marginTop: '0.25em !important', 62 | marginBottom: '0.25em !important', 63 | }, 64 | hr : { 65 | marginTop: '1.25em !important', 66 | marginBottom: '1.25em !important', 67 | }, 68 | }, 69 | }, 70 | }, 71 | }, 72 | container: { 73 | padding: { 74 | DEFAULT: "1rem", 75 | sm: "2rem", 76 | lg: "4rem", 77 | xl: "5rem", 78 | "2xl": "6rem", 79 | }, 80 | }, 81 | }, 82 | plugins: [ 83 | require("@tailwindcss/aspect-ratio"), 84 | require("@tailwindcss/typography"), 85 | require("@tailwindcss/line-clamp"), 86 | Icons(() => ({ 87 | gg: { 88 | includeAll: true, 89 | }, 90 | tabler: { 91 | includeAll: true, 92 | }, 93 | simpleIcons: { 94 | includeAll: true, 95 | }, 96 | bx: { 97 | includeAll: true, 98 | }, 99 | })), 100 | ], 101 | safelist: [ 102 | "i-gg-sun", 103 | "i-gg-moon", 104 | "i-tabler-mail", 105 | "i-simple-icons-wechat", 106 | "i-simple-icons-tencentqq", 107 | "i-simple-icons-sinaweibo", 108 | "i-simple-icons-zhihu", 109 | "i-simple-icons-douban", 110 | "i-simple-icons-bilibili", 111 | "i-simple-icons-tiktok", 112 | "i-simple-icons-telegram", 113 | "i-simple-icons-facebook", 114 | "i-simple-icons-instagram", 115 | "i-simple-icons-linkedin", 116 | "i-simple-icons-twitter", 117 | "i-simple-icons-slack", 118 | "i-simple-icons-discord", 119 | "i-simple-icons-youtube", 120 | "i-simple-icons-steam", 121 | "i-simple-icons-github", 122 | "i-simple-icons-gitlab", 123 | ], 124 | }; 125 | -------------------------------------------------------------------------------- /templates/archives.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 |
16 | 17 | 18 | 19 | 22 | 23 | 24 | 25 |
26 | 27 |
28 | 66 |
67 | 68 |
69 | 当前没有文章 70 |
71 |
72 | 73 | -------------------------------------------------------------------------------- /templates/assets/images/computer.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/assets/images/crown.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/assets/images/default-avatar.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/assets/images/default-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxware-dev/theme-ocean/eb5f43d3882b86bf1c82a87316e73d5e473b1bfe/templates/assets/images/default-background.png -------------------------------------------------------------------------------- /templates/assets/images/lightning.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/assets/images/model.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/assets/images/read.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/assets/images/star.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /templates/categories.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 |
17 | 18 | 21 | 22 |
23 | 24 |
25 | 此分类下没有文章 26 |
27 | 28 | 37 |
38 |
39 | 40 | -------------------------------------------------------------------------------- /templates/category.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 |
16 | 17 | 20 | 21 |
22 | 23 |
24 | 62 |
63 | 64 |
65 | 此分类下没有文章 66 |
67 |
68 | 69 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /templates/links.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |
8 |

链接

9 | 34 |
35 |
36 | 37 | -------------------------------------------------------------------------------- /templates/modules/category-filter.html: -------------------------------------------------------------------------------- 1 | 35 | -------------------------------------------------------------------------------- /templates/modules/category-sub.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /templates/modules/category-tree.html: -------------------------------------------------------------------------------- 1 | 21 | -------------------------------------------------------------------------------- /templates/modules/featured-post-card.html: -------------------------------------------------------------------------------- 1 |
5 |
6 | 7 | 12 | 13 |
14 |
15 |
19 | 26 | 27 | 34 | 35 |
36 |

39 | 40 |

41 |

42 |
43 | 50 | 55 | 59 | 60 |
61 |
62 |
63 | -------------------------------------------------------------------------------- /templates/modules/footer.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 | 28 |
29 |
30 | 31 |
35 | 39 | 40 | 50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | 61 | 68 | 69 |
70 | Copyright © 71 | 72 | . All Rights Reserved.
Powered by 73 | Halo. 74 |
75 |
76 |
77 |
78 |
79 | 80 |
81 |
82 |
83 | 84 | 90 | 94 | 95 | 100 | 101 |
102 |
106 | 107 |
108 |

112 |
    113 |
  • 114 | 119 |
  • 120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 | 128 | © 129 | 130 | . All Rights Reserved. Powered by 131 | Halo. 132 | 133 |
137 | 143 |
144 |
145 |
146 |
147 |
148 | 149 |
150 |
151 | 152 | 158 | 159 | 160 | 161 | 162 |
    166 |
  • 167 | 172 |
  • 173 |
174 |
175 |
176 |
177 | 178 | 185 | 186 | 187 | © 188 | 189 | . All Rights Reserved. Powered by 190 | Halo. 191 | 192 |
193 | 194 | 195 | 196 |
197 |
198 |
199 | 223 |
224 |
225 | 226 |
230 | 234 | 235 | 245 |
246 |
247 |
248 |
249 |
250 |
251 |

关注我们

252 | 253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 | 262 | 269 | 270 |
271 | Copyright © 272 | 273 | . All Rights Reserved.
Powered by 274 | Halo. 275 |
276 |
277 |
278 |
279 |
280 | 281 | 282 | 289 | 290 | 297 | -------------------------------------------------------------------------------- /templates/modules/header.html: -------------------------------------------------------------------------------- 1 |
2 |
3 |
4 |
5 |
6 | 38 |
39 |
40 | 87 | 214 |
215 |
216 |
217 |
222 |
223 | 228 | 233 | 234 | 237 |
238 | 263 |
264 |
268 |

269 | 热门查询: 270 | 271 | 272 | 273 | 278 | 279 | 280 | 281 |

282 |
283 |
284 | 285 |
286 | 293 | 318 | 343 |
344 |
348 |

349 | 热门查询: 350 | 351 | 352 | 357 | 358 | 359 |

360 |
361 |
362 |
363 |
364 |
365 |
370 |
371 | 372 |
373 |
374 |
375 |
376 | 387 |
399 |
400 | 406 |

菜单

407 |
408 | 426 |
427 |
428 |
429 | -------------------------------------------------------------------------------- /templates/modules/index/category-filter.html: -------------------------------------------------------------------------------- 1 | 2 |

6 | 按产品浏览 7 |

8 | 47 |
48 | -------------------------------------------------------------------------------- /templates/modules/index/popular-posts.html: -------------------------------------------------------------------------------- 1 | 5 |

9 | 推荐阅读 10 |

11 | 65 |
66 | -------------------------------------------------------------------------------- /templates/modules/index/tag-filter.html: -------------------------------------------------------------------------------- 1 | 2 |

6 | 常见主题 7 |

8 |
9 |
10 |
    14 | 15 | 16 |
  • 17 |
    18 |
    19 | 20 | 27 | 28 |
    29 |
    30 | 31 |

    35 |
    36 |
    37 |
    38 | 39 |
      40 |
    • 41 |
      42 |
      43 | 44 | 51 | 52 |
      53 |
      54 | 60 | 61 |
      62 |
      63 |
    • 64 |
    65 |
    66 |
  • 67 |
    68 |
    69 |
70 |
71 |
72 |
73 | -------------------------------------------------------------------------------- /templates/modules/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 16 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 |
27 |
28 |
29 | 30 |
31 | 55 |
56 | 57 | 58 |
59 | 60 | 61 | 62 | 63 | 64 | 65 |
66 |
67 |
68 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /templates/modules/post-card.html: -------------------------------------------------------------------------------- 1 |
6 |
11 | 12 | 18 | 19 |
20 |
21 |
22 |
23 |
28 |
32 | 40 | 41 | 49 | 50 |
51 |

55 | 56 |

57 |

62 |
63 | 70 | 75 | 79 | 80 |
81 |
82 |
83 | -------------------------------------------------------------------------------- /templates/modules/sidebar.html: -------------------------------------------------------------------------------- 1 | 27 | -------------------------------------------------------------------------------- /templates/modules/tag-filter.html: -------------------------------------------------------------------------------- 1 |
2 |

3 | 4 | 所有标签 5 |

6 | 18 |
19 | -------------------------------------------------------------------------------- /templates/modules/widgets/categories.html: -------------------------------------------------------------------------------- 1 |
4 |

5 | 6 | 分类目录 7 |

8 |
9 |
    10 |
  • 11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /templates/modules/widgets/home.html: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /templates/modules/widgets/latest-comments.html: -------------------------------------------------------------------------------- 1 |
4 |

5 | 6 | 最新评论 7 |

8 |
9 |
    10 |
  • 11 |
    12 | Comment Avatar 13 |
    14 |
    15 |

    Phyllis McKenzie

    16 |

    1h

    17 |
    18 |

    19 | Fugit quae nam dolores impedit quia fuga pariatur dignissimos recusandae. 20 |

    21 |
    22 |
    23 |
  • 24 |
  • 25 |
    26 | Comment Avatar 27 |
    28 |
    29 |

    Willard Labadie I

    30 |

    1h

    31 |
    32 |

    33 | Officiis quis quos repudiandae quam delectus impedit quidem amet ut. 34 |

    35 |
    36 |
    37 |
  • 38 |
  • 39 |
    40 | Comment Avatar 41 |
    42 |
    43 |

    Miss Leonard Sporer

    44 |

    1h

    45 |
    46 |

    Nesciunt dolores et debitis.

    47 |
    48 |
    49 |
  • 50 |
  • 51 |
    52 | Comment Avatar 53 |
    54 |
    55 |

    Tyrone Fisher

    56 |

    1h

    57 |
    58 |

    Et nesciunt dolorem eum ut corporis.

    59 |
    60 |
    61 |
  • 62 |
  • 63 |
    64 | Comment Avatar 65 |
    66 |
    67 |

    Angie Braun V

    68 |

    1h

    69 |
    70 |

    Autem labore ipsam earum reiciendis eum omnis.

    71 |
    72 |
    73 |
  • 74 |
75 |
76 |
77 | -------------------------------------------------------------------------------- /templates/modules/widgets/popular-posts.html: -------------------------------------------------------------------------------- 1 |
4 |

5 | 6 | 热门文章 7 |

8 |
9 |
    10 |
  • 11 |
    12 |
    13 |

    14 | 15 |

    16 |

    20 |
    21 |
    22 | 23 | 24 |
    25 |
    26 |
  • 27 |
28 |
29 |
30 | -------------------------------------------------------------------------------- /templates/modules/widgets/profile.html: -------------------------------------------------------------------------------- 1 |
5 |
6 |
7 | 8 |
9 |

10 |
11 |

12 |
13 |
14 |
15 | 16 | 文章数 17 |
18 |
19 | 23 | 分类数 24 |
25 |
26 | 30 | 评论数 31 |
32 |
33 | 访问量 35 |
36 |
37 |
38 | 44 | 45 | 46 |
47 |
48 |
49 | -------------------------------------------------------------------------------- /templates/modules/widgets/tags.html: -------------------------------------------------------------------------------- 1 |
4 |
5 |

6 | 7 | 标签 8 |

9 | 13 | 更多 14 | 15 | 16 |
17 | 29 |
30 | -------------------------------------------------------------------------------- /templates/page.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 |
13 |
14 |
15 | 21 |
22 | 27 |
28 | 29 | / 30 | 31 | / 32 | 33 | / 34 | 35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 | 43 |
46 |
47 |
48 |
51 |
52 |
53 |
54 |

55 |
59 |
60 | 61 |
62 |

评论

63 | 69 |
70 |
71 | 72 | 78 |
79 |
80 |
81 | 82 | -------------------------------------------------------------------------------- /templates/post.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 |
14 | 19 |

20 |
21 | 28 | 29 |
30 |
31 |
35 |
36 | 42 |
43 |
44 | 49 | 50 | / 51 | 52 | / 53 | 54 | / 55 | 56 |
57 |
58 |
59 |
60 |
61 | 67 | 73 |
74 | 75 |
78 |
79 |
80 |
83 |
84 |
85 |
86 | 87 |
88 |
89 |
94 |
95 | 127 |
128 |
129 | 是否对你有帮助? 130 | 136 | 142 | 148 | 154 |
155 | 156 |
157 |

评论

158 | 164 |
165 |
166 | 172 |
173 |
174 |
175 | 176 |
179 |
180 |

181 | 182 | 返回首页 / 187 | 返回上一页 192 | 193 |

194 |
195 |
196 |
199 |

200 | 201 | 目录 202 |

203 |
204 |
205 |
206 | 207 | 208 | 209 | 210 | 211 | 214 | 215 | 216 | 217 | -------------------------------------------------------------------------------- /templates/tag.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |
8 | 9 |
10 | 11 |
18 | 19 | 22 | 23 |
24 | 25 |
26 | 64 |
65 | 66 |
67 | 此标签下没有文章 68 |
69 |
70 | 71 | -------------------------------------------------------------------------------- /templates/tags.html: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 |
8 | 9 |
10 | 11 | 12 | 13 |
20 | 21 | 24 | 25 |
26 | 27 |
28 | 此标签下没有文章 29 |
30 | 31 | 40 |
41 |
42 |
43 | 44 | -------------------------------------------------------------------------------- /theme.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: theme.halo.run/v1alpha1 2 | kind: Theme 3 | metadata: 4 | name: theme-ocean 5 | spec: 6 | displayName: Ocean 7 | author: 8 | name: halo-dev 9 | website: https://halo.run 10 | description: Knowledgebase theme of Halo 2.0 11 | logo: https://halo.run/logo 12 | website: https://github.com/f2ccloud/theme-ocean 13 | repo: https://github.com/f2ccloud/theme-ocean.git 14 | settingName: "theme-ocean-setting" 15 | configMapName: "theme-ocean-configMap" 16 | version: 1.5.0 17 | require: ">=2.20.0" 18 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ESNext", 4 | "useDefineForClassFields": true, 5 | "module": "ESNext", 6 | "lib": ["ESNext", "DOM"], 7 | "moduleResolution": "Node", 8 | "strict": true, 9 | "sourceMap": true, 10 | "resolveJsonModule": true, 11 | "isolatedModules": true, 12 | "esModuleInterop": true, 13 | "noEmit": true, 14 | "noUnusedLocals": true, 15 | "noUnusedParameters": true, 16 | "noImplicitReturns": true, 17 | "skipLibCheck": true 18 | }, 19 | "include": ["src", "./env.d.ts"] 20 | } 21 | -------------------------------------------------------------------------------- /vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import { fileURLToPath } from "url"; 3 | import path from "path"; 4 | 5 | export default defineConfig({ 6 | plugins: [], 7 | build: { 8 | outDir: fileURLToPath(new URL("./templates/assets/dist", import.meta.url)), 9 | emptyOutDir: true, 10 | lib: { 11 | entry: path.resolve(__dirname, "src/main.ts"), 12 | name: "main", 13 | fileName: "main", 14 | formats: ["iife"], 15 | }, 16 | }, 17 | }); 18 | --------------------------------------------------------------------------------