Skip to content

Commit 50c3844

Browse files
authored
Add auto-displayed "Last Updated" on each page based on git commit (#595)
* Add auto-displayed "Last Updated" on each page based on git commit * Replace deprecated Moment.js with Day.js, the minimum alternative * Update Container file for auto last-update * Update podman command for auto last-updated The .git directory must be exposed inside the container because last-updated is based on git [1]. https://v1.vuepress.vuejs.org/theme/default-theme-config.html#last-updated
1 parent 09d8388 commit 50c3844

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

Containerfile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
FROM docker.io/library/node:lts-alpine AS builder
22
LABEL stage=auto-clean-stage1
3-
RUN mkdir -p /wiki/tmp
4-
COPY . /wiki/tmp
5-
WORKDIR /wiki/tmp
6-
RUN yarn
3+
RUN mkdir -p /work
4+
COPY . /work
5+
WORKDIR /work
6+
RUN yarn
77

88
FROM docker.io/library/node:lts-alpine
9+
# alternate node_modules directory brought from builder
10+
ARG alt_node_modules=/node_modules
11+
ENV alt_node_modules ${alt_node_modules}
12+
# required for auto last-update
13+
RUN apk update && apk add git
14+
915
RUN mkdir /wiki
1016
WORKDIR /wiki
11-
COPY --from=builder /wiki/tmp/package.json /wiki/package.json
12-
COPY --from=builder /wiki/tmp/node_modules /wiki/node_modules
13-
COPY --from=builder /wiki/tmp/yarn.lock /wiki/yarn.lock
14-
CMD yarn run docs:dev
17+
18+
COPY --from=builder /work/node_modules ${alt_node_modules}
19+
20+
CMD yarn run --modules-folder=${alt_node_modules} vuepress dev docs

docs/.vuepress/config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,21 @@ module.exports = {
1818
['link', { rel: "shortcut icon", type: 'image/png', href: "/images/logo.png"}],
1919
],
2020
base: '/',
21+
plugins: [
22+
[
23+
'@vuepress/last-updated',
24+
{
25+
transformer: (timestamp, lang) =>
26+
{
27+
var dayjs = require('dayjs')
28+
// Omit time from last updated
29+
return dayjs(timestamp).format('YYYY-MM-DD')
30+
}
31+
}
32+
]
33+
],
2134
themeConfig: {
35+
lastUpdated: true,
2236
logo: '/images/logo.png',
2337
nav: [
2438
{ text: 'Home', link: 'https://almalinux.org/' },

docs/Contribute-to-Documentation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ You can use a container engine like Podman or Docker to deploy a local developme
7575
```
7676
* Now you can create a container from this image whenever is needed from the image that was built above and mount *docs* to */wiki/docs* inside the container:
7777
```sh
78-
podman run --name wiki_dev --rm -i -t -p 8080:8080 -v "$(pwd)"/docs:/wiki/docs:ro,z localhost/wiki_dev
78+
podman run --name wiki_dev --rm -i -t -p 8080:8080 -v "$(pwd)":/wiki:ro,z localhost/wiki_dev
7979
```
8080
The options of the command are:
8181
* `podman/docker` - container engine
@@ -84,7 +84,7 @@ You can use a container engine like Podman or Docker to deploy a local developme
8484
* `--rm` - remove the container once it is stopped
8585
* `-i -t` - an interactive terminal session where you can track the deployment process and check the logs. Stop it with `Ctrl+C`.
8686
* `-p 8080:8080` - map the port number 8080 inside the container to 8080 on the host
87-
* `-v "$(pwd)"/docs:/wiki/docs:ro,z` - mount `docs` in the current directory on `/wiki/docs` inside the container read-only (ro). **`,z` is needed only for systems that have SELinux.**
87+
* `-v "$(pwd)":/wiki:ro,z` - mount the current directory (the repository root) on `/wiki` inside the container read-only (ro). **`,z` is needed only for systems that have SELinux.**
8888
* `localhost/wiki_dev` - the name of the container image
8989
* The wiki instance should be up and running on [http://localhost:8080/](http://localhost:8080/).
9090
* Don't forget to stop the container when you've finished.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,8 @@
88
},
99
"devDependencies": {
1010
"vuepress": "^1.9.9"
11+
},
12+
"dependencies": {
13+
"dayjs": "^1.11.13"
1114
}
1215
}

0 commit comments

Comments
 (0)