fix(posts): Correct sidebar layout with Author, MiniGraph, Tags
This commit is contained in:
parent
336238e758
commit
7d0851f489
|
@ -192,7 +192,7 @@ const nodeTypeCounts = {
|
|||
</div>
|
||||
</div>
|
||||
<div class="full-post-footer">
|
||||
<a href="#" id="full-post-link" class="full-post-link" target="_self" rel="noopener noreferrer">
|
||||
<a href="#" id="full-post-link" class="full-post-link" target="_blank" rel="noopener noreferrer"> <!-- Changed target to _blank -->
|
||||
Read Full Article
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path>
|
||||
|
@ -878,41 +878,6 @@ const nodeTypeCounts = {
|
|||
// Reset graph view if "All" is selected
|
||||
cy.elements().removeClass('highlighted faded filtered');
|
||||
const allFilterBtn = document.querySelector('.graph-filter[data-filter="all"]');
|
||||
// Add event listener to prevent redirect in fullscreen mode
|
||||
if (fullPostLink) {
|
||||
fullPostLink.addEventListener('click', (e) => {
|
||||
if (isFullscreen) {
|
||||
// If in fullscreen, prevent default behavior to keep the user in the graph view
|
||||
e.preventDefault();
|
||||
|
||||
// Instead, display a message to exit fullscreen to visit the full article
|
||||
const message = document.createElement('div');
|
||||
message.className = 'fullscreen-message';
|
||||
message.textContent = 'Exit fullscreen to visit the full article page';
|
||||
message.style.position = 'absolute';
|
||||
message.style.bottom = '70px'; // Adjust as needed
|
||||
message.style.left = '50%';
|
||||
message.style.transform = 'translateX(-50%)';
|
||||
message.style.background = 'rgba(0, 0, 0, 0.75)';
|
||||
message.style.color = 'white';
|
||||
message.style.padding = '8px 16px';
|
||||
message.style.borderRadius = '4px';
|
||||
message.style.zIndex = '1000';
|
||||
message.style.transition = 'opacity 0.3s ease';
|
||||
|
||||
fullPostContent.appendChild(message);
|
||||
|
||||
// Remove the message after 3 seconds
|
||||
setTimeout(() => {
|
||||
message.style.opacity = '0';
|
||||
setTimeout(() => {
|
||||
message.remove();
|
||||
}, 300);
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Listen for ESC key to exit fullscreen
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape' && isFullscreen) {
|
||||
|
@ -958,41 +923,6 @@ const nodeTypeCounts = {
|
|||
// Dispatch graphReady event for external listeners
|
||||
document.dispatchEvent(new CustomEvent('graphReady', { detail: { cy } }));
|
||||
|
||||
// Add event listener to prevent redirect in fullscreen mode
|
||||
if (fullPostLink) {
|
||||
fullPostLink.addEventListener('click', (e) => {
|
||||
if (isFullscreen) {
|
||||
// If in fullscreen, prevent default behavior to keep the user in the graph view
|
||||
e.preventDefault();
|
||||
|
||||
// Instead, display a message to exit fullscreen to visit the full article
|
||||
const message = document.createElement('div');
|
||||
message.className = 'fullscreen-message';
|
||||
message.textContent = 'Exit fullscreen to visit the full article page';
|
||||
message.style.position = 'absolute';
|
||||
message.style.bottom = '70px'; // Adjust as needed
|
||||
message.style.left = '50%';
|
||||
message.style.transform = 'translateX(-50%)';
|
||||
message.style.background = 'rgba(0, 0, 0, 0.75)';
|
||||
message.style.color = 'white';
|
||||
message.style.padding = '8px 16px';
|
||||
message.style.borderRadius = '4px';
|
||||
message.style.zIndex = '1000';
|
||||
message.style.transition = 'opacity 0.3s ease';
|
||||
|
||||
fullPostContent.appendChild(message);
|
||||
|
||||
// Remove the message after 3 seconds
|
||||
setTimeout(() => {
|
||||
message.style.opacity = '0';
|
||||
setTimeout(() => {
|
||||
message.remove();
|
||||
}, 300);
|
||||
}, 3000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Listen for ESC key to exit fullscreen
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape' && isFullscreen) {
|
||||
|
|
|
@ -1,14 +1,12 @@
|
|||
---
|
||||
title: Secure Remote Access with Cloudflare Tunnels
|
||||
title: This is a test
|
||||
description: How to set up Cloudflare Tunnels for secure remote access to your home lab services
|
||||
pubDate: Jul 22 2023
|
||||
heroImage: /images/posts/prometheusk8.png
|
||||
category: networking
|
||||
tags:
|
||||
- cloudflare
|
||||
- networking
|
||||
- security
|
||||
- homelab
|
||||
- tunnels
|
||||
- Tag A
|
||||
- Tag B
|
||||
- Tag C
|
||||
readTime: "7 min read"
|
||||
---
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
import BaseLayout from './BaseLayout.astro';
|
||||
import Header from '../components/Header.astro';
|
||||
import Footer from '../components/Footer.astro';
|
||||
import MiniKnowledgeGraph from '../components/MiniKnowledgeGraph.astro'; // Restore original or keep if needed
|
||||
// import MiniKnowledgeGraph from '../components/MiniKnowledgeGraph.astro'; // Keep if needed elsewhere, but remove from main content
|
||||
import MiniGraph from '../components/MiniGraph.astro'; // Add import for MiniGraph
|
||||
import { getCollection } from 'astro:content';
|
||||
|
||||
interface Props {
|
||||
|
@ -137,11 +138,11 @@ const displayImage = frontmatter.heroImage || '/images/placeholders/default.jpg'
|
|||
</div>
|
||||
)}
|
||||
|
||||
{/* Content Connections - Knowledge Graph */}
|
||||
<div class="content-connections">
|
||||
{/* Content Connections - Removed MiniKnowledgeGraph from here */}
|
||||
{/* <div class="content-connections">
|
||||
<h3 class="connections-title">Post Connections</h3>
|
||||
<MiniKnowledgeGraph currentPost={currentPost} relatedPosts={relatedPosts} />
|
||||
</div>
|
||||
</div> */}
|
||||
|
||||
{/* Main Content Area */}
|
||||
<div class="blog-post-content prose prose-invert max-w-none">
|
||||
|
@ -194,6 +195,24 @@ const displayImage = frontmatter.heroImage || '/images/placeholders/default.jpg'
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{/* MiniGraph Component - Placed after Author Card */}
|
||||
<MiniGraph
|
||||
slug={slug}
|
||||
title={frontmatter.title}
|
||||
tags={frontmatter.tags}
|
||||
category={frontmatter.category}
|
||||
/>
|
||||
|
||||
{/* Tags Section - Placed after MiniGraph */}
|
||||
<div class="sidebar-card">
|
||||
<h3 class="sidebar-title">Tags</h3>
|
||||
<div class="tags">
|
||||
{frontmatter.tags && frontmatter.tags.map(tag => (
|
||||
<a href={`/tag/${tag}`} class="tag">{tag}</a>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Table of Contents Card */}
|
||||
<div class="sidebar-card toc-card">
|
||||
<h3>Table of Contents</h3>
|
||||
|
@ -306,6 +325,37 @@ const displayImage = frontmatter.heroImage || '/images/placeholders/default.jpg'
|
|||
font-style: italic;
|
||||
font-size: 0.9rem;
|
||||
}
|
||||
|
||||
/* Add styles for Tags in the sidebar */
|
||||
.tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
|
||||
.tag {
|
||||
color: var(--accent-secondary);
|
||||
text-decoration: none;
|
||||
font-size: 0.85rem;
|
||||
transition: all 0.3s ease;
|
||||
font-family: var(--font-mono);
|
||||
background-color: rgba(59, 130, 246, 0.1);
|
||||
padding: 0.3rem 0.6rem;
|
||||
border-radius: 4px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.tag:hover {
|
||||
color: var(--accent-primary);
|
||||
background-color: rgba(6, 182, 212, 0.15);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.sidebar-title {
|
||||
font-size: 1.1rem;
|
||||
margin-bottom: 1rem;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
</style>
|
||||
|
||||
<style>
|
|
@ -2,6 +2,7 @@
|
|||
// src/pages/posts/[slug].astro
|
||||
import { getCollection } from 'astro:content';
|
||||
import BaseLayout from '../../layouts/BaseLayout.astro';
|
||||
import MiniGraph from '../../components/MiniGraph.astro'; // Add import for MiniGraph
|
||||
|
||||
// Required getStaticPaths function for dynamic routes
|
||||
export async function getStaticPaths() {
|
||||
|
@ -156,9 +157,38 @@ const { Content } = await post.render();
|
|||
</div>
|
||||
|
||||
<aside class="post-sidebar">
|
||||
<!-- 1. Author Card (New) -->
|
||||
{post.data.author && (
|
||||
<div class="author-card sidebar-block">
|
||||
<h3 class="sidebar-title">Author</h3>
|
||||
<div class="author-profile">
|
||||
<div class="author-avatar">
|
||||
{post.data.authorImage ?
|
||||
<img src={post.data.authorImage} alt={post.data.author} /> :
|
||||
<div class="default-avatar">{post.data.author.charAt(0)}</div>
|
||||
}
|
||||
</div>
|
||||
<div class="author-info">
|
||||
<div class="author-name">{post.data.author}</div>
|
||||
{post.data.authorBio && <div class="author-bio">{post.data.authorBio}</div>}
|
||||
{post.data.authorUrl && <a href={post.data.authorUrl} class="author-link">Profile</a>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<!-- 2. Mini Knowledge Graph (New) -->
|
||||
<MiniGraph
|
||||
slug={post.slug}
|
||||
title={post.data.title}
|
||||
tags={post.data.tags || []}
|
||||
category={post.data.category || ''}
|
||||
/>
|
||||
|
||||
<!-- 3. Tags (Existing, moved below MiniGraph) -->
|
||||
{post.data.tags && post.data.tags.length > 0 && (
|
||||
<div class="tags-section sidebar-block">
|
||||
<h3>Tags</h3>
|
||||
<h3 class="sidebar-title">Tags</h3>
|
||||
<div class="tags">
|
||||
{post.data.tags.map(tag => (
|
||||
<a href={`/tag/${tag}`} class="tag">{tag}</a>
|
||||
|
@ -169,7 +199,7 @@ const { Content } = await post.render();
|
|||
|
||||
{post.data.category && (
|
||||
<div class="category-section sidebar-block">
|
||||
<h3>Category</h3>
|
||||
<h3 class="sidebar-title">Category</h3>
|
||||
<a href={`/categories/${post.data.category}`} class="category">
|
||||
{post.data.category}
|
||||
</a>
|
||||
|
@ -178,7 +208,7 @@ const { Content } = await post.render();
|
|||
|
||||
{post.data.categories && post.data.categories.length > 0 && (
|
||||
<div class="categories-section sidebar-block">
|
||||
<h3>Categories</h3>
|
||||
<h3 class="sidebar-title">Categories</h3>
|
||||
<div class="categories">
|
||||
{post.data.categories.map(category => (
|
||||
<a href={`/categories/${category}`} class="category">
|
||||
|
@ -191,7 +221,7 @@ const { Content } = await post.render();
|
|||
|
||||
{combinedRelatedPosts.length > 0 && (
|
||||
<div class="related-posts-section sidebar-block">
|
||||
<h3>Related Articles</h3>
|
||||
<h3 class="sidebar-title">Related Articles</h3>
|
||||
<ul class="related-posts">
|
||||
{combinedRelatedPosts.map(relatedPost => (
|
||||
<li>
|
||||
|
@ -292,12 +322,79 @@ const { Content } = await post.render();
|
|||
border: 1px solid var(--border-primary);
|
||||
}
|
||||
|
||||
.sidebar-block h3 {
|
||||
.sidebar-block h3, .sidebar-title {
|
||||
font-size: var(--font-size-lg, 1.125rem);
|
||||
margin-bottom: 1rem;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* Author Card Styles */
|
||||
.author-profile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.author-avatar {
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
border-radius: 50%;
|
||||
overflow: hidden;
|
||||
border: 2px solid var(--accent-primary);
|
||||
}
|
||||
|
||||
.author-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.default-avatar {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
|
||||
color: white;
|
||||
font-size: 1.5rem;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.author-info {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.author-name {
|
||||
font-weight: 600;
|
||||
font-size: 1.1rem;
|
||||
margin-bottom: 0.25rem;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.author-bio {
|
||||
font-size: 0.875rem;
|
||||
color: var(--text-secondary);
|
||||
margin-bottom: 0.5rem;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.author-link {
|
||||
display: inline-block;
|
||||
font-size: 0.8rem;
|
||||
padding: 0.25rem 0.75rem;
|
||||
background: rgba(6, 182, 212, 0.1);
|
||||
border-radius: 20px;
|
||||
color: var(--accent-primary);
|
||||
text-decoration: none;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.author-link:hover {
|
||||
background: rgba(6, 182, 212, 0.2);
|
||||
transform: translateY(-2px);
|
||||
}
|
||||
|
||||
.tags {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
|
Loading…
Reference in New Issue