mirror of
https://gitea.com/gitea/docs.git
synced 2026-06-29 07:34:22 +00:00
Add outdated component to outdated documents (#25)
- `git log` needs all commit history to compare latest commit of files, so changed `git clone --depth=1` to `git clone`. This will make the step take longer, so might be improved if there is a better way. - `src/theme/MDXContent/index.js` is from [ejecting of the component](https://docusaurus.io/docs/swizzling#ejecting) inside `@docusaurus/theme-classic` plugin, and this one is safe to eject according to docusaurus   - [Outdated component style reference](https://mui.com/material-ui/react-alert/) - Added [`Translate` component](https://docusaurus.io/docs/next/docusaurus-core#translate) to `Outdated` so it can be localized. [reference](https://docusaurus.io/docs/next/i18n/tutorial#translate-your-react-code) - One way to check for the specific outdated documents: search for `lastest commit timestamp` in [prepare nightly docs and prepare 1.19 docs steps](https://gitea.com/gitea/gitea-docusaurus/actions/runs/74) # After The Chinese documents that are outdated (latest commit is ealier than laster commit of English version):    Reviewed-on: https://gitea.com/gitea/gitea-docusaurus/pulls/25 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: HesterG <hestergong@gmail.com> Co-committed-by: HesterG <hestergong@gmail.com>
This commit is contained in:
38
check_outdated.sh
Executable file
38
check_outdated.sh
Executable file
@@ -0,0 +1,38 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The script takes two params:
|
||||
# version: "latest" or a specific version number
|
||||
# locale
|
||||
# This script checks if a specific locale version of document is up to date with English version
|
||||
# If latest commit timestamp of English version is greater than the specific locale version,
|
||||
# The specific locale version document will be marked as outdated
|
||||
|
||||
set -xe
|
||||
|
||||
if sed --version 2>/dev/null | grep -q GNU; then
|
||||
SED_INPLACE="sed -i"
|
||||
else
|
||||
SED_INPLACE="sed -i ''"
|
||||
fi
|
||||
version="$1"
|
||||
locale="$2"
|
||||
cur_path=`pwd`
|
||||
cd .tmp/upstream-docs-"$version"
|
||||
|
||||
for file in `find ./docs/content/doc -name "*.${locale}.md"`; do
|
||||
file_en="${file/.${locale}/.en-us}"
|
||||
if [ ! -f "$file_en" ]; then
|
||||
continue
|
||||
fi
|
||||
latest_commit_time_en=$(git log -1 --format=%ct "$file_en")
|
||||
latest_commit_time_locale=$(git log -1 --format=%ct "$file")
|
||||
if [ -z "$latest_commit_time_locale" ]; then
|
||||
continue
|
||||
fi
|
||||
if [[ "$latest_commit_time_en" -gt "$latest_commit_time_locale" ]]; then
|
||||
echo "file: $file, lastest commit timestamp: $latest_commit_time_en (en ver), $latest_commit_time_locale ($locale ver)"
|
||||
$SED_INPLACE '1s/---/---\nisOutdated: true/' $file
|
||||
fi
|
||||
done
|
||||
|
||||
cd "$cur_path"
|
||||
Reference in New Issue
Block a user