Style active link in SSG #1434
-
|
Hi! Been learning Lit for the last few days and using Greenwood for a framework, and I'm really liking it so far. I've just run into a hiccup I don't know how to solve, and would love some insight if what I'm trying to do is possible. I have a sidebar component which styles the current link differently, using a class: I achieve this via a utility function that checks the given href against This of course can't work during SSG, as there's no Any help would be really appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
|
Hey @EskiMojo14 , thanks for checking out Greenwood and glad you are enjoying it so far! So Greenwood has a config setting called "Active Content" that I think is what you're looking for here, as I use it for just this kind of thing! Specifically, you would be looking to leverage the Active Frontmatter pattern, which is similar in nature to an ESI (edge side include). For example, on the Greenwood website we use this pattern a lot to do the underline styles for the header navigation, and side nav "highlight" styling based on the current page
Here are the code links for you to check, and let me know if you have any other questions!
Hope that helps! ✌️ |
Beta Was this translation helpful? Give feedback.
-
|
So on the topic of production time content as data issue, I figured out what the issue was and so now have that working in the production build * 🥳
'<meta property="og:description"\n' +
' content="eskimojo - Where the heart is"\n' +
' >\n' +
' <link rel="stylesheet" href="../styles/global.css" crossorigin >\n' +
'<link rel="preconnect" href="https://fonts.googleapis.com" >\n' +
'<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin >\n' +
' \n' +
' <script type="module" src="../scripts/initial-theme.ts"></script>\n' +
'<script type="module" src="../components/sidebar/sidebar.ts"></script>\n' +
'<script type="module" src="../components/header/header.ts"></script>\n' +
' </head>\n' +
' <body>\n' +
' \n' +
' <sidebar-nav current-route="/"></sidebar-nav>\n' +
' <div class="root">\n' +
' <page-header>\n' +
' Home\n' +
' <p slot="subtitle">Where the heart is</p>\n' +
' </page-header>\n' +
' \n' +
' </div>\n' +
' \n' +
' </body>\n' +
' </html>\n' { headerText: '', subtitleText: '' }So I think then when the client kicks which will support those DOM operations and gets the actual injected values, this then becomes the likely cause of the mismatch? Will keep playing around with it just to make sure it's not a Greenwood thing and get a new release out with everything identified so far at least. Either way, keep building and keep asking questions; thanks again for helping out with all your reports and feedback. 🏗️ We're getting there! The site looks really nice btw 💯 |
Beta Was this translation helpful? Give feedback.
-
|
OK, v0.32.0-alpha.7 should now include all reported patches so that any of the PNPM ones can be removed now.🤞 |
Beta Was this translation helpful? Give feedback.








Hey @EskiMojo14 , thanks for checking out Greenwood and glad you are enjoying it so far!
So Greenwood has a config setting called "Active Content" that I think is what you're looking for here, as I use it for just this kind of thing! Specifically, you would be looking to leverage the Active Frontmatter pattern, which is similar in nature to an ESI (edge side include).
For example, on the Greenwood website we use this pattern a lot to do the underline styles for the header navigation, and side nav "highlight" styling based on the current page
HTMLElementhere, but aLitElementshould work j…