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

docs.raqn.io: adding basic table of content for developers content #34

Merged
merged 6 commits into from
Sep 6, 2024

Conversation

nc-andreashaller
Copy link
Collaborator

@nc-andreashaller nc-andreashaller commented Aug 6, 2024

Basic implementation of a table of content to have an overview of what pages are available generated from GIT markdown.

This can only be tested with a local CORS proxy or directly on docs.raqn.io

image

unfortunately not working

Copy link

aem-code-sync bot commented Aug 6, 2024

Hello, I'm the AEM Code Sync Bot and I will run some actions to deploy your branch and validate page speed.
In case there are problems, just click a checkbox below to rerun the respective action.

  • Re-run PSI checks
  • Re-sync branch
Commits

Copy link

aem-code-sync bot commented Sep 4, 2024

Page Scores Audits Google
M /drafts/ahaller/developers-toc PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI
D /drafts/ahaller/developers-toc PERFORMANCE A11Y SEO BEST PRACTICES SI FCP LCP TBT CLS PSI

const sitePathPrefix = 'developers';

export default class DeveloperToc extends ComponentBase {
ready() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optionally for this type of component which needs to be initialized without having a block on the page, there is a feature used for breadcrumbs which could be reused.

This will add the component in the first section on the page based on the bellow selector for targetsSelectors.
Is it required to have it's own section?

Meta attribute structure-${componentName} -> structure-developers-toc set to true

Config required on the DeveloperToc class:

static loaderConfig = {
    ...ComponentBase.loaderConfig,
    targetsSelectors: 'main > div:first-child',
    targetsSelectorsLimit: 1,
  };
  
  extendConfig() {
    return [
      ...super.extendConfig(),
      {
        contentFromTargets: false,
        addToTargetMethod: 'replaceWith',
        targetsAsContainers: {
          addToTargetMethod: 'prepend',
          contentFromTargets: false,
        },
      },
    ];
  }

scripts/init.js Outdated
@@ -93,6 +93,7 @@ export const onLoadComponents = {
],

async init() {
await this.setupTemplateAndAutoBlocks();
Copy link
Collaborator

Choose a reason for hiding this comment

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

For templates we could still use the web-component to have the same features as a component where we can have different settings by viewport and css file if needed plus the ability to use the config file option.
It could even handle things like the placeholder render/replacement on content outside of blocks.

But this simple approach is also useful where we have just a small change like this and we don't need a full component.
Luckily our component loader can also work with a function if the module exports a default one instead of a class.

WDYT?

We can keep it as is, add the topic for spec/refinement to explore the options.

@nc-andreashaller nc-andreashaller merged commit 14008a5 into main Sep 6, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants