mirror of
https://github.com/BillyOutlast/posthog.com.git
synced 2026-02-04 03:11:21 +01:00
Contributing documentation updates (#1541)
* Move contributing docs into /contributing/* * Add table of contents to MDX files * consistent formatting of tips and notes * Fix CSS scoping * Avoid duplicates in safe_rename.py * revert yarn.lock change * Add safe redirects * remove unused attribute: className * fixed typo Co-authored-by: PostHog <hey@posthog.com> Co-authored-by: James Hawkins <47497682+jamesefhawkins@users.noreply.github.com>
This commit is contained in:
@@ -15,19 +15,28 @@ try:
|
||||
rename_from_regex = r'rename from contents(.*).md'
|
||||
rename_to_regex = r'rename to contents(.*).md'
|
||||
|
||||
|
||||
from_paths = re.findall(rename_from_regex, git_diff)
|
||||
to_paths = re.findall(rename_to_regex, git_diff)
|
||||
|
||||
if len(from_paths) > 0 and len(from_paths) == len(to_paths):
|
||||
netlify_config_text = requests.get('https://raw.githubusercontent.com/PostHog/posthog.com/master/netlify.toml').text
|
||||
|
||||
# Load existing redirect file to be used to avoid duplicates
|
||||
local_netlify_config_file = open("./netlify.toml", "r")
|
||||
local_netlify_config_text = local_netlify_config_file.read()
|
||||
local_netlify_config_file.close()
|
||||
|
||||
new_redirects = ''
|
||||
|
||||
for i in range(len(from_paths)):
|
||||
md_to_mdx = '.mdx' not in from_paths[i] and '.mdx' in to_paths[i]
|
||||
if from_paths[i] not in netlify_config_text and not md_to_mdx and from_paths[i] != '(.*)':
|
||||
new_redirects += redirect_text.format(from_paths[i], to_paths[i])
|
||||
new_redirect = redirect_text.format(from_paths[i], to_paths[i])
|
||||
|
||||
# Only add if the redirect is not already included
|
||||
if new_redirect not in local_netlify_config_text:
|
||||
print("Creating redirect: ", new_redirect)
|
||||
new_redirects += new_redirect
|
||||
|
||||
with open("./netlify.toml", "a") as netlify_config:
|
||||
netlify_config.write(new_redirects)
|
||||
|
||||
Reference in New Issue
Block a user