mirror of
https://github.com/Lissy93/dashy.git
synced 2025-07-27 07:34:43 +02:00
Adds back-to-top functionality
This commit is contained in:
parent
743c65baf5
commit
f8d3632615
@ -1,7 +1,13 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
# A script to update each markdown file in the docs directory
|
||||||
|
# Used to process the docs from the GitHub repo to be used for dashy.to website
|
||||||
|
# Because GH and Docusourus dashy.to expect slightly different markdown features
|
||||||
|
# Written by @CrazyWolf13
|
||||||
|
|
||||||
def process_file(file_path):
|
def process_file(file_path):
|
||||||
|
# Read the file content
|
||||||
with open(file_path, 'r', encoding='utf-8') as file:
|
with open(file_path, 'r', encoding='utf-8') as file:
|
||||||
content = file.read()
|
content = file.read()
|
||||||
|
|
||||||
@ -14,12 +20,11 @@ def process_file(file_path):
|
|||||||
# Make each link relative, so replace ./docs with /docs
|
# Make each link relative, so replace ./docs with /docs
|
||||||
content = content.replace('./docs', '/docs')
|
content = content.replace('./docs', '/docs')
|
||||||
|
|
||||||
# Remove .md extension from every link while ensuring idempotency
|
# Remove .md extension from every relative link (ignoring http/https links)
|
||||||
content = re.sub(r'(\[[^\]]+\]\((?!https?://)[^)#]+?)\.md(/?#?[^)]*?)(\))', r'\1\2\3', content)
|
content = re.sub(r'(\[[^\]]+\]\((?!https?://)[^)#]+?)\.md(/?#?[^)]*?)(\))', r'\1\2\3', content)
|
||||||
|
|
||||||
# Replace back to top buttons
|
# Replace back to top buttons
|
||||||
# Assuming this pattern is correct; adjust if necessary
|
content = re.sub(r'\[\s*⬆️\s*Back to Top\s*\]\(#.*?\)', '[⬆️ Back to Top](#top)', content, flags=re.IGNORECASE)
|
||||||
content = re.sub(r'\[.*Back to top.*\]', '[⬆️ Back to Top](https://riot.im/app/#)', content)
|
|
||||||
|
|
||||||
# Remove any <details> tags
|
# Remove any <details> tags
|
||||||
content = re.sub(r'<details>.*?</details>', '', content, flags=re.DOTALL)
|
content = re.sub(r'<details>.*?</details>', '', content, flags=re.DOTALL)
|
||||||
@ -36,6 +41,5 @@ def process_docs_folder(folder_path):
|
|||||||
process_file(file_path)
|
process_file(file_path)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
# Update this path to the correct relative path where the script will be run in the GitHub Action
|
|
||||||
docs_folder_path = "./docs/"
|
docs_folder_path = "./docs/"
|
||||||
process_docs_folder(docs_folder_path)
|
process_docs_folder(docs_folder_path)
|
||||||
|
@ -13,7 +13,7 @@ export default function Home() {
|
|||||||
description="Dashy, the self-hosted dashboard app for your homelab">
|
description="Dashy, the self-hosted dashboard app for your homelab">
|
||||||
<HomePageHeader />
|
<HomePageHeader />
|
||||||
<HomePageFeatures />
|
<HomePageFeatures />
|
||||||
<main>
|
<main id="top">
|
||||||
</main>
|
</main>
|
||||||
</Layout>
|
</Layout>
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user