-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathinit-topics-and-clients.sh
More file actions
executable file
·77 lines (62 loc) · 2.08 KB
/
Copy pathinit-topics-and-clients.sh
File metadata and controls
executable file
·77 lines (62 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# See README for usage
# This file will create stub files for all the topics.
# first check to make sure there are arguments
if [ -z "$1" ]; then
echo "You must supply a path to the topics as the first argument"
exit 1
fi
if [ -z "$2" ]; then
echo "You must supply a path to the clients directory as the second argument"
exit 1
fi
# check for validity of these arguments as paths
if [ ! -d "$1" ]; then
echo "The topics directory must exist and be a valid path"
exit 1
fi
if [ ! -d "$2" ]; then
echo "The clients directory must exist and be a valid path"
exit 1
fi
# check for old style /docs/topics
if [ -e "content/docs/topics" ]; then
echo "Documentation topic files have moved. Delete content/docs/topics before proceeding."
exit 1
fi
# Create symlink to topics, except if it already exists and points to the same directory.
if [ ! -L build-topics -o "$(readlink build-topics)" != "$1" ]; then
ln -s $1 ./build-topics
fi
for fname in $(find $1 -maxdepth 1 -iname "*.md")
do
base=${fname##*/}
topic=${base%.*}
if [[ "$topic" != "index" ]]; then
if [ -f "./build/custom-frontmatter/topics/$topic.toml" ]; then
echo "+++" >> "./content/topics/$topic.md"
cat "./build/custom-frontmatter/topics/$topic.toml" >> "./content/topics/$topic.md"
echo "+++" >> "./content/topics/$topic.md"
else
cat << EOF > "./content/topics/$topic.md"
+++
# This is a generated stub file.
# To edit the content see /topic/$topic.md in the 'valkey-doc' repo
aliases = ["/docs/topics/$topic/"]
+++
EOF
fi
fi
done
echo "Topic stub files created at content/topics."
for fname in $(find $1 -maxdepth 1 -iname "*.png" -o -iname "*.jpg" -o -iname "*.jpeg" -o -iname "*.gif")
do
base=${fname##*/}
cp ${fname} ./content/topics/${base}
done
echo "Copied images to topics directory."
#create symlink to clients, expect if it already exists
if [ ! -L build-clients -o "$(readlink build-clients)" != "$2" ]; then
ln -s $2 ./build-clients
fi
echo "Symlink to clients has been created at ./build-clients "