Skip to content

Commit

Permalink
添加文章的创建时间, 每篇文章的阅读量
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson0714 committed Aug 30, 2024
1 parent 16ecece commit f86195a
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default defineUserConfig({
head: [
// meta
["meta", { name: "robots", content: "all" }],
["meta", { name: "author", content: "Guide" }],
["meta", { name: "author", content: "passjava" }],
[
"meta",
{
Expand Down
3 changes: 2 additions & 1 deletion docs/.vuepress/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default hopeTheme({
'<a href="https://beian.miit.gov.cn/" target="_blank">鄂ICP备2020015769号-1</a>',
displayFooter: true,

pageInfo: ["Author", "Category", "Tag", "Original", "Word", "ReadingTime"],
pageInfo: ["Author", "Date", "Category", "Tag", "Original", "Word", "ReadingTime", "PageView"],

blog: {
intro: "/about-the-author/",
Expand All @@ -48,6 +48,7 @@ export default hopeTheme({
comment: {
provider: "Waline",
serverURL: "https://comment.passjava.cn/", // your server url
pageview: true,
},
components: {
rootComponents: {
Expand Down
3 changes: 2 additions & 1 deletion docs/my-essay/my-blog/vuepress-theme-hope-add-comment.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ category: 博客优化
tag:
- 博客优化
- VuePress
- 评论
- 博客评论
date: 2024-08-26
---

## 评论效果图
Expand Down
123 changes: 123 additions & 0 deletions jenkins.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
pipeline {
agent any

tools {
// 定义 Jenkins 应该使用的 Git 版本
git 'Default'
nodejs "node"
}
parameters {
string(name: 'GIT_BRANCH', defaultValue: 'main', description: '请选择部署的分支')
choice(name: 'ENVIRONMENT', choices: ['passjava-learning'], description: '请选择环境')
}

// 定义 GitLab 仓库的 URL 和分支
environment {
GIT_URL = 'https://gitee.com/jayh2018/PassJava-Learning.git'
SSH_URL = getSSHUrl(params.ENVIRONMENT)
}

stages {
stage('获取最新代码') {
steps {
script {
// 使用 params 对象获取参数值
def branchName = params.GIT_BRANCH
echo "Building branch: ${branchName}"

echo "Building ssh url: ${SSH_URL}"

// 使用 git 插件检出仓库的特定分支
checkout([
$class: 'GitSCM',
branches: [[name: "${branchName}"]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[
credentialsId: '2dcbf8b2-6314-4f43-8f52-79ec802f6d14', // 在 Jenkins 凭据中定义的 GitLab 凭据 ID
url: "${GIT_URL}"
]]
])
}
}
}
stage('编译代码') {
steps {

script {
echo "--------------- 步骤:开始编译代码 --------------- "
sh 'rm -rf dist.tar.gz'
sh 'npm install'
sh 'npm run docs:build'
sh 'tar -czf dist.tar.gz dist'
echo "--------------- 步骤:编译代码完成 --------------- "
}
}
}
stage('上传代码') {
steps {
script {
echo "--------------- 步骤:开始上传代码 --------------- "
echo "开始上传 dist 压缩包"
sshPublisher(
failOnError: true,
publishers: [
sshPublisherDesc(
configName: "${SSH_URL}",
verbose: true,
transfers: [
sshTransfer(
execCommand: '',
execTimeout: 120000,
flatten: false,
makeEmptyDirs: false,
noDefaultExcludes: false,
patternSeparator: '[, ]+',
remoteDirectory: 'passjava-learning/',
remoteDirectorySDF: false,
removePrefix: '',
sourceFiles: 'dist.tar.gz'
)
]
)
]
)
echo "完成上传 JAR 包"
echo "--------------- 步骤:上传代码完成 --------------- "
}
}
}
stage('更新代码') {
steps {
script {
echo "--------------- 步骤:开始更新代码 --------------- "
sshPublisher(
failOnError: true,
publishers: [
sshPublisherDesc(
configName: "${SSH_URL}",
verbose: true,
transfers: [
sshTransfer(
execCommand: "cd /nfs-data/passjava/passjava-learning && tar -xzf dist.tar.gz",
execTimeout: 120000
)
]
)
])
echo "--------------- 步骤:更新代码完成 --------------- "
}
}
}
}
}

def getSSHUrl(environment) {
switch (environment) {
case 'passjava-learning':
return '[email protected]'
default:
error "Unsupported environment: ${environment}"
}
}

0 comments on commit f86195a

Please sign in to comment.