Skip to content

Commit eedc1a6

Browse files
committed
add redirects for existing news
the url redirect option does not play well on github. So instead we keep the new url pattern for news and add redirect files for the existing news links. That way old news are accessible from the old and the new link, ex.: old: /project/2018/07/16/release-1.0.8.html new: /news/2018-07-16-release-1.0.8 New news do not need this redirect.
1 parent 07bebef commit eedc1a6

File tree

33 files changed

+141
-6
lines changed

33 files changed

+141
-6
lines changed

.vitepress/config.mts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,4 @@ export default defineConfig({
195195
pattern: 'https://github.com/naemon/naemon.github.io/edit/master/src/:path'
196196
}
197197
},
198-
199-
// rewrite urls from existing news
200-
// https://vitepress.dev/reference/site-config#routing
201-
rewrites: {
202-
'news/:year(\\d+)-:mon(\\d+)-:day(\\d+)-:slug(.*\\.md)': 'project/:year/:mon/:day/:slug',
203-
},
204198
})

.vitepress/theme/Redirect.vue

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<script setup>
2+
import { useData } from 'vitepress';
3+
import { onMounted } from 'vue';
4+
5+
const { frontmatter } = useData();
6+
7+
onMounted(() => {
8+
if(frontmatter.value.url) {
9+
window.location.href = frontmatter.value.url;
10+
}
11+
});
12+
</script>
13+
14+
<meta http-equiv="refresh" :content=' "0;url="+frontmatter.url'>
15+
16+
# Redirect
17+
18+
Page has moved here: <a :href=$frontmatter.url>{{ $frontmatter.url }}</a>
19+

.vitepress/theme/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import DefaultTheme from 'vitepress/theme'
44
import '@fortawesome/fontawesome-free/css/all.css'
55
import './naemon.css'
66
import News from './News.vue'
7+
import Redirect from './Redirect.vue'
78
import Breadcrumb from './components/Breadcrumb.vue'
89

910
export default {
@@ -20,5 +21,6 @@ export default {
2021
app.config.globalProperties.$RELEASE_DATE = import.meta.env.VITE_RELEASE_DATE
2122

2223
app.component('news', News)
24+
app.component('redirect', Redirect)
2325
}
2426
} satisfies Theme
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: redirect
3+
url: /news/2014-02-01-quality-work
4+
---

src/project/2014/02/01/release.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: redirect
3+
url: /news/2014-02-01-release
4+
---

src/project/2014/02/09/docs.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: redirect
3+
url: /news/2014-02-09-docs
4+
---
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: redirect
3+
url: /news/2014-02-14-release-day
4+
---

src/project/2014/03/22/docs.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: redirect
3+
url: /news/2014-03-22-docs
4+
---
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: redirect
3+
url: /news/2014-08-27-on-the-road
4+
---
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
layout: redirect
3+
url: /news/2015-03-30-release-day
4+
---

0 commit comments

Comments
 (0)