@commonpub/layer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/app.vue +7 -0
- package/components/AnnouncementBand.vue +117 -0
- package/components/AppToast.vue +108 -0
- package/components/AuthorCard.vue +119 -0
- package/components/AuthorRow.vue +81 -0
- package/components/CommentSection.vue +330 -0
- package/components/ContentCard.vue +340 -0
- package/components/ContentPicker.vue +240 -0
- package/components/ContentStarterForm.vue +214 -0
- package/components/ContentTypeBadge.vue +46 -0
- package/components/CountdownTimer.vue +68 -0
- package/components/CpubEditor.vue +87 -0
- package/components/DiscussionItem.vue +191 -0
- package/components/EditorPropertiesPanel.vue +393 -0
- package/components/EngagementBar.vue +131 -0
- package/components/FederatedContentCard.vue +291 -0
- package/components/FeedItem.vue +283 -0
- package/components/FilterChip.vue +21 -0
- package/components/HeatmapGrid.vue +92 -0
- package/components/ImageUpload.vue +219 -0
- package/components/MemberCard.vue +163 -0
- package/components/MessageThread.vue +120 -0
- package/components/NotificationItem.vue +103 -0
- package/components/ProgressTracker.vue +41 -0
- package/components/PublishErrorsModal.vue +116 -0
- package/components/RemoteActorCard.vue +206 -0
- package/components/RemoteUserSearch.vue +117 -0
- package/components/SearchFilters.vue +188 -0
- package/components/SearchSidebar.vue +181 -0
- package/components/SectionHeader.vue +17 -0
- package/components/ShareToHubModal.vue +189 -0
- package/components/SiteLogo.vue +21 -0
- package/components/SkillBar.vue +57 -0
- package/components/SortSelect.vue +30 -0
- package/components/StatBar.vue +14 -0
- package/components/TOCNav.vue +69 -0
- package/components/TimelineItem.vue +82 -0
- package/components/VideoCard.vue +106 -0
- package/components/blocks/BlockBuildStepView.vue +92 -0
- package/components/blocks/BlockCalloutView.vue +82 -0
- package/components/blocks/BlockCheckpointView.vue +50 -0
- package/components/blocks/BlockCodeView.vue +212 -0
- package/components/blocks/BlockContentRenderer.vue +143 -0
- package/components/blocks/BlockDividerView.vue +11 -0
- package/components/blocks/BlockDownloadsView.vue +126 -0
- package/components/blocks/BlockEmbedView.vue +61 -0
- package/components/blocks/BlockGalleryView.vue +57 -0
- package/components/blocks/BlockHeadingView.vue +29 -0
- package/components/blocks/BlockImageView.vue +34 -0
- package/components/blocks/BlockMarkdownView.vue +118 -0
- package/components/blocks/BlockMathView.vue +45 -0
- package/components/blocks/BlockPartsListView.vue +104 -0
- package/components/blocks/BlockQuizView.vue +239 -0
- package/components/blocks/BlockQuoteView.vue +41 -0
- package/components/blocks/BlockSectionHeaderView.vue +58 -0
- package/components/blocks/BlockSliderView.vue +236 -0
- package/components/blocks/BlockTextView.vue +41 -0
- package/components/blocks/BlockToolListView.vue +87 -0
- package/components/blocks/BlockVideoView.vue +89 -0
- package/components/editors/ArticleEditor.vue +545 -0
- package/components/editors/BlockCanvas.vue +487 -0
- package/components/editors/BlockInsertZone.vue +84 -0
- package/components/editors/BlockPicker.vue +285 -0
- package/components/editors/BlockWrapper.vue +192 -0
- package/components/editors/BlogEditor.vue +567 -0
- package/components/editors/EditorBlocks.vue +248 -0
- package/components/editors/EditorSection.vue +81 -0
- package/components/editors/EditorShell.vue +168 -0
- package/components/editors/EditorTagInput.vue +114 -0
- package/components/editors/EditorVisibility.vue +110 -0
- package/components/editors/ExplainerEditor.vue +503 -0
- package/components/editors/MarkdownImportDialog.vue +249 -0
- package/components/editors/ProjectEditor.vue +446 -0
- package/components/editors/blocks/BuildStepBlock.vue +102 -0
- package/components/editors/blocks/CalloutBlock.vue +122 -0
- package/components/editors/blocks/CheckpointBlock.vue +27 -0
- package/components/editors/blocks/CodeBlock.vue +177 -0
- package/components/editors/blocks/DividerBlock.vue +22 -0
- package/components/editors/blocks/DownloadsBlock.vue +41 -0
- package/components/editors/blocks/EmbedBlock.vue +20 -0
- package/components/editors/blocks/GalleryBlock.vue +236 -0
- package/components/editors/blocks/HeadingBlock.vue +96 -0
- package/components/editors/blocks/ImageBlock.vue +271 -0
- package/components/editors/blocks/MarkdownBlock.vue +258 -0
- package/components/editors/blocks/MathBlock.vue +37 -0
- package/components/editors/blocks/PartsListBlock.vue +358 -0
- package/components/editors/blocks/QuizBlock.vue +47 -0
- package/components/editors/blocks/QuoteBlock.vue +101 -0
- package/components/editors/blocks/SectionHeaderBlock.vue +130 -0
- package/components/editors/blocks/SliderBlock.vue +318 -0
- package/components/editors/blocks/TextBlock.vue +201 -0
- package/components/editors/blocks/ToolListBlock.vue +70 -0
- package/components/editors/blocks/VideoBlock.vue +22 -0
- package/components/hub/HubDiscussions.vue +47 -0
- package/components/hub/HubFeed.vue +199 -0
- package/components/hub/HubHero.vue +185 -0
- package/components/hub/HubLayout.vue +103 -0
- package/components/hub/HubMembers.vue +40 -0
- package/components/hub/HubProducts.vue +93 -0
- package/components/hub/HubProjects.vue +207 -0
- package/components/hub/HubSidebar.vue +12 -0
- package/components/hub/HubSidebarCard.vue +35 -0
- package/components/views/ArticleView.vue +771 -0
- package/components/views/BlogView.vue +667 -0
- package/components/views/ExplainerView.vue +688 -0
- package/components/views/ProjectView.vue +1500 -0
- package/composables/useApiError.ts +39 -0
- package/composables/useAuth.ts +87 -0
- package/composables/useBlockEditor.ts +187 -0
- package/composables/useContentSave.ts +253 -0
- package/composables/useContentTypes.ts +37 -0
- package/composables/useEngagement.ts +196 -0
- package/composables/useFeatures.ts +33 -0
- package/composables/useFederation.ts +72 -0
- package/composables/useJsonLd.ts +183 -0
- package/composables/useMarkdownImport.ts +77 -0
- package/composables/useMirrorContent.ts +105 -0
- package/composables/useNotifications.ts +73 -0
- package/composables/usePublishValidation.ts +65 -0
- package/composables/useSanitize.ts +34 -0
- package/composables/useSiteName.ts +4 -0
- package/composables/useTheme.ts +34 -0
- package/composables/useToast.ts +35 -0
- package/error.vue +129 -0
- package/layouts/admin.vue +213 -0
- package/layouts/auth.vue +63 -0
- package/layouts/default.vue +269 -0
- package/layouts/editor.vue +129 -0
- package/middleware/auth.ts +6 -0
- package/nuxt.config.ts +83 -0
- package/package.json +59 -0
- package/pages/[type]/[slug]/edit.vue +676 -0
- package/pages/[type]/[slug]/index.vue +313 -0
- package/pages/[type]/index.vue +118 -0
- package/pages/about.vue +100 -0
- package/pages/admin/audit.vue +66 -0
- package/pages/admin/content.vue +116 -0
- package/pages/admin/federation.vue +446 -0
- package/pages/admin/index.vue +62 -0
- package/pages/admin/reports.vue +88 -0
- package/pages/admin/settings.vue +167 -0
- package/pages/admin/users.vue +145 -0
- package/pages/auth/forgot-password.vue +103 -0
- package/pages/auth/login.vue +216 -0
- package/pages/auth/oauth/authorize.vue +178 -0
- package/pages/auth/register.vue +246 -0
- package/pages/auth/reset-password.vue +124 -0
- package/pages/auth/verify-email.vue +80 -0
- package/pages/cert/[code].vue +154 -0
- package/pages/contests/[slug]/edit.vue +153 -0
- package/pages/contests/[slug]/index.vue +556 -0
- package/pages/contests/[slug]/judge.vue +160 -0
- package/pages/contests/create.vue +192 -0
- package/pages/contests/index.vue +69 -0
- package/pages/create.vue +219 -0
- package/pages/dashboard.vue +521 -0
- package/pages/docs/[siteSlug]/[...pagePath].vue +704 -0
- package/pages/docs/[siteSlug]/edit.vue +480 -0
- package/pages/docs/[siteSlug]/index.vue +380 -0
- package/pages/docs/create.vue +60 -0
- package/pages/docs/index.vue +181 -0
- package/pages/explore.vue +422 -0
- package/pages/federated-hubs/[id]/index.vue +385 -0
- package/pages/federated-hubs/[id]/posts/[postId].vue +309 -0
- package/pages/federation/index.vue +157 -0
- package/pages/federation/search.vue +43 -0
- package/pages/federation/users/[handle].vue +221 -0
- package/pages/feed.vue +135 -0
- package/pages/hubs/[slug]/index.vue +513 -0
- package/pages/hubs/[slug]/members.vue +134 -0
- package/pages/hubs/[slug]/posts/[postId].vue +352 -0
- package/pages/hubs/[slug]/settings.vue +254 -0
- package/pages/hubs/create.vue +201 -0
- package/pages/hubs/index.vue +207 -0
- package/pages/index.vue +1005 -0
- package/pages/learn/[slug]/[lessonSlug]/edit.vue +413 -0
- package/pages/learn/[slug]/[lessonSlug]/index.vue +438 -0
- package/pages/learn/[slug]/edit.vue +414 -0
- package/pages/learn/[slug]/index.vue +341 -0
- package/pages/learn/create.vue +71 -0
- package/pages/learn/index.vue +360 -0
- package/pages/messages/[conversationId].vue +113 -0
- package/pages/messages/index.vue +303 -0
- package/pages/mirror/[id].vue +115 -0
- package/pages/notifications.vue +91 -0
- package/pages/products/[slug].vue +128 -0
- package/pages/products/index.vue +122 -0
- package/pages/search.vue +692 -0
- package/pages/settings/account.vue +170 -0
- package/pages/settings/appearance.vue +80 -0
- package/pages/settings/index.vue +81 -0
- package/pages/settings/notifications.vue +68 -0
- package/pages/settings/profile.vue +838 -0
- package/pages/tags/[slug].vue +111 -0
- package/pages/tags/index.vue +73 -0
- package/pages/u/[username]/followers.vue +86 -0
- package/pages/u/[username]/following.vue +94 -0
- package/pages/u/[username]/index.vue +837 -0
- package/pages/videos/[id].vue +212 -0
- package/pages/videos/index.vue +327 -0
- package/pages/videos/submit.vue +112 -0
- package/plugins/auth.ts +23 -0
- package/server/api/admin/audit.get.ts +17 -0
- package/server/api/admin/content/[id].delete.ts +15 -0
- package/server/api/admin/content/[id].patch.ts +37 -0
- package/server/api/admin/federation/activity.get.ts +31 -0
- package/server/api/admin/federation/clients.get.ts +9 -0
- package/server/api/admin/federation/clients.post.ts +16 -0
- package/server/api/admin/federation/hub-mirrors/index.get.ts +10 -0
- package/server/api/admin/federation/hub-mirrors/index.post.ts +42 -0
- package/server/api/admin/federation/mirrors/[id]/backfill.post.ts +39 -0
- package/server/api/admin/federation/mirrors/[id].delete.ts +11 -0
- package/server/api/admin/federation/mirrors/[id].get.ts +15 -0
- package/server/api/admin/federation/mirrors/[id].put.ts +22 -0
- package/server/api/admin/federation/mirrors/index.get.ts +9 -0
- package/server/api/admin/federation/mirrors/index.post.ts +30 -0
- package/server/api/admin/federation/pending.get.ts +22 -0
- package/server/api/admin/federation/refederate.post.ts +92 -0
- package/server/api/admin/federation/repair-types.post.ts +57 -0
- package/server/api/admin/federation/retry.post.ts +41 -0
- package/server/api/admin/federation/stats.get.ts +26 -0
- package/server/api/admin/reports/[id]/resolve.post.ts +12 -0
- package/server/api/admin/reports.get.ts +17 -0
- package/server/api/admin/settings.get.ts +22 -0
- package/server/api/admin/settings.put.ts +11 -0
- package/server/api/admin/stats.get.ts +9 -0
- package/server/api/admin/users/[id]/role.put.ts +12 -0
- package/server/api/admin/users/[id]/status.put.ts +12 -0
- package/server/api/admin/users/[id].delete.ts +10 -0
- package/server/api/admin/users.get.ts +18 -0
- package/server/api/auth/federated/callback.get.ts +67 -0
- package/server/api/auth/federated/login.post.ts +60 -0
- package/server/api/auth/oauth2/authorize.get.ts +30 -0
- package/server/api/auth/oauth2/authorize.post.ts +51 -0
- package/server/api/auth/oauth2/register.post.ts +41 -0
- package/server/api/auth/oauth2/token.post.ts +48 -0
- package/server/api/cert/[code].get.ts +13 -0
- package/server/api/content/[id]/build.post.ts +9 -0
- package/server/api/content/[id]/fork.post.ts +10 -0
- package/server/api/content/[id]/index.delete.ts +18 -0
- package/server/api/content/[id]/index.get.ts +15 -0
- package/server/api/content/[id]/index.put.ts +23 -0
- package/server/api/content/[id]/products/[productId].delete.ts +28 -0
- package/server/api/content/[id]/products-sync.post.ts +29 -0
- package/server/api/content/[id]/products.get.ts +9 -0
- package/server/api/content/[id]/products.post.ts +31 -0
- package/server/api/content/[id]/publish.post.ts +17 -0
- package/server/api/content/[id]/report.post.ts +17 -0
- package/server/api/content/[id]/versions.get.ts +9 -0
- package/server/api/content/[id]/view.post.ts +34 -0
- package/server/api/content/index.get.ts +23 -0
- package/server/api/content/index.post.ts +11 -0
- package/server/api/contests/[slug]/entries.get.ts +18 -0
- package/server/api/contests/[slug]/entries.post.ts +23 -0
- package/server/api/contests/[slug]/index.delete.ts +21 -0
- package/server/api/contests/[slug]/index.get.ts +11 -0
- package/server/api/contests/[slug]/index.put.ts +15 -0
- package/server/api/contests/[slug]/judge.post.ts +12 -0
- package/server/api/contests/[slug]/transition.post.ts +24 -0
- package/server/api/contests/index.get.ts +10 -0
- package/server/api/contests/index.post.ts +28 -0
- package/server/api/docs/[siteSlug]/index.delete.ts +14 -0
- package/server/api/docs/[siteSlug]/index.get.ts +17 -0
- package/server/api/docs/[siteSlug]/index.put.ts +20 -0
- package/server/api/docs/[siteSlug]/nav.get.ts +26 -0
- package/server/api/docs/[siteSlug]/pages/[pageId].delete.ts +14 -0
- package/server/api/docs/[siteSlug]/pages/[pageId].get.ts +31 -0
- package/server/api/docs/[siteSlug]/pages/[pageId].put.ts +15 -0
- package/server/api/docs/[siteSlug]/pages/index.get.ts +34 -0
- package/server/api/docs/[siteSlug]/pages/index.post.ts +28 -0
- package/server/api/docs/[siteSlug]/pages/reorder.post.ts +26 -0
- package/server/api/docs/[siteSlug]/search.get.ts +20 -0
- package/server/api/docs/[siteSlug]/versions.post.ts +11 -0
- package/server/api/docs/index.get.ts +6 -0
- package/server/api/docs/index.post.ts +10 -0
- package/server/api/federated-hubs/[id]/posts/[postId].get.ts +16 -0
- package/server/api/federated-hubs/[id]/posts.get.ts +15 -0
- package/server/api/federated-hubs/[id].get.ts +16 -0
- package/server/api/federation/boost.post.ts +21 -0
- package/server/api/federation/content/[id].get.ts +15 -0
- package/server/api/federation/follow.post.ts +16 -0
- package/server/api/federation/health.get.ts +56 -0
- package/server/api/federation/hub-follow.post.ts +27 -0
- package/server/api/federation/hub-post-like.post.ts +115 -0
- package/server/api/federation/hub-post-likes.get.ts +24 -0
- package/server/api/federation/hub-post-reply.post.ts +42 -0
- package/server/api/federation/hub-post.post.ts +33 -0
- package/server/api/federation/like.post.ts +21 -0
- package/server/api/federation/remote-actor.get.ts +22 -0
- package/server/api/federation/reply.post.ts +22 -0
- package/server/api/federation/search.post.ts +17 -0
- package/server/api/federation/timeline.get.ts +22 -0
- package/server/api/federation/unfollow.post.ts +17 -0
- package/server/api/files/[id].delete.ts +35 -0
- package/server/api/files/mine.get.ts +31 -0
- package/server/api/files/upload-from-url.post.ts +68 -0
- package/server/api/files/upload.post.ts +105 -0
- package/server/api/health.get.ts +4 -0
- package/server/api/hubs/[slug]/bans/[userId].delete.ts +13 -0
- package/server/api/hubs/[slug]/bans.get.ts +20 -0
- package/server/api/hubs/[slug]/bans.post.ts +23 -0
- package/server/api/hubs/[slug]/feed.xml.get.ts +60 -0
- package/server/api/hubs/[slug]/gallery.get.ts +21 -0
- package/server/api/hubs/[slug]/index.delete.ts +18 -0
- package/server/api/hubs/[slug]/index.get.ts +14 -0
- package/server/api/hubs/[slug]/index.put.ts +22 -0
- package/server/api/hubs/[slug]/invites.get.ts +20 -0
- package/server/api/hubs/[slug]/invites.post.ts +27 -0
- package/server/api/hubs/[slug]/join.post.ts +17 -0
- package/server/api/hubs/[slug]/leave.post.ts +13 -0
- package/server/api/hubs/[slug]/members/[userId].delete.ts +13 -0
- package/server/api/hubs/[slug]/members/[userId].put.ts +16 -0
- package/server/api/hubs/[slug]/members.get.ts +20 -0
- package/server/api/hubs/[slug]/posts/[postId]/like.post.ts +21 -0
- package/server/api/hubs/[slug]/posts/[postId]/lock.post.ts +17 -0
- package/server/api/hubs/[slug]/posts/[postId]/pin.post.ts +17 -0
- package/server/api/hubs/[slug]/posts/[postId]/replies.get.ts +16 -0
- package/server/api/hubs/[slug]/posts/[postId]/replies.post.ts +21 -0
- package/server/api/hubs/[slug]/posts/[postId].delete.ts +23 -0
- package/server/api/hubs/[slug]/posts/[postId].get.ts +16 -0
- package/server/api/hubs/[slug]/posts/index.get.ts +16 -0
- package/server/api/hubs/[slug]/posts/index.post.ts +36 -0
- package/server/api/hubs/[slug]/products.get.ts +26 -0
- package/server/api/hubs/[slug]/products.post.ts +18 -0
- package/server/api/hubs/[slug]/share.post.ts +39 -0
- package/server/api/hubs/index.get.ts +15 -0
- package/server/api/hubs/index.post.ts +11 -0
- package/server/api/image-proxy.get.ts +91 -0
- package/server/api/learn/[slug]/[lessonSlug]/complete.post.ts +13 -0
- package/server/api/learn/[slug]/[lessonSlug]/index.get.ts +68 -0
- package/server/api/learn/[slug]/enroll.post.ts +12 -0
- package/server/api/learn/[slug]/index.delete.ts +12 -0
- package/server/api/learn/[slug]/index.get.ts +14 -0
- package/server/api/learn/[slug]/index.put.ts +19 -0
- package/server/api/learn/[slug]/lessons/[lessonId].delete.ts +14 -0
- package/server/api/learn/[slug]/lessons/[lessonId].put.ts +24 -0
- package/server/api/learn/[slug]/lessons.post.ts +10 -0
- package/server/api/learn/[slug]/modules/[moduleId].delete.ts +14 -0
- package/server/api/learn/[slug]/modules/[moduleId].put.ts +15 -0
- package/server/api/learn/[slug]/modules.post.ts +14 -0
- package/server/api/learn/[slug]/publish.post.ts +13 -0
- package/server/api/learn/[slug]/unenroll.post.ts +12 -0
- package/server/api/learn/certificates.get.ts +9 -0
- package/server/api/learn/enrollments.get.ts +9 -0
- package/server/api/learn/index.get.ts +17 -0
- package/server/api/learn/index.post.ts +11 -0
- package/server/api/me.get.ts +13 -0
- package/server/api/messages/[conversationId]/info.get.ts +43 -0
- package/server/api/messages/[conversationId]/stream.get.ts +73 -0
- package/server/api/messages/[conversationId].get.ts +13 -0
- package/server/api/messages/[conversationId].post.ts +12 -0
- package/server/api/messages/index.get.ts +39 -0
- package/server/api/messages/index.post.ts +58 -0
- package/server/api/notifications/[id].delete.ts +11 -0
- package/server/api/notifications/count.get.ts +10 -0
- package/server/api/notifications/index.get.ts +24 -0
- package/server/api/notifications/read.post.ts +15 -0
- package/server/api/notifications/stream.get.ts +59 -0
- package/server/api/openapi.get.ts +5 -0
- package/server/api/products/[id].delete.ts +15 -0
- package/server/api/products/[id].put.ts +18 -0
- package/server/api/products/[slug]/content.get.ts +21 -0
- package/server/api/products/[slug].get.ts +16 -0
- package/server/api/products/index.get.ts +28 -0
- package/server/api/profile.get.ts +15 -0
- package/server/api/profile.put.ts +24 -0
- package/server/api/resolve-identity.post.ts +34 -0
- package/server/api/search/index.get.ts +24 -0
- package/server/api/search/trending.get.ts +22 -0
- package/server/api/social/bookmark.get.ts +16 -0
- package/server/api/social/bookmark.post.ts +15 -0
- package/server/api/social/bookmarks.get.ts +16 -0
- package/server/api/social/comments/[id].delete.ts +13 -0
- package/server/api/social/comments.get.ts +18 -0
- package/server/api/social/comments.post.ts +11 -0
- package/server/api/social/like.get.ts +17 -0
- package/server/api/social/like.post.ts +35 -0
- package/server/api/stats.get.ts +8 -0
- package/server/api/user/hubs.get.ts +22 -0
- package/server/api/users/[username]/content.get.ts +21 -0
- package/server/api/users/[username]/feed.xml.get.ts +65 -0
- package/server/api/users/[username]/follow.delete.ts +15 -0
- package/server/api/users/[username]/follow.post.ts +15 -0
- package/server/api/users/[username]/followers.get.ts +22 -0
- package/server/api/users/[username]/following.get.ts +22 -0
- package/server/api/users/[username]/learning.get.ts +18 -0
- package/server/api/users/[username].get.ts +25 -0
- package/server/api/users/index.get.ts +78 -0
- package/server/api/videos/[id].get.ts +18 -0
- package/server/api/videos/categories/[id].delete.ts +15 -0
- package/server/api/videos/categories/[id].put.ts +17 -0
- package/server/api/videos/categories.get.ts +7 -0
- package/server/api/videos/categories.post.ts +11 -0
- package/server/api/videos/index.get.ts +20 -0
- package/server/api/videos/index.post.ts +11 -0
- package/server/middleware/auth.ts +180 -0
- package/server/middleware/features.ts +31 -0
- package/server/middleware/security.ts +54 -0
- package/server/plugins/auto-admin.ts +69 -0
- package/server/plugins/federation-delivery.ts +74 -0
- package/server/routes/.well-known/nodeinfo.ts +15 -0
- package/server/routes/.well-known/webfinger.ts +86 -0
- package/server/routes/actor/followers.ts +34 -0
- package/server/routes/actor/following.ts +34 -0
- package/server/routes/actor/outbox.ts +31 -0
- package/server/routes/actor.ts +30 -0
- package/server/routes/feed.xml.ts +59 -0
- package/server/routes/hubs/[slug]/followers.ts +39 -0
- package/server/routes/hubs/[slug]/inbox.ts +35 -0
- package/server/routes/hubs/[slug]/outbox.ts +43 -0
- package/server/routes/hubs/[slug]/posts/[postId].ts +63 -0
- package/server/routes/hubs/[slug].ts +29 -0
- package/server/routes/inbox.ts +34 -0
- package/server/routes/nodeinfo/2.1.ts +27 -0
- package/server/routes/robots.txt.ts +19 -0
- package/server/routes/sitemap.xml.ts +105 -0
- package/server/routes/users/[username]/followers.ts +33 -0
- package/server/routes/users/[username]/following.ts +33 -0
- package/server/routes/users/[username]/inbox.ts +34 -0
- package/server/routes/users/[username]/outbox.ts +35 -0
- package/server/routes/users/[username].ts +62 -0
- package/server/utils/auth.ts +36 -0
- package/server/utils/db.ts +34 -0
- package/server/utils/errors.ts +24 -0
- package/server/utils/inbox.ts +122 -0
- package/server/utils/validate.ts +82 -0
- package/theme/base.css +283 -0
- package/theme/components.css +322 -0
- package/theme/dark.css +87 -0
- package/theme/editor-panels.css +63 -0
- package/theme/forms.css +216 -0
- package/theme/generics.css +68 -0
- package/theme/layouts.css +415 -0
- package/theme/prose.css +342 -0
- package/types/hub.ts +61 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
defineProps<{
|
|
3
|
+
video: {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
thumbnailUrl?: string | null;
|
|
7
|
+
duration?: number | null;
|
|
8
|
+
viewCount: number;
|
|
9
|
+
authorId: string;
|
|
10
|
+
author?: {
|
|
11
|
+
username: string;
|
|
12
|
+
displayName: string | null;
|
|
13
|
+
avatarUrl: string | null;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
}>();
|
|
17
|
+
|
|
18
|
+
function formatDuration(seconds: number | null | undefined): string {
|
|
19
|
+
if (!seconds) return '';
|
|
20
|
+
const m = Math.floor(seconds / 60);
|
|
21
|
+
const s = seconds % 60;
|
|
22
|
+
return `${m}:${String(s).padStart(2, '0')}`;
|
|
23
|
+
}
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<div class="cpub-video-card cpub-card">
|
|
28
|
+
<div class="cpub-video-thumb">
|
|
29
|
+
<img v-if="video.thumbnailUrl" :src="video.thumbnailUrl" :alt="video.title" loading="lazy" />
|
|
30
|
+
<div v-else class="cpub-video-thumb-placeholder">
|
|
31
|
+
<i class="fa-solid fa-play"></i>
|
|
32
|
+
</div>
|
|
33
|
+
<span v-if="video.duration" class="cpub-video-duration">{{ formatDuration(video.duration) }}</span>
|
|
34
|
+
</div>
|
|
35
|
+
<div class="cpub-card-body">
|
|
36
|
+
<h3 class="cpub-video-title">{{ video.title }}</h3>
|
|
37
|
+
<div v-if="video.author" class="cpub-video-author-row">
|
|
38
|
+
<div class="cpub-video-av">
|
|
39
|
+
<img v-if="video.author.avatarUrl" :src="video.author.avatarUrl" :alt="video.author.displayName || video.author.username" class="cpub-video-av-img" />
|
|
40
|
+
<span v-else>{{ (video.author.displayName || video.author.username || '?').charAt(0).toUpperCase() }}</span>
|
|
41
|
+
</div>
|
|
42
|
+
<span class="cpub-video-author-name">{{ video.author.displayName || video.author.username }}</span>
|
|
43
|
+
</div>
|
|
44
|
+
<div class="cpub-video-meta">
|
|
45
|
+
<span><i class="fa-solid fa-eye"></i> {{ video.viewCount }}</span>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<style scoped>
|
|
52
|
+
.cpub-video-thumb {
|
|
53
|
+
position: relative;
|
|
54
|
+
height: 140px;
|
|
55
|
+
background: var(--surface2);
|
|
56
|
+
border-bottom: var(--border-width-default) solid var(--border);
|
|
57
|
+
overflow: hidden;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.cpub-video-thumb img {
|
|
61
|
+
width: 100%;
|
|
62
|
+
height: 100%;
|
|
63
|
+
object-fit: cover;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.cpub-video-thumb-placeholder {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
height: 100%;
|
|
71
|
+
font-size: 24px;
|
|
72
|
+
color: var(--text-faint);
|
|
73
|
+
opacity: 0.3;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.cpub-video-duration {
|
|
77
|
+
position: absolute;
|
|
78
|
+
bottom: 6px;
|
|
79
|
+
right: 6px;
|
|
80
|
+
background: var(--color-surface-overlay);
|
|
81
|
+
color: var(--color-text-inverse);
|
|
82
|
+
font-size: 10px;
|
|
83
|
+
font-family: var(--font-mono);
|
|
84
|
+
padding: 2px 6px;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.cpub-video-title {
|
|
88
|
+
font-size: 13px;
|
|
89
|
+
font-weight: 600;
|
|
90
|
+
margin-bottom: 4px;
|
|
91
|
+
line-height: 1.35;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.cpub-video-author-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
|
|
95
|
+
.cpub-video-av { width: 18px; height: 18px; border-radius: 50%; background: var(--surface2); border: var(--border-width-default) solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 7px; font-family: var(--font-mono); color: var(--text-faint); flex-shrink: 0; overflow: hidden; }
|
|
96
|
+
.cpub-video-av-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
|
|
97
|
+
.cpub-video-author-name { font-size: 11px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
98
|
+
|
|
99
|
+
.cpub-video-meta {
|
|
100
|
+
font-size: 10px;
|
|
101
|
+
color: var(--text-faint);
|
|
102
|
+
font-family: var(--font-mono);
|
|
103
|
+
display: flex;
|
|
104
|
+
gap: 8px;
|
|
105
|
+
}
|
|
106
|
+
</style>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
content: Record<string, unknown>;
|
|
4
|
+
stepNumber?: number;
|
|
5
|
+
}>();
|
|
6
|
+
|
|
7
|
+
const title = computed(() => (props.content.title as string) || `Step ${props.stepNumber ?? 1}`);
|
|
8
|
+
const instructions = computed(() => (props.content.instructions as string) || '');
|
|
9
|
+
const time = computed(() => (props.content.time as string) || '');
|
|
10
|
+
const image = computed(() => (props.content.image as string) || '');
|
|
11
|
+
const num = computed(() => props.stepNumber ?? (props.content.stepNumber as number) ?? 1);
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<div class="cpub-block-step">
|
|
16
|
+
<div class="cpub-step-header">
|
|
17
|
+
<span class="cpub-step-num">{{ num }}</span>
|
|
18
|
+
<h3 class="cpub-step-title">{{ title }}</h3>
|
|
19
|
+
<span v-if="time" class="cpub-step-time"><i class="fa-regular fa-clock"></i> {{ time }}</span>
|
|
20
|
+
</div>
|
|
21
|
+
<div class="cpub-step-body">
|
|
22
|
+
<p v-if="instructions">{{ instructions }}</p>
|
|
23
|
+
<img v-if="image" :src="image" :alt="`Step ${num}`" class="cpub-step-img" loading="lazy" />
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<style scoped>
|
|
29
|
+
.cpub-block-step {
|
|
30
|
+
border: var(--border-width-default) solid var(--border);
|
|
31
|
+
overflow: hidden;
|
|
32
|
+
margin: 20px 0;
|
|
33
|
+
box-shadow: var(--shadow-md);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.cpub-step-header {
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
gap: 10px;
|
|
40
|
+
padding: 12px 16px;
|
|
41
|
+
background: var(--border);
|
|
42
|
+
color: var(--surface);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.cpub-step-num {
|
|
46
|
+
width: 28px;
|
|
47
|
+
height: 28px;
|
|
48
|
+
background: var(--accent);
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
|
+
justify-content: center;
|
|
52
|
+
font-family: var(--font-mono);
|
|
53
|
+
font-size: 13px;
|
|
54
|
+
font-weight: 700;
|
|
55
|
+
flex-shrink: 0;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.cpub-step-title {
|
|
59
|
+
font-size: 14px;
|
|
60
|
+
font-weight: 600;
|
|
61
|
+
flex: 1;
|
|
62
|
+
margin: 0;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.cpub-step-time {
|
|
66
|
+
font-family: var(--font-mono);
|
|
67
|
+
font-size: 11px;
|
|
68
|
+
opacity: 0.7;
|
|
69
|
+
display: flex;
|
|
70
|
+
align-items: center;
|
|
71
|
+
gap: 4px;
|
|
72
|
+
flex-shrink: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.cpub-step-body {
|
|
76
|
+
padding: 16px;
|
|
77
|
+
font-size: 13px;
|
|
78
|
+
line-height: 1.7;
|
|
79
|
+
color: var(--text-dim);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.cpub-step-body p { margin: 0 0 12px; }
|
|
83
|
+
.cpub-step-body p:last-child { margin-bottom: 0; }
|
|
84
|
+
|
|
85
|
+
.cpub-step-img {
|
|
86
|
+
width: 100%;
|
|
87
|
+
max-height: 400px;
|
|
88
|
+
object-fit: cover;
|
|
89
|
+
border: var(--border-width-default) solid var(--border);
|
|
90
|
+
margin-top: 12px;
|
|
91
|
+
}
|
|
92
|
+
</style>
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { sanitizeBlockHtml } from '../../composables/useSanitize';
|
|
3
|
+
|
|
4
|
+
const props = defineProps<{ content: Record<string, unknown> }>();
|
|
5
|
+
|
|
6
|
+
const html = computed(() => sanitizeBlockHtml((props.content.html as string) || ''));
|
|
7
|
+
const variant = computed(() => (props.content.variant as string) || 'info');
|
|
8
|
+
|
|
9
|
+
const variantConfig: Record<string, { icon: string; label: string }> = {
|
|
10
|
+
info: { icon: 'fa-circle-info', label: 'Info' },
|
|
11
|
+
tip: { icon: 'fa-lightbulb', label: 'Tip' },
|
|
12
|
+
warning: { icon: 'fa-triangle-exclamation', label: 'Warning' },
|
|
13
|
+
danger: { icon: 'fa-circle-exclamation', label: 'Danger' },
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const config = computed(() => variantConfig[variant.value] ?? variantConfig.info!);
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<template>
|
|
20
|
+
<div class="cpub-block-callout" :class="`cpub-callout--${variant}`">
|
|
21
|
+
<div class="cpub-callout-icon">
|
|
22
|
+
<i :class="['fa-solid', config.icon]"></i>
|
|
23
|
+
</div>
|
|
24
|
+
<div class="cpub-callout-body">
|
|
25
|
+
<div class="cpub-callout-label">{{ config.label }}</div>
|
|
26
|
+
<div class="cpub-callout-text" v-html="html" />
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<style scoped>
|
|
32
|
+
.cpub-block-callout {
|
|
33
|
+
display: flex;
|
|
34
|
+
gap: 12px;
|
|
35
|
+
padding: 16px 18px;
|
|
36
|
+
margin: 20px 0;
|
|
37
|
+
border: var(--border-width-default) solid var(--border);
|
|
38
|
+
border-left-width: 5px;
|
|
39
|
+
box-shadow: var(--shadow-md);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.cpub-callout--info { border-left-color: var(--accent); background: var(--accent-bg); }
|
|
43
|
+
.cpub-callout--tip { border-left-color: var(--green); background: var(--green-bg); }
|
|
44
|
+
.cpub-callout--warning { border-left-color: var(--yellow); background: var(--yellow-bg); }
|
|
45
|
+
.cpub-callout--danger { border-left-color: var(--red); background: var(--red-bg); }
|
|
46
|
+
|
|
47
|
+
.cpub-callout-icon {
|
|
48
|
+
font-size: 14px;
|
|
49
|
+
margin-top: 2px;
|
|
50
|
+
flex-shrink: 0;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.cpub-callout--info .cpub-callout-icon { color: var(--accent); }
|
|
54
|
+
.cpub-callout--tip .cpub-callout-icon { color: var(--green); }
|
|
55
|
+
.cpub-callout--warning .cpub-callout-icon { color: var(--yellow); }
|
|
56
|
+
.cpub-callout--danger .cpub-callout-icon { color: var(--red); }
|
|
57
|
+
|
|
58
|
+
.cpub-callout-body { flex: 1; min-width: 0; }
|
|
59
|
+
|
|
60
|
+
.cpub-callout-label {
|
|
61
|
+
font-family: var(--font-mono);
|
|
62
|
+
font-size: 10px;
|
|
63
|
+
font-weight: 700;
|
|
64
|
+
text-transform: uppercase;
|
|
65
|
+
letter-spacing: 0.1em;
|
|
66
|
+
margin-bottom: 4px;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.cpub-callout--info .cpub-callout-label { color: var(--accent); }
|
|
70
|
+
.cpub-callout--tip .cpub-callout-label { color: var(--green); }
|
|
71
|
+
.cpub-callout--warning .cpub-callout-label { color: var(--yellow); }
|
|
72
|
+
.cpub-callout--danger .cpub-callout-label { color: var(--red); }
|
|
73
|
+
|
|
74
|
+
.cpub-callout-text {
|
|
75
|
+
font-size: 14px;
|
|
76
|
+
line-height: 1.65;
|
|
77
|
+
color: var(--text-dim);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.cpub-callout-text :deep(strong) { color: var(--text); }
|
|
81
|
+
.cpub-callout-text :deep(p) { margin: 0; }
|
|
82
|
+
</style>
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps<{ content: Record<string, unknown> }>();
|
|
3
|
+
const emit = defineEmits<{ reached: [] }>();
|
|
4
|
+
|
|
5
|
+
const label = computed(() => (props.content.label as string) || 'Checkpoint reached');
|
|
6
|
+
const completed = ref(false);
|
|
7
|
+
|
|
8
|
+
function markComplete(): void {
|
|
9
|
+
if (completed.value) return;
|
|
10
|
+
completed.value = true;
|
|
11
|
+
emit('reached');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
onMounted(() => {
|
|
15
|
+
// Auto-trigger when scrolled into view
|
|
16
|
+
markComplete();
|
|
17
|
+
});
|
|
18
|
+
</script>
|
|
19
|
+
|
|
20
|
+
<template>
|
|
21
|
+
<div class="cpub-block-checkpoint" :class="{ visible: completed }">
|
|
22
|
+
<i class="fa-solid fa-circle-check"></i>
|
|
23
|
+
<span class="cpub-checkpoint-text">{{ label }}</span>
|
|
24
|
+
</div>
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<style scoped>
|
|
28
|
+
.cpub-block-checkpoint {
|
|
29
|
+
display: flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
gap: 10px;
|
|
32
|
+
padding: 12px 16px;
|
|
33
|
+
background: var(--green-bg);
|
|
34
|
+
border: var(--border-width-default) solid var(--green);
|
|
35
|
+
margin: 24px 0;
|
|
36
|
+
font-size: 13px;
|
|
37
|
+
color: var(--green);
|
|
38
|
+
opacity: 0;
|
|
39
|
+
transform: translateY(8px);
|
|
40
|
+
transition: opacity 0.4s ease, transform 0.4s ease;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.cpub-block-checkpoint.visible {
|
|
44
|
+
opacity: 1;
|
|
45
|
+
transform: translateY(0);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.cpub-block-checkpoint i { font-size: 14px; }
|
|
49
|
+
.cpub-checkpoint-text { font-weight: 600; }
|
|
50
|
+
</style>
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import hljs from 'highlight.js/lib/core';
|
|
3
|
+
|
|
4
|
+
import javascript from 'highlight.js/lib/languages/javascript';
|
|
5
|
+
import typescript from 'highlight.js/lib/languages/typescript';
|
|
6
|
+
import python from 'highlight.js/lib/languages/python';
|
|
7
|
+
import bash from 'highlight.js/lib/languages/bash';
|
|
8
|
+
import css from 'highlight.js/lib/languages/css';
|
|
9
|
+
import scss from 'highlight.js/lib/languages/scss';
|
|
10
|
+
import json from 'highlight.js/lib/languages/json';
|
|
11
|
+
import yaml from 'highlight.js/lib/languages/yaml';
|
|
12
|
+
import xml from 'highlight.js/lib/languages/xml';
|
|
13
|
+
import sql from 'highlight.js/lib/languages/sql';
|
|
14
|
+
import rust from 'highlight.js/lib/languages/rust';
|
|
15
|
+
import go from 'highlight.js/lib/languages/go';
|
|
16
|
+
import java from 'highlight.js/lib/languages/java';
|
|
17
|
+
import cpp from 'highlight.js/lib/languages/cpp';
|
|
18
|
+
import csharp from 'highlight.js/lib/languages/csharp';
|
|
19
|
+
import ruby from 'highlight.js/lib/languages/ruby';
|
|
20
|
+
import php from 'highlight.js/lib/languages/php';
|
|
21
|
+
import swift from 'highlight.js/lib/languages/swift';
|
|
22
|
+
import kotlin from 'highlight.js/lib/languages/kotlin';
|
|
23
|
+
import markdown from 'highlight.js/lib/languages/markdown';
|
|
24
|
+
import dockerfile from 'highlight.js/lib/languages/dockerfile';
|
|
25
|
+
import graphql from 'highlight.js/lib/languages/graphql';
|
|
26
|
+
import ini from 'highlight.js/lib/languages/ini';
|
|
27
|
+
|
|
28
|
+
hljs.registerLanguage('javascript', javascript);
|
|
29
|
+
hljs.registerLanguage('js', javascript);
|
|
30
|
+
hljs.registerLanguage('typescript', typescript);
|
|
31
|
+
hljs.registerLanguage('ts', typescript);
|
|
32
|
+
hljs.registerLanguage('python', python);
|
|
33
|
+
hljs.registerLanguage('bash', bash);
|
|
34
|
+
hljs.registerLanguage('shell', bash);
|
|
35
|
+
hljs.registerLanguage('sh', bash);
|
|
36
|
+
hljs.registerLanguage('css', css);
|
|
37
|
+
hljs.registerLanguage('scss', scss);
|
|
38
|
+
hljs.registerLanguage('json', json);
|
|
39
|
+
hljs.registerLanguage('yaml', yaml);
|
|
40
|
+
hljs.registerLanguage('yml', yaml);
|
|
41
|
+
hljs.registerLanguage('xml', xml);
|
|
42
|
+
hljs.registerLanguage('html', xml);
|
|
43
|
+
hljs.registerLanguage('vue', xml);
|
|
44
|
+
hljs.registerLanguage('svelte', xml);
|
|
45
|
+
hljs.registerLanguage('sql', sql);
|
|
46
|
+
hljs.registerLanguage('rust', rust);
|
|
47
|
+
hljs.registerLanguage('go', go);
|
|
48
|
+
hljs.registerLanguage('java', java);
|
|
49
|
+
hljs.registerLanguage('cpp', cpp);
|
|
50
|
+
hljs.registerLanguage('c', cpp);
|
|
51
|
+
hljs.registerLanguage('csharp', csharp);
|
|
52
|
+
hljs.registerLanguage('ruby', ruby);
|
|
53
|
+
hljs.registerLanguage('php', php);
|
|
54
|
+
hljs.registerLanguage('swift', swift);
|
|
55
|
+
hljs.registerLanguage('kotlin', kotlin);
|
|
56
|
+
hljs.registerLanguage('markdown', markdown);
|
|
57
|
+
hljs.registerLanguage('md', markdown);
|
|
58
|
+
hljs.registerLanguage('dockerfile', dockerfile);
|
|
59
|
+
hljs.registerLanguage('docker', dockerfile);
|
|
60
|
+
hljs.registerLanguage('graphql', graphql);
|
|
61
|
+
hljs.registerLanguage('toml', ini);
|
|
62
|
+
hljs.registerLanguage('ini', ini);
|
|
63
|
+
|
|
64
|
+
const props = defineProps<{ content: Record<string, unknown> }>();
|
|
65
|
+
|
|
66
|
+
const language = computed(() => (props.content.language as string) || '');
|
|
67
|
+
const filename = computed(() => (props.content.filename as string) || '');
|
|
68
|
+
const code = computed(() => (props.content.code as string) || '');
|
|
69
|
+
|
|
70
|
+
const highlightedHtml = computed(() => {
|
|
71
|
+
if (!code.value) return '';
|
|
72
|
+
try {
|
|
73
|
+
const lang = language.value.toLowerCase();
|
|
74
|
+
if (lang && hljs.getLanguage(lang)) {
|
|
75
|
+
return hljs.highlight(code.value, { language: lang }).value;
|
|
76
|
+
}
|
|
77
|
+
return hljs.highlightAuto(code.value).value;
|
|
78
|
+
} catch {
|
|
79
|
+
return '';
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
const copied = ref(false);
|
|
84
|
+
|
|
85
|
+
async function copyCode(): Promise<void> {
|
|
86
|
+
try {
|
|
87
|
+
await navigator.clipboard.writeText(code.value);
|
|
88
|
+
copied.value = true;
|
|
89
|
+
setTimeout(() => { copied.value = false; }, 1500);
|
|
90
|
+
} catch { /* clipboard API not available */ }
|
|
91
|
+
}
|
|
92
|
+
</script>
|
|
93
|
+
|
|
94
|
+
<template>
|
|
95
|
+
<div class="cpub-block-code">
|
|
96
|
+
<div class="cpub-code-header">
|
|
97
|
+
<span v-if="language" class="cpub-code-lang">{{ language }}</span>
|
|
98
|
+
<span v-if="filename" class="cpub-code-filename">{{ filename }}</span>
|
|
99
|
+
<button class="cpub-code-copy" @click="copyCode">
|
|
100
|
+
<i :class="copied ? 'fa-solid fa-check' : 'fa-regular fa-copy'"></i>
|
|
101
|
+
{{ copied ? 'Copied' : 'Copy' }}
|
|
102
|
+
</button>
|
|
103
|
+
</div>
|
|
104
|
+
<pre class="cpub-code-body hljs"><code v-if="highlightedHtml" v-html="highlightedHtml" /><code v-else>{{ code }}</code></pre>
|
|
105
|
+
</div>
|
|
106
|
+
</template>
|
|
107
|
+
|
|
108
|
+
<style>
|
|
109
|
+
/* highlight.js github-dark theme — MUST be unscoped so hljs classes apply to v-html content */
|
|
110
|
+
pre.hljs {
|
|
111
|
+
background: #0d1117;
|
|
112
|
+
color: #e6edf3;
|
|
113
|
+
}
|
|
114
|
+
pre.hljs .hljs-comment,
|
|
115
|
+
pre.hljs .hljs-quote { color: #8b949e; font-style: italic; }
|
|
116
|
+
pre.hljs .hljs-keyword,
|
|
117
|
+
pre.hljs .hljs-selector-tag,
|
|
118
|
+
pre.hljs .hljs-type { color: #ff7b72; }
|
|
119
|
+
pre.hljs .hljs-literal,
|
|
120
|
+
pre.hljs .hljs-number,
|
|
121
|
+
pre.hljs .hljs-tag .hljs-attr { color: #79c0ff; }
|
|
122
|
+
pre.hljs .hljs-string,
|
|
123
|
+
pre.hljs .hljs-addition { color: #a5d6ff; }
|
|
124
|
+
pre.hljs .hljs-deletion { color: #ffa198; }
|
|
125
|
+
pre.hljs .hljs-regexp,
|
|
126
|
+
pre.hljs .hljs-link { color: #a5d6ff; }
|
|
127
|
+
pre.hljs .hljs-meta { color: #d2a8ff; }
|
|
128
|
+
pre.hljs .hljs-title,
|
|
129
|
+
pre.hljs .hljs-section,
|
|
130
|
+
pre.hljs .hljs-built_in { color: #d2a8ff; }
|
|
131
|
+
pre.hljs .hljs-name,
|
|
132
|
+
pre.hljs .hljs-selector-id,
|
|
133
|
+
pre.hljs .hljs-selector-class { color: #7ee787; }
|
|
134
|
+
pre.hljs .hljs-variable,
|
|
135
|
+
pre.hljs .hljs-template-variable { color: #ffa657; }
|
|
136
|
+
pre.hljs .hljs-attribute { color: #79c0ff; }
|
|
137
|
+
pre.hljs .hljs-symbol,
|
|
138
|
+
pre.hljs .hljs-bullet { color: #ffa657; }
|
|
139
|
+
pre.hljs .hljs-subst { color: #e6edf3; }
|
|
140
|
+
pre.hljs .hljs-title.function_ { color: #d2a8ff; }
|
|
141
|
+
pre.hljs .hljs-title.class_ { color: #ffa657; }
|
|
142
|
+
</style>
|
|
143
|
+
|
|
144
|
+
<style scoped>
|
|
145
|
+
.cpub-block-code {
|
|
146
|
+
border: var(--border-width-default) solid var(--border);
|
|
147
|
+
overflow: hidden;
|
|
148
|
+
margin: 20px 0;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.cpub-code-header {
|
|
152
|
+
display: flex;
|
|
153
|
+
align-items: center;
|
|
154
|
+
gap: 8px;
|
|
155
|
+
padding: 8px 14px;
|
|
156
|
+
background: #161b22;
|
|
157
|
+
border-bottom: var(--border-width-default) solid var(--border);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.cpub-code-lang {
|
|
161
|
+
font-family: var(--font-mono);
|
|
162
|
+
font-size: 10px;
|
|
163
|
+
font-weight: 600;
|
|
164
|
+
text-transform: uppercase;
|
|
165
|
+
letter-spacing: 0.06em;
|
|
166
|
+
color: #7ee787;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.cpub-code-filename {
|
|
170
|
+
font-family: var(--font-mono);
|
|
171
|
+
font-size: 10px;
|
|
172
|
+
color: #8b949e;
|
|
173
|
+
flex: 1;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.cpub-code-copy {
|
|
177
|
+
font-family: var(--font-mono);
|
|
178
|
+
font-size: 10px;
|
|
179
|
+
color: #8b949e;
|
|
180
|
+
background: transparent;
|
|
181
|
+
border: var(--border-width-default) solid #30363d;
|
|
182
|
+
padding: 3px 8px;
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
display: flex;
|
|
185
|
+
align-items: center;
|
|
186
|
+
gap: 4px;
|
|
187
|
+
flex-shrink: 0;
|
|
188
|
+
margin-left: auto;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.cpub-code-copy:hover {
|
|
192
|
+
color: #e6edf3;
|
|
193
|
+
border-color: #8b949e;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.cpub-code-body {
|
|
197
|
+
margin: 0;
|
|
198
|
+
padding: 16px;
|
|
199
|
+
font-family: var(--font-mono);
|
|
200
|
+
font-size: 13px;
|
|
201
|
+
line-height: 1.6;
|
|
202
|
+
overflow-x: auto;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.cpub-code-body code {
|
|
206
|
+
font-family: inherit;
|
|
207
|
+
background: none !important;
|
|
208
|
+
border: none !important;
|
|
209
|
+
padding: 0 !important;
|
|
210
|
+
color: inherit;
|
|
211
|
+
}
|
|
212
|
+
</style>
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
/**
|
|
3
|
+
* BlockContentRenderer — renders BlockTuple[] as pure Vue components.
|
|
4
|
+
* Replaces CpubEditor in read-only mode so interactive blocks (quiz, slider)
|
|
5
|
+
* render fully instead of as TipTap placeholders.
|
|
6
|
+
*/
|
|
7
|
+
import type { Component } from 'vue';
|
|
8
|
+
import { sanitizeBlockHtml } from '../../composables/useSanitize';
|
|
9
|
+
import BlockTextView from './BlockTextView.vue';
|
|
10
|
+
import BlockHeadingView from './BlockHeadingView.vue';
|
|
11
|
+
import BlockCodeView from './BlockCodeView.vue';
|
|
12
|
+
import BlockImageView from './BlockImageView.vue';
|
|
13
|
+
import BlockQuoteView from './BlockQuoteView.vue';
|
|
14
|
+
import BlockCalloutView from './BlockCalloutView.vue';
|
|
15
|
+
import BlockDividerView from './BlockDividerView.vue';
|
|
16
|
+
import BlockVideoView from './BlockVideoView.vue';
|
|
17
|
+
import BlockEmbedView from './BlockEmbedView.vue';
|
|
18
|
+
import BlockPartsListView from './BlockPartsListView.vue';
|
|
19
|
+
import BlockBuildStepView from './BlockBuildStepView.vue';
|
|
20
|
+
import BlockToolListView from './BlockToolListView.vue';
|
|
21
|
+
import BlockDownloadsView from './BlockDownloadsView.vue';
|
|
22
|
+
import BlockQuizView from './BlockQuizView.vue';
|
|
23
|
+
import BlockSliderView from './BlockSliderView.vue';
|
|
24
|
+
import BlockCheckpointView from './BlockCheckpointView.vue';
|
|
25
|
+
import BlockMathView from './BlockMathView.vue';
|
|
26
|
+
import BlockGalleryView from './BlockGalleryView.vue';
|
|
27
|
+
import BlockSectionHeaderView from './BlockSectionHeaderView.vue';
|
|
28
|
+
import BlockMarkdownView from './BlockMarkdownView.vue';
|
|
29
|
+
import type { BlockTuple } from '@commonpub/editor';
|
|
30
|
+
|
|
31
|
+
const props = defineProps<{
|
|
32
|
+
blocks: BlockTuple[];
|
|
33
|
+
startIndex?: number;
|
|
34
|
+
endIndex?: number;
|
|
35
|
+
}>();
|
|
36
|
+
|
|
37
|
+
const emit = defineEmits<{
|
|
38
|
+
quizAnswered: [blockIndex: number, correct: boolean];
|
|
39
|
+
checkpointReached: [blockIndex: number];
|
|
40
|
+
}>();
|
|
41
|
+
|
|
42
|
+
const componentMap: Record<string, unknown> = {
|
|
43
|
+
text: BlockTextView,
|
|
44
|
+
paragraph: BlockTextView,
|
|
45
|
+
heading: BlockHeadingView,
|
|
46
|
+
code: BlockCodeView,
|
|
47
|
+
code_block: BlockCodeView,
|
|
48
|
+
codeBlock: BlockCodeView,
|
|
49
|
+
image: BlockImageView,
|
|
50
|
+
quote: BlockQuoteView,
|
|
51
|
+
blockquote: BlockQuoteView,
|
|
52
|
+
callout: BlockCalloutView,
|
|
53
|
+
divider: BlockDividerView,
|
|
54
|
+
horizontalRule: BlockDividerView,
|
|
55
|
+
video: BlockVideoView,
|
|
56
|
+
embed: BlockEmbedView,
|
|
57
|
+
partsList: BlockPartsListView,
|
|
58
|
+
buildStep: BlockBuildStepView,
|
|
59
|
+
toolList: BlockToolListView,
|
|
60
|
+
downloads: BlockDownloadsView,
|
|
61
|
+
quiz: BlockQuizView,
|
|
62
|
+
interactiveSlider: BlockSliderView,
|
|
63
|
+
slider: BlockSliderView,
|
|
64
|
+
checkpoint: BlockCheckpointView,
|
|
65
|
+
mathNotation: BlockMathView,
|
|
66
|
+
math: BlockMathView,
|
|
67
|
+
gallery: BlockGalleryView,
|
|
68
|
+
sectionHeader: BlockSectionHeaderView,
|
|
69
|
+
markdown: BlockMarkdownView,
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const visibleBlocks = computed(() => {
|
|
73
|
+
const start = props.startIndex ?? 0;
|
|
74
|
+
const end = props.endIndex ?? props.blocks.length;
|
|
75
|
+
return props.blocks.slice(start, end).map((block, i) => ({
|
|
76
|
+
type: block[0],
|
|
77
|
+
data: block[1],
|
|
78
|
+
index: start + i,
|
|
79
|
+
}));
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Track sequential build step numbers
|
|
83
|
+
const stepCounters = computed(() => {
|
|
84
|
+
const counters: Record<number, number> = {};
|
|
85
|
+
let stepNum = 0;
|
|
86
|
+
const start = props.startIndex ?? 0;
|
|
87
|
+
const end = props.endIndex ?? props.blocks.length;
|
|
88
|
+
for (let i = start; i < end; i++) {
|
|
89
|
+
if (props.blocks[i]![0] === 'buildStep') {
|
|
90
|
+
stepNum++;
|
|
91
|
+
counters[i] = stepNum;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return counters;
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
function resolveComponent(type: string): unknown {
|
|
98
|
+
return componentMap[type] ?? null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function onQuizAnswered(blockIndex: number, correct: boolean): void {
|
|
102
|
+
emit('quizAnswered', blockIndex, correct);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function onCheckpointReached(blockIndex: number): void {
|
|
106
|
+
emit('checkpointReached', blockIndex);
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<template>
|
|
111
|
+
<div class="cpub-block-renderer">
|
|
112
|
+
<template v-for="block in visibleBlocks" :key="block.index">
|
|
113
|
+
<component
|
|
114
|
+
:is="(resolveComponent(block.type) as Component)"
|
|
115
|
+
v-if="resolveComponent(block.type)"
|
|
116
|
+
:content="block.data"
|
|
117
|
+
:step-number="block.type === 'buildStep' ? stepCounters[block.index] : undefined"
|
|
118
|
+
@answered="(correct: boolean) => onQuizAnswered(block.index, correct)"
|
|
119
|
+
@reached="() => onCheckpointReached(block.index)"
|
|
120
|
+
/>
|
|
121
|
+
<!-- Fallback for unknown block types: render as text if html present -->
|
|
122
|
+
<div v-else-if="'html' in block.data && (block.data as Record<string, unknown>).html" class="cpub-block-fallback" v-html="sanitizeBlockHtml((block.data as Record<string, unknown>).html as string)" />
|
|
123
|
+
</template>
|
|
124
|
+
</div>
|
|
125
|
+
</template>
|
|
126
|
+
|
|
127
|
+
<style scoped>
|
|
128
|
+
.cpub-block-renderer {
|
|
129
|
+
display: flex;
|
|
130
|
+
flex-direction: column;
|
|
131
|
+
gap: 0;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.cpub-block-fallback {
|
|
135
|
+
font-size: 15px;
|
|
136
|
+
line-height: 1.75;
|
|
137
|
+
color: var(--text-dim);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.cpub-block-fallback :deep(p) {
|
|
141
|
+
margin-bottom: 14px;
|
|
142
|
+
}
|
|
143
|
+
</style>
|