Skip to content

Commit

Permalink
experiment with link preview support
Browse files Browse the repository at this point in the history
  • Loading branch information
eerussianguy committed Oct 4, 2024
1 parent 327bbb6 commit 03a6bd7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
11 changes: 9 additions & 2 deletions assets/templates/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>{title}</title>
<meta name="title" content="{long_title}" />
<meta name="description" content="{short_description}" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://terrafirmacraft.github.io/Field-Guide" />
<meta property="og:title" content="{long_title}" />
<meta property="og:description" content="{short_description}" />
<meta property="og:image" content="{preview_image}" />

<title>{long_title}</title>

<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.min.css">
Expand Down
14 changes: 13 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ def build_book_html(context: Context):
# Main Page
util.write_html(context.output_dir, 'index.html', html=TEMPLATE.format(
title=context.translate(I18n.TITLE),
long_title=context.translate(I18n.TITLE),
short_description=context.translate(I18n.HOME),
preview_image=get_splash_location(),
text_index=context.translate(I18n.INDEX),
text_contents=context.translate(I18n.CONTENTS),
text_version=context.translate(I18n.VERSION),
Expand Down Expand Up @@ -434,7 +437,7 @@ def build_book_html(context: Context):
""".format(
text_home=context.translate(I18n.HOME),
text_entries=context.translate(I18n.CATEGORIES),
splash_image='splash' if versions.MC_VERSION != '1.20.1' else 'splash_120'
splash_image=get_splash_location()
) + '\n'.join(
"""
<div class="col">
Expand All @@ -458,6 +461,9 @@ def build_book_html(context: Context):
for category_id, cat in context.sorted_categories:
util.write_html(context.output_dir, category_id, 'index.html', html=TEMPLATE.format(
title=context.translate(I18n.TITLE),
long_title=cat.name + " | " + context.translate(I18n.TITLE),
short_description=cat.name,
preview_image=get_splash_location(),
text_index=context.translate(I18n.INDEX),
text_contents=context.translate(I18n.CONTENTS),
text_version=context.translate(I18n.VERSION),
Expand Down Expand Up @@ -514,6 +520,9 @@ def build_book_html(context: Context):
for entry_id, entry in cat.sorted_entries:
util.write_html(context.output_dir, entry_id + '.html', html=TEMPLATE.format(
title=context.translate(I18n.TITLE),
long_title=entry.name + " | " + cat.name + " | " + context.translate(I18n.TITLE),
short_description=entry.name,
preview_image=entry.icon,
text_index=context.translate(I18n.INDEX),
text_contents=context.translate(I18n.CONTENTS),
text_version=context.translate(I18n.VERSION),
Expand Down Expand Up @@ -569,6 +578,9 @@ def title_with_optional_icon(text: str, icon_src: str, icon_title: str) -> str:
else:
return text

def get_splash_location():
return 'splash' if versions.MC_VERSION != '1.20.1' else 'splash_120'

def entry_card_with_default_icon(entry_page: str, entry_title: str, icon_src: str, icon_title: str) -> str:
if not icon_src:
icon_src = util.path_join('..', '..', '_images', 'placeholder_16.png')
Expand Down
1 change: 1 addition & 0 deletions tfc/TerraFirmaCraft
Submodule TerraFirmaCraft added at 250691

0 comments on commit 03a6bd7

Please sign in to comment.