Skip to content

Commit

Permalink
fix(docs): add redirect function for /current path (#3922)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteKoe authored Dec 13, 2024
1 parent 589bd88 commit bd4bd91
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 10 deletions.
25 changes: 17 additions & 8 deletions .github/workflows/release-to-maven-central.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,31 @@ jobs:
MAVEN_PASSWORD: ${{ secrets.OSS_SONATYPE_PASSWORD }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

- name: Deploy Asciidoc docs output to GitHub Pages
- name: Deploy documentation to GitHub Pages for version ${{ github.event.inputs.releaseversion }}
uses: JamesIves/[email protected]
with:
branch: gh-pages # The branch the action should deploy to.
folder: spring-boot-admin-docs/target/generated-docs # The folder the action should deploy.
branch: gh-pages
folder: spring-boot-admin-docs/target/generated-docs
target-folder: ${{ github.event.inputs.releaseversion }}
clean: true # Automatically remove deleted files from the deploy branch
clean: true

- name: Deploy Asciidoc docs output to GitHub Pages
- name: Deploy redirect for /current to /${{ github.event.inputs.releaseversion }}
uses: JamesIves/[email protected]
if: github.event.inputs.copyDocsToCurrent == 'true'
with:
branch: gh-pages # The branch the action should deploy to.
folder: spring-boot-admin-docs/target/generated-docs/current # The folder the action should deploy.
branch: gh-pages
folder: spring-boot-admin-docs/target/generated-docs/current
target-folder: /current
clean: true # Automatically remove deleted files from the deploy branch
clean: true

- name: Deploy deeplink redirect for /current/* to /${{ github.event.inputs.releaseversion }}/*
uses: JamesIves/[email protected]
if: github.event.inputs.copyDocsToCurrent == 'true'
with:
branch: gh-pages
folder: spring-boot-admin-docs/target/generated-docs/current
target-folder: /
clean: false

publish-github-release:
needs: publish-central-and-pages
Expand Down
1 change: 1 addition & 0 deletions spring-boot-admin-docs/src/site/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
npm-debug.log*

current/index.html
current/404.html
111 changes: 111 additions & 0 deletions spring-boot-admin-docs/src/site/current/404.template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='utf-8'>
<title>Page not found · GitHub Pages</title>
<script type='text/javascript'>
function getRedirectUrl() {
const l = window.location;
if (l.pathname.includes("/current")) {
return l.protocol + "//" + l.hostname + (l.port ? ":" + l.port : "") +
[
"",
"@@VERSION@@",
l.pathname.split("/").slice(2)
].join("/")
+
l.hash;
}
}

const redirectUrl = getRedirectUrl();
if (redirectUrl) {
window.location.replace(redirectUrl);
}
</script>

<style type="text/css" media="screen">
body {
background-color: #f1f1f1;
margin: 0;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

.container {
margin: 50px auto 40px auto;
width: 600px;
text-align: center;
}

a {
color: #4183c4;
text-decoration: none;
}

a:hover {
text-decoration: underline;
}

h1 {
width: 800px;
position: relative;
left: -100px;
letter-spacing: -1px;
line-height: 60px;
font-size: 60px;
font-weight: 100;
margin: 0 0 50px 0;
text-shadow: 0 1px 0 #fff;
}

p {
color: rgba(0, 0, 0, 0.5);
margin: 20px 0;
line-height: 1.6;
}

ul {
list-style: none;
margin: 25px 0;
padding: 0;
}

li {
display: table-cell;
font-weight: bold;
width: 1%;
}

#suggestions {
margin-top: 35px;
color: #ccc;
}

#suggestions a {
color: #666666;
font-weight: 200;
font-size: 14px;
margin: 0 10px;
}
</style>
</head>
<body>
<div class="container">

<h1>404</h1>
<p><strong>There isn't a GitHub Pages site here.</strong></p>

<p>
Did you mean to visit <a href="//docs.spring-boot-admin.com/">docs.spring-boot-admin.com</a>?
Please note that this site belongs to a GitHub user and is
<strong>not an official GitHub site</strong>.
</p>

<div id="suggestions">
<a href="https://github.com/codecentric/spring-boot-admin">@codecentric/spring-boot-admin</a>
<a href="https://www.codecentric.de">codecentric</a>
<a href="https://github.com/codecentric/spring-boot-admin/issues">Issues</a>
</div>
</div>
</body>
</html>
4 changes: 2 additions & 2 deletions spring-boot-admin-docs/src/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"scripts": {
"docusaurus": "docusaurus",
"start": "docusaurus start",
"build:current-version-redirect": "sed \"s/@@VERSION@@/$VERSION/g\" current/index.template.html > current/index.html",
"build:current-version-redirect": "sed \"s/@@VERSION@@/$VERSION/g\" current/index.template.html > current/index.html && sed \"s/@@VERSION@@/$VERSION/g\" current/404.template.html > current/404.html",
"build": "docusaurus build",
"build:prod": "npm run build && npm run build:current-version-redirect && cp ./build ../../target/generated-docs"
"build:prod": "npm run build && npm run build:current-version-redirect && mv ./build ../../target/generated-docs"
},
"dependencies": {
"@docusaurus/core": "^3.6.3",
Expand Down

0 comments on commit bd4bd91

Please sign in to comment.