Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add layout partial list.html for sequential links #1395

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

jhauga
Copy link

@jhauga jhauga commented Jan 25, 2024

Added a partial that creates sequential page navigation at the bottom of each page. Thought it would make the site a bit better as when reading sequentially you can click to the next page in the current section without scrolling up.

Some of the links had to be modified with JavaScript as was not able to achieve sequential weight navigation with Hugo.

Added support repo documentation-sequential-links with built site (hugo). Was hoping to have it deployed and fully working with GitHub "Pages", but had to use "Codespaces" for everything (most) to work correctly. I just started a codespace for main branch and started a local host with php -S localhost:8000. From there GitHub prompts with link to open in browser.

Added a partial that creates sequential page navigation. At bottom of each page. Thought it would make the site a bit better as when reading sequentially you can click to the next page in the current section. 

Some of the links had to be modified with JavaScript as was not able to achieve sequential weight navigation with Hugo.
Copy link

vercel bot commented Jan 25, 2024

@jhauga is attempting to deploy a commit to the Mastodon Team on Vercel.

A member of the Team first needs to authorize it.

@jhauga jhauga changed the title layout partial - list - sequential links Add layout partial list.html for sequential links Jan 25, 2024
Disable initial state and change innerHTML of filler sequential page links.
</aside>
<div class="e-content">
{{ .Content }}
{{ partial "list.html" . }}
Copy link
Author

@jhauga jhauga Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including new partial template list.html after generated content. Output is essentially :
Previous - Page Next - Page

To Expand:
"Page" is changed to the page's innerText from the side nav or the page name as Hugo reads it. Links that are alphabetically sorted used Hugo, but had to use JavaScript to make sequential weighted links.

{{ if $currentPage.IsMenuCurrent "docs" . }}
<!-- Add filler html and use JavaScript to put in correct links. -->
<div style="margin: {{ $verticalMargin }} 0px">
<a id="previousLink" href="javascript:void(0)" style="font-size: {{ $fontSize }}">Previous - Page</a>
Copy link
Author

@jhauga jhauga Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed href to "javascript:void(0)" as if an error occurs, worst case scenario are un-working links with generic filler text. outputting:
Previous - Page Next - Page

To Expand:
Per testing links changed consistently for me. I made a support repo with a working example - Pull #1395 working example. You'll have to use "Codesapces" then localhost it. I used php -S localhost:8000, GitHub prompts with link, and a working (mostly) example.

With the "Codespaces" localhost the links in section "API Entities" go to a table of contents like page, but this happens when clicking on side nav and clicking on sequential nav.

var pageTurnSpacer = document.getElementById("pageTurnSpacer");
var useJS = document.getElementById("useJS");

// Only run statement to add correct links if html id useJS innerHTLM is 1.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using html from Hugo build (id="useJS") for variable that tells if content is genereated from Hugo (alphabetical sorted pages) or needs links and text to be changed with JavaScript.

Copy link
Author

@jhauga jhauga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added single line comments for a brief and expanded description of changes.

@jhauga jhauga marked this pull request as draft May 15, 2024 22:31
* Keep partials DRY and fix nested page sequential links

Utilize new partial to keep DRY (Don't Repeat Yourself) and got sequential links working for nested pages in all sections.

* Keep partials DRY and fix nested page sequential links

Utilize new partial to keep DRY (Don't Repeat Yourself) and got sequential links working for nested pages in all sections.
@jhauga jhauga marked this pull request as ready for review May 18, 2024 00:20
@jhauga
Copy link
Author

jhauga commented May 18, 2024

Utilized a new partial to keep DRY (Don't Repeat Yourself) and got sequential links working for nested pages in all sections.

A working sample, more details, and the testing procedure for this pull request can be found in a supporting supplemental repo:

documentation-sequential-links

{{ end }}

<script>
// IMPORTANT NOTE - this depends on HTML attributes to work.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is important.

// and text output of links will render as:
// <- Page Page ->

// DEPENDENT VARIABLES - redefine if HTML attributes or semantics change.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Variables in case dependent HTML tags and/or attributes change. These could be implemented elsewhere though.

nextLink.href = nextHref; // set href for next page
nextLink.innerHTML = nextLink.innerHTML.replace("Page", nextName); // set text for next page
} // IMPORTANT NOTE:
// WELL - VERY IMPORTANT NOTE - this all depends on current HTML attributes to work. //
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See top of script - the "FIRST SET OF VARIABLES" (its' important)

Copy link
Author

@jhauga jhauga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments on comments left in space regarding variables targeting dependent HTML DOM elements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants