Verified Commit e5a980cc authored by Tom Riedl's avatar Tom Riedl

#21 Dynamically building tag pages

parent 86f7bce3
......@@ -15,6 +15,7 @@
"krypto",
"kryptow",
"kryptowährungen",
"middot",
"monospace",
"noopener",
"tomriedl"
......
......@@ -126,9 +126,13 @@ export const config = /*#__PURE__*/configuration({
result = result.replace(/OKEX_URL/g, 'https://www.okex.com/join/1/3066896');
result = result.replace(/SERVERPROFIS_URL/g, 'https://service.serverprofis.net/aff.php?aff=846');
// Free title tag to read it easily from shell script
result = result.replace("<title>", "\n<title>");
result = result.replace("</title>", "</title>\n");
// Open all external links in new tabs
const tags: RegExpMatchArray | null = result.match(/<a [^>]*href="[^"]*"[^>]*>/gm);
for (const tag of tags || [])
const linkTags: RegExpMatchArray | null = result.match(/<a [^>]*href="[^"]*"[^>]*>/gm);
for (const tag of linkTags || [])
{
const uri: RegExpMatchArray | null = tag.match(/.*href="([^"]*)".*/);
if (uri && uri.length >= 2)
......@@ -144,6 +148,22 @@ export const config = /*#__PURE__*/configuration({
}
}
// Replace tags
const tagsCode: RegExpMatchArray | null = result.match(/<code>##Tags##:(.*?)<\/code>/gm);
for (const codeBlock of tagsCode || [])
{
const tags: string = codeBlock.replace("<code>##Tags##:", "").replace("</code>", "").replace(",", " ").trim();
const tagList: Array<string> = tags.toLowerCase().split(" ");
const replacementTags: Array<string> = [];
for (const rawTag of tagList)
{
const tag = rawTag.trim();
replacementTags.push(`<a href="/tag/${tag}" class="TagLink">${tag}</a>`);
}
const replacement: string = `Tags: \n${replacementTags.join(" &middot; \n")}\n`;
result = result.replace(codeBlock, replacement);
}
// Extract first image to add it to og:image
const imageUrls: Array<string> | undefined = result.match(/<img [^>]*src="[^"]*"[^>]*>/gm)?.map((x: string) => x.replace(/.*src="([^"]*)".*/, '$1'));
const coverImage: string = imageUrls && imageUrls.length ? imageUrls[0] : "";
......
......@@ -27,6 +27,7 @@
"Sfinex",
"Slangbegriff",
"Strg",
"TOTPs",
"Tokensale",
"Verifizierungsprozess",
"YOGRBLF",
......
# Tag: $TAG
[Liste aller Tags der Website](/tags/)
This directory gets built by the CI system
\ No newline at end of file
# Beiträge mit dem Tag "coinlend"
- [Coinlend-App](/version1/coinlend-app/)
- [Kryptowährungen gegen Zinsen verleihen – Coinlend Anleitung/Tutorial](/version1/kryptowaehrungen-gegen-zinsen-verleihen-coinlend-anleitungtutorial/)
......@@ -29,3 +29,5 @@ Geschäftsführer Jan Pumpe erwähnte, dass sie neben dem Look & Fell der Websit
[![Coinlend App iPhone iOS](/wp-content/uploads/2018/07/download-on-the-app-store-300x89.png)](https://itunes.apple.com/us/app/coinlend/id1402850970?ls=1&mt=8)
[Weitere Artikel zu coinlend](/tag/coinlend/)
```##Tags##: android app coinlend ios lending saving zinsen verleihen```
......@@ -40,4 +40,6 @@ Um sich vor einem Verlust zu schützen, sollten die Schlüssel für die Two-Fact
Nutze immer eine Authentifizierung mit mehreren Faktoren, um deine Zugänge zu schützen. Die 2FA mit einem Authenticator ist hierfür eine einfache und schnell umzusetzende Möglichkeit.
*Titelbild von [George Becker](https://stocksnap.io/author/31938)*
\ No newline at end of file
*Titelbild von [George Becker](https://stocksnap.io/author/31938)*
```##Tags##: authenticator mfa schutz sicherheit tfa totp two-factor authentication verlust```
......@@ -21,6 +21,13 @@ Build:
- BuildNumber=$(cat "Meta/BuildNumber")
- Branch=$(cat "Meta/Branch")
- cd Implementation
# Check codedoc
- codedoc install
- codedoc check
# First build to generate tags
- codedoc build
- ../Pipeline/CreateTagPages.sh
- rm rf ./dist/*
# Replace variables
- find docs -type f \( -name "*.ts" -or -name "*.tsx" -or -name "*.html" -or -name "*.md" \) -print0 | xargs -0 sed -i "s/##0.0.0-feature##/$Version/g"
# Create sitemap
......@@ -34,7 +41,5 @@ Build:
- printf "\n\n| Datum | Commit | Kommentar |\n| --- | --- | --- |\n" >> "docs/md/changelog/index.md"
- 'git log --pretty=format:''| %ad | [%h](https://gitlab.com/TomRiedl/tomriedl.com/-/commit/%H) | %s |'' --date=short | grep -v "Merge branch" >> "docs/md/changelog/index.md"'
# Build
- codedoc install
- codedoc check
- codedoc build
#!/bin/bash
echo "Creating tag pages..."
if [ -d "docs/md/tag" ]; then rm -rf docs/md/tag/*; fi
TagIntro=$(cat docs/md/_tag.md)
TagIndexFile="docs/md/tag/all-tags"
for f in $(find dist -name '*.html' ! -name '_*' ! -name '404*'); do
echo "Reading tags from $f..."
Tags=$(cat $f | grep "\"TagLink\"" | grep "href=\"/tag/")
echo "$Tags" | while read Line
do
Tag=$(echo $Line | cut -d "\"" -f 2)
Tag=${Tag/\/tag\//}
if [ "$Tag" == "" ]; then break; fi
if [ ! -d "docs/md/tag/${Tag}" ]; then
mkdir -p "docs/md/tag/${Tag}"
echo "$Tag" >> $TagIndexFile
fi
UrlToHere=${f/dist\//\/}
UrlToHere=${UrlToHere/\/index.html/\/}
Title=$(cat $f | grep "<title>" | grep "</title>" | cut -d "|" -f 1)
Title=${Title/<title>/}
if [ ! -f "docs/md/tag/${Tag}/index.md" ]; then
Intro=${TagIntro/\$TAG/$Tag}
echo "$Intro" > "docs/md/tag/${Tag}/index.md"
printf "\n\n" >> "docs/md/tag/${Tag}/index.md"
fi
printf "%s [${Title}](${UrlToHere})\n" "-" >> "docs/md/tag/${Tag}/index.md"
done
done
sort $TagIndexFile | uniq -u > "$TagIndexFile.sorted"
TagIndex=$(cat $TagIndexFile.sorted)
cp "docs/md/_tag-index.md" "docs/md/tag/index.md"
printf "\n\n" >> "docs/md/tag/index.md"
echo "$TagIndex" | while read Tag
do
printf "%s [${Tag}](/tag/${Tag})\n" "-" >> "docs/md/tag/index.md"
done
rm "$TagIndexFile" "$TagIndexFile.sorted"
......@@ -35,7 +35,7 @@ Tag=$(git tag --contains $CI_COMMIT_SHA)
LastTag=$(git describe --tags --abbrev=0 --match '[0-9]*\.[0-9]*\.[0-9]*' $(git merge-base $RemoteName/$ReleaseBranchName HEAD))
CommitHash=$CI_COMMIT_SHA
CommitShortHash=$CI_COMMIT_SHORT_SHA
BuildNumber=$CI_PIPELINE_ID
BuildNumber=$CI_PIPELINE_IID
if [[ "$Branch" == "$ReleaseBranchName/"* ]]; then
echo "Detected $Branch branch."
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment