@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,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable composable for content engagement actions (like, bookmark, share).
|
|
3
|
+
* Handles optimistic updates with rollback on API failure.
|
|
4
|
+
*/
|
|
5
|
+
export interface ContentViewData {
|
|
6
|
+
id: string;
|
|
7
|
+
type: string;
|
|
8
|
+
title: string;
|
|
9
|
+
slug: string;
|
|
10
|
+
subtitle: string | null;
|
|
11
|
+
description: string | null;
|
|
12
|
+
content: unknown;
|
|
13
|
+
coverImageUrl: string | null;
|
|
14
|
+
category: string | null;
|
|
15
|
+
difficulty: string | null;
|
|
16
|
+
buildTime: string | null;
|
|
17
|
+
estimatedCost: string | null;
|
|
18
|
+
status: string;
|
|
19
|
+
visibility: string;
|
|
20
|
+
isFeatured: boolean;
|
|
21
|
+
seoDescription: string | null;
|
|
22
|
+
previewToken: string | null;
|
|
23
|
+
parts: Array<{
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
quantity: number;
|
|
28
|
+
url?: string;
|
|
29
|
+
price?: number;
|
|
30
|
+
currency?: string;
|
|
31
|
+
category?: string;
|
|
32
|
+
required: boolean;
|
|
33
|
+
productId?: string;
|
|
34
|
+
}> | null;
|
|
35
|
+
sections: Array<{
|
|
36
|
+
id: string;
|
|
37
|
+
title: string;
|
|
38
|
+
anchor: string;
|
|
39
|
+
type: string;
|
|
40
|
+
content?: unknown;
|
|
41
|
+
}> | null;
|
|
42
|
+
viewCount: number;
|
|
43
|
+
likeCount: number;
|
|
44
|
+
commentCount: number;
|
|
45
|
+
forkCount: number;
|
|
46
|
+
publishedAt: string | null;
|
|
47
|
+
createdAt: string;
|
|
48
|
+
updatedAt: string;
|
|
49
|
+
licenseType: string | null;
|
|
50
|
+
series: string | null;
|
|
51
|
+
estimatedMinutes: number | null;
|
|
52
|
+
tags: Array<{ id: string; name: string; slug: string }>;
|
|
53
|
+
author: {
|
|
54
|
+
id: string;
|
|
55
|
+
username: string;
|
|
56
|
+
displayName: string | null;
|
|
57
|
+
avatarUrl: string | null;
|
|
58
|
+
bio?: string | null;
|
|
59
|
+
headline?: string | null;
|
|
60
|
+
verified?: boolean;
|
|
61
|
+
org?: string;
|
|
62
|
+
articleCount?: number;
|
|
63
|
+
followerCount?: number;
|
|
64
|
+
totalViews?: number;
|
|
65
|
+
postCount?: number;
|
|
66
|
+
};
|
|
67
|
+
// Optional fields that may come from enriched responses
|
|
68
|
+
readTime?: string;
|
|
69
|
+
buildCount?: number;
|
|
70
|
+
bookmarkCount?: number;
|
|
71
|
+
githubUrl?: string;
|
|
72
|
+
license?: string;
|
|
73
|
+
hardwarePrimary?: string;
|
|
74
|
+
hardwareSecondary?: string;
|
|
75
|
+
hardwareTertiary?: string;
|
|
76
|
+
community?: { name: string; slug: string; description: string | null };
|
|
77
|
+
related?: Array<{ id: string; type: string; slug: string; title: string; readTime?: string; viewCount?: number }>;
|
|
78
|
+
seriesPart?: number;
|
|
79
|
+
seriesTitle?: string;
|
|
80
|
+
seriesTotalParts?: number;
|
|
81
|
+
seriesPrev?: { title: string; url: string };
|
|
82
|
+
seriesNext?: { title: string; url: string };
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface EngagementOptions {
|
|
86
|
+
contentId: Ref<string | undefined>;
|
|
87
|
+
contentType: Ref<string>;
|
|
88
|
+
/** When set, likes federate to the remote instance instead of acting locally */
|
|
89
|
+
federatedContentId?: Ref<string | undefined>;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function useEngagement(opts: EngagementOptions) {
|
|
93
|
+
const { contentId, contentType, federatedContentId } = opts;
|
|
94
|
+
const liked = ref(false);
|
|
95
|
+
const bookmarked = ref(false);
|
|
96
|
+
const likeCount = ref(0);
|
|
97
|
+
|
|
98
|
+
const isFederated = computed(() => !!federatedContentId?.value);
|
|
99
|
+
|
|
100
|
+
function setInitialState(isLiked: boolean, isBookmarked: boolean, likes: number): void {
|
|
101
|
+
liked.value = isLiked;
|
|
102
|
+
bookmarked.value = isBookmarked;
|
|
103
|
+
likeCount.value = likes;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function toggleLike(): Promise<void> {
|
|
107
|
+
if (!contentId.value) return;
|
|
108
|
+
const prev = liked.value;
|
|
109
|
+
const prevCount = likeCount.value;
|
|
110
|
+
liked.value = !liked.value;
|
|
111
|
+
likeCount.value += liked.value ? 1 : -1;
|
|
112
|
+
|
|
113
|
+
try {
|
|
114
|
+
if (isFederated.value) {
|
|
115
|
+
await $fetch('/api/federation/like', {
|
|
116
|
+
method: 'POST',
|
|
117
|
+
body: { federatedContentId: federatedContentId!.value },
|
|
118
|
+
});
|
|
119
|
+
} else {
|
|
120
|
+
await $fetch('/api/social/like', {
|
|
121
|
+
method: 'POST',
|
|
122
|
+
body: { targetType: contentType.value, targetId: contentId.value },
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
} catch {
|
|
126
|
+
liked.value = prev;
|
|
127
|
+
likeCount.value = prevCount;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function toggleBookmark(): Promise<void> {
|
|
132
|
+
if (!contentId.value) return;
|
|
133
|
+
// Bookmarks are local-only — skip for federated content (no local record to target)
|
|
134
|
+
if (isFederated.value) return;
|
|
135
|
+
const prev = bookmarked.value;
|
|
136
|
+
bookmarked.value = !bookmarked.value;
|
|
137
|
+
|
|
138
|
+
try {
|
|
139
|
+
await $fetch('/api/social/bookmark', {
|
|
140
|
+
method: 'POST',
|
|
141
|
+
body: { targetType: contentType.value, targetId: contentId.value },
|
|
142
|
+
});
|
|
143
|
+
} catch {
|
|
144
|
+
bookmarked.value = prev;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async function share(): Promise<void> {
|
|
149
|
+
if (!contentId.value) return;
|
|
150
|
+
if (navigator.share) {
|
|
151
|
+
try {
|
|
152
|
+
await navigator.share({
|
|
153
|
+
url: window.location.href,
|
|
154
|
+
});
|
|
155
|
+
} catch {
|
|
156
|
+
// User cancelled or not supported
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
await navigator.clipboard.writeText(window.location.href);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Fetch actual liked/bookmarked state from server (call onMounted) */
|
|
164
|
+
async function fetchInitialState(likes: number): Promise<void> {
|
|
165
|
+
likeCount.value = likes;
|
|
166
|
+
if (!contentId.value) return;
|
|
167
|
+
// Skip state fetch for federated content — no local like/bookmark records
|
|
168
|
+
if (isFederated.value) return;
|
|
169
|
+
try {
|
|
170
|
+
const [likeRes, bmRes] = await Promise.all([
|
|
171
|
+
$fetch<{ liked: boolean }>('/api/social/like', {
|
|
172
|
+
params: { targetType: contentType.value, targetId: contentId.value },
|
|
173
|
+
}).catch(() => ({ liked: false })),
|
|
174
|
+
$fetch<{ bookmarked: boolean }>('/api/social/bookmark', {
|
|
175
|
+
params: { targetType: contentType.value, targetId: contentId.value },
|
|
176
|
+
}).catch(() => ({ bookmarked: false })),
|
|
177
|
+
]);
|
|
178
|
+
liked.value = likeRes.liked;
|
|
179
|
+
bookmarked.value = bmRes.bookmarked;
|
|
180
|
+
} catch {
|
|
181
|
+
// Non-critical — default to false
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
liked,
|
|
187
|
+
bookmarked,
|
|
188
|
+
likeCount,
|
|
189
|
+
isFederated,
|
|
190
|
+
setInitialState,
|
|
191
|
+
fetchInitialState,
|
|
192
|
+
toggleLike,
|
|
193
|
+
toggleBookmark,
|
|
194
|
+
share,
|
|
195
|
+
};
|
|
196
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Feature flag composable — reactive access to enabled features
|
|
2
|
+
|
|
3
|
+
export interface FeatureFlags {
|
|
4
|
+
content: boolean;
|
|
5
|
+
social: boolean;
|
|
6
|
+
hubs: boolean;
|
|
7
|
+
docs: boolean;
|
|
8
|
+
video: boolean;
|
|
9
|
+
contests: boolean;
|
|
10
|
+
learning: boolean;
|
|
11
|
+
explainers: boolean;
|
|
12
|
+
federation: boolean;
|
|
13
|
+
admin: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function useFeatures() {
|
|
17
|
+
const config = useRuntimeConfig();
|
|
18
|
+
const flags = config.public.features as FeatureFlags;
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
features: flags,
|
|
22
|
+
content: computed(() => flags.content),
|
|
23
|
+
social: computed(() => flags.social),
|
|
24
|
+
hubs: computed(() => flags.hubs),
|
|
25
|
+
docs: computed(() => flags.docs),
|
|
26
|
+
video: computed(() => flags.video),
|
|
27
|
+
contests: computed(() => flags.contests),
|
|
28
|
+
learning: computed(() => flags.learning),
|
|
29
|
+
explainers: computed(() => flags.explainers),
|
|
30
|
+
federation: computed(() => flags.federation),
|
|
31
|
+
admin: computed(() => flags.admin),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { RemoteActorProfile } from '@commonpub/server';
|
|
2
|
+
|
|
3
|
+
export function useFederation() {
|
|
4
|
+
const searchResult = ref<RemoteActorProfile | null>(null);
|
|
5
|
+
const searchLoading = ref(false);
|
|
6
|
+
const searchError = ref<string | null>(null);
|
|
7
|
+
|
|
8
|
+
async function searchRemoteUser(query: string): Promise<RemoteActorProfile | null> {
|
|
9
|
+
searchLoading.value = true;
|
|
10
|
+
searchError.value = null;
|
|
11
|
+
searchResult.value = null;
|
|
12
|
+
|
|
13
|
+
try {
|
|
14
|
+
const result = await $fetch<RemoteActorProfile | null>('/api/federation/search', {
|
|
15
|
+
method: 'POST',
|
|
16
|
+
body: { query },
|
|
17
|
+
});
|
|
18
|
+
searchResult.value = result;
|
|
19
|
+
return result;
|
|
20
|
+
} catch (err: unknown) {
|
|
21
|
+
const msg = err instanceof Error ? err.message : 'Search failed';
|
|
22
|
+
searchError.value = msg;
|
|
23
|
+
return null;
|
|
24
|
+
} finally {
|
|
25
|
+
searchLoading.value = false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function followRemoteUser(actorUri: string): Promise<boolean> {
|
|
30
|
+
try {
|
|
31
|
+
await $fetch('/api/federation/follow', {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
body: { actorUri },
|
|
34
|
+
});
|
|
35
|
+
// Update search result to reflect pending follow
|
|
36
|
+
if (searchResult.value && searchResult.value.actorUri === actorUri) {
|
|
37
|
+
searchResult.value = { ...searchResult.value, isFollowPending: true };
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
} catch {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function unfollowRemoteUser(actorUri: string): Promise<boolean> {
|
|
46
|
+
try {
|
|
47
|
+
await $fetch('/api/federation/unfollow', {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
body: { actorUri },
|
|
50
|
+
});
|
|
51
|
+
if (searchResult.value && searchResult.value.actorUri === actorUri) {
|
|
52
|
+
searchResult.value = {
|
|
53
|
+
...searchResult.value,
|
|
54
|
+
isFollowing: false,
|
|
55
|
+
isFollowPending: false,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
searchResult,
|
|
66
|
+
searchLoading,
|
|
67
|
+
searchError,
|
|
68
|
+
searchRemoteUser,
|
|
69
|
+
followRemoteUser,
|
|
70
|
+
unfollowRemoteUser,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
/** Composable for adding JSON-LD structured data to pages */
|
|
2
|
+
|
|
3
|
+
interface JsonLdArticle {
|
|
4
|
+
type: 'article';
|
|
5
|
+
title: string;
|
|
6
|
+
description: string;
|
|
7
|
+
url: string;
|
|
8
|
+
imageUrl?: string;
|
|
9
|
+
authorName: string;
|
|
10
|
+
authorUrl: string;
|
|
11
|
+
publishedAt: string;
|
|
12
|
+
updatedAt: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface JsonLdHowTo {
|
|
16
|
+
type: 'howto';
|
|
17
|
+
title: string;
|
|
18
|
+
description: string;
|
|
19
|
+
url: string;
|
|
20
|
+
imageUrl?: string;
|
|
21
|
+
authorName: string;
|
|
22
|
+
authorUrl: string;
|
|
23
|
+
difficulty?: string;
|
|
24
|
+
estimatedTime?: string;
|
|
25
|
+
estimatedCost?: string;
|
|
26
|
+
steps?: Array<{ name: string; text: string }>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface JsonLdCourse {
|
|
30
|
+
type: 'course';
|
|
31
|
+
title: string;
|
|
32
|
+
description: string;
|
|
33
|
+
url: string;
|
|
34
|
+
imageUrl?: string;
|
|
35
|
+
providerName: string;
|
|
36
|
+
providerUrl: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface JsonLdVideo {
|
|
40
|
+
type: 'video';
|
|
41
|
+
title: string;
|
|
42
|
+
description: string;
|
|
43
|
+
url: string;
|
|
44
|
+
thumbnailUrl?: string;
|
|
45
|
+
uploadDate: string;
|
|
46
|
+
duration?: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface JsonLdPerson {
|
|
50
|
+
type: 'person';
|
|
51
|
+
name: string;
|
|
52
|
+
url: string;
|
|
53
|
+
imageUrl?: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
jobTitle?: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
interface JsonLdOrganization {
|
|
59
|
+
type: 'organization';
|
|
60
|
+
name: string;
|
|
61
|
+
url: string;
|
|
62
|
+
logoUrl?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
type JsonLdInput =
|
|
67
|
+
| JsonLdArticle
|
|
68
|
+
| JsonLdHowTo
|
|
69
|
+
| JsonLdCourse
|
|
70
|
+
| JsonLdVideo
|
|
71
|
+
| JsonLdPerson
|
|
72
|
+
| JsonLdOrganization;
|
|
73
|
+
|
|
74
|
+
function buildJsonLd(input: JsonLdInput): Record<string, unknown> {
|
|
75
|
+
switch (input.type) {
|
|
76
|
+
case 'article':
|
|
77
|
+
return {
|
|
78
|
+
'@context': 'https://schema.org',
|
|
79
|
+
'@type': 'Article',
|
|
80
|
+
headline: input.title,
|
|
81
|
+
description: input.description,
|
|
82
|
+
url: input.url,
|
|
83
|
+
...(input.imageUrl ? { image: input.imageUrl } : {}),
|
|
84
|
+
author: {
|
|
85
|
+
'@type': 'Person',
|
|
86
|
+
name: input.authorName,
|
|
87
|
+
url: input.authorUrl,
|
|
88
|
+
},
|
|
89
|
+
datePublished: input.publishedAt,
|
|
90
|
+
dateModified: input.updatedAt,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
case 'howto':
|
|
94
|
+
return {
|
|
95
|
+
'@context': 'https://schema.org',
|
|
96
|
+
'@type': 'HowTo',
|
|
97
|
+
name: input.title,
|
|
98
|
+
description: input.description,
|
|
99
|
+
url: input.url,
|
|
100
|
+
...(input.imageUrl ? { image: input.imageUrl } : {}),
|
|
101
|
+
author: {
|
|
102
|
+
'@type': 'Person',
|
|
103
|
+
name: input.authorName,
|
|
104
|
+
url: input.authorUrl,
|
|
105
|
+
},
|
|
106
|
+
...(input.estimatedTime ? { totalTime: input.estimatedTime } : {}),
|
|
107
|
+
...(input.estimatedCost
|
|
108
|
+
? { estimatedCost: { '@type': 'MonetaryAmount', value: input.estimatedCost, currency: 'USD' } }
|
|
109
|
+
: {}),
|
|
110
|
+
...(input.steps?.length
|
|
111
|
+
? {
|
|
112
|
+
step: input.steps.map((s, i) => ({
|
|
113
|
+
'@type': 'HowToStep',
|
|
114
|
+
position: i + 1,
|
|
115
|
+
name: s.name,
|
|
116
|
+
text: s.text,
|
|
117
|
+
})),
|
|
118
|
+
}
|
|
119
|
+
: {}),
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
case 'course':
|
|
123
|
+
return {
|
|
124
|
+
'@context': 'https://schema.org',
|
|
125
|
+
'@type': 'Course',
|
|
126
|
+
name: input.title,
|
|
127
|
+
description: input.description,
|
|
128
|
+
url: input.url,
|
|
129
|
+
...(input.imageUrl ? { image: input.imageUrl } : {}),
|
|
130
|
+
provider: {
|
|
131
|
+
'@type': 'Organization',
|
|
132
|
+
name: input.providerName,
|
|
133
|
+
sameAs: input.providerUrl,
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
case 'video':
|
|
138
|
+
return {
|
|
139
|
+
'@context': 'https://schema.org',
|
|
140
|
+
'@type': 'VideoObject',
|
|
141
|
+
name: input.title,
|
|
142
|
+
description: input.description,
|
|
143
|
+
url: input.url,
|
|
144
|
+
...(input.thumbnailUrl ? { thumbnailUrl: input.thumbnailUrl } : {}),
|
|
145
|
+
uploadDate: input.uploadDate,
|
|
146
|
+
...(input.duration ? { duration: input.duration } : {}),
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
case 'person':
|
|
150
|
+
return {
|
|
151
|
+
'@context': 'https://schema.org',
|
|
152
|
+
'@type': 'Person',
|
|
153
|
+
name: input.name,
|
|
154
|
+
url: input.url,
|
|
155
|
+
...(input.imageUrl ? { image: input.imageUrl } : {}),
|
|
156
|
+
...(input.description ? { description: input.description } : {}),
|
|
157
|
+
...(input.jobTitle ? { jobTitle: input.jobTitle } : {}),
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
case 'organization':
|
|
161
|
+
return {
|
|
162
|
+
'@context': 'https://schema.org',
|
|
163
|
+
'@type': 'Organization',
|
|
164
|
+
name: input.name,
|
|
165
|
+
url: input.url,
|
|
166
|
+
...(input.logoUrl ? { logo: input.logoUrl } : {}),
|
|
167
|
+
...(input.description ? { description: input.description } : {}),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export function useJsonLd(input: JsonLdInput): void {
|
|
173
|
+
const jsonLd = buildJsonLd(input);
|
|
174
|
+
|
|
175
|
+
useHead({
|
|
176
|
+
script: [
|
|
177
|
+
{
|
|
178
|
+
type: 'application/ld+json',
|
|
179
|
+
innerHTML: JSON.stringify(jsonLd),
|
|
180
|
+
},
|
|
181
|
+
],
|
|
182
|
+
});
|
|
183
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Markdown import composable — converts markdown to blocks and handles image uploads.
|
|
3
|
+
*/
|
|
4
|
+
import { markdownToBlockTuples } from '@commonpub/editor';
|
|
5
|
+
import type { BlockTuple } from '@commonpub/editor';
|
|
6
|
+
import type { BlockEditor } from './useBlockEditor';
|
|
7
|
+
|
|
8
|
+
export function useMarkdownImport(blockEditor: BlockEditor) {
|
|
9
|
+
const importing = ref(false);
|
|
10
|
+
const progress = ref({ total: 0, uploaded: 0 });
|
|
11
|
+
|
|
12
|
+
async function importMarkdown(md: string, mode: 'append' | 'replace' = 'append'): Promise<void> {
|
|
13
|
+
importing.value = true;
|
|
14
|
+
progress.value = { total: 0, uploaded: 0 };
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const tuples = markdownToBlockTuples(md);
|
|
18
|
+
if (!tuples.length) return;
|
|
19
|
+
|
|
20
|
+
const editor = blockEditor;
|
|
21
|
+
|
|
22
|
+
if (mode === 'replace') {
|
|
23
|
+
editor.clearBlocks();
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Insert blocks sequentially, tracking position for correct ordering
|
|
27
|
+
let insertAt: number | undefined;
|
|
28
|
+
if (mode === 'append') {
|
|
29
|
+
insertAt = editor.blocks.value.length;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
for (const [type, content] of tuples) {
|
|
33
|
+
editor.addBlock(type, content as Record<string, unknown>, insertAt);
|
|
34
|
+
if (insertAt !== undefined) insertAt++;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Find image blocks with remote URLs and upload them
|
|
38
|
+
const imageBlocks = [...editor.blocks.value].filter(
|
|
39
|
+
b => b.type === 'image' && b.content.src && isRemoteUrl(b.content.src as string),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
if (imageBlocks.length > 0) {
|
|
43
|
+
progress.value.total = imageBlocks.length;
|
|
44
|
+
|
|
45
|
+
for (const block of imageBlocks) {
|
|
46
|
+
try {
|
|
47
|
+
const result = await $fetch<{ url: string }>('/api/files/upload-from-url', {
|
|
48
|
+
method: 'POST',
|
|
49
|
+
body: { url: block.content.src, purpose: 'content' },
|
|
50
|
+
});
|
|
51
|
+
editor.updateBlock(block.id, { ...block.content, src: result.url });
|
|
52
|
+
} catch {
|
|
53
|
+
// Non-fatal — remote URL stays in place
|
|
54
|
+
console.warn(`[md-import] Failed to upload image: ${block.content.src}`);
|
|
55
|
+
}
|
|
56
|
+
progress.value.uploaded++;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
} finally {
|
|
60
|
+
importing.value = false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function importFile(file: File, mode: 'append' | 'replace' = 'append'): Promise<void> {
|
|
65
|
+
const text = await file.text();
|
|
66
|
+
return importMarkdown(text, mode);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return { importing, progress, importMarkdown, importFile };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function isRemoteUrl(url: string): boolean {
|
|
73
|
+
if (!url.startsWith('http')) return false;
|
|
74
|
+
// Skip URLs that are already on our S3 bucket
|
|
75
|
+
if (url.includes('digitaloceanspaces.com')) return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { ContentViewData } from './useEngagement';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Transforms federated content API response into ContentViewData for view components.
|
|
5
|
+
* Handles block content parsing, metadata extraction, and actor profile mapping.
|
|
6
|
+
*/
|
|
7
|
+
export function useMirrorContent(fedContent: Ref<Record<string, unknown> | null>) {
|
|
8
|
+
const contentType = computed(() => {
|
|
9
|
+
const t = (fedContent.value?.cpubType as string) || (fedContent.value?.apType as string)?.toLowerCase() || 'article';
|
|
10
|
+
return t;
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const actor = computed(() => fedContent.value?.actor as Record<string, unknown> | null);
|
|
14
|
+
|
|
15
|
+
const transformedContent = computed<ContentViewData | null>(() => {
|
|
16
|
+
const fc = fedContent.value;
|
|
17
|
+
if (!fc) return null;
|
|
18
|
+
|
|
19
|
+
const title = (fc.title as string) || 'Untitled';
|
|
20
|
+
|
|
21
|
+
// Parse block content: may be BlockTuple JSON or raw HTML from federation
|
|
22
|
+
let content: unknown = fc.content;
|
|
23
|
+
if (typeof content === 'string') {
|
|
24
|
+
const trimmed = content.trim();
|
|
25
|
+
if (trimmed.startsWith('[[') || trimmed.startsWith('[["')) {
|
|
26
|
+
try { content = JSON.parse(trimmed); } catch { /* keep as string */ }
|
|
27
|
+
}
|
|
28
|
+
// If still a string (HTML from federation), wrap as BlockTuple array
|
|
29
|
+
if (typeof content === 'string' && content.trim()) {
|
|
30
|
+
content = [['paragraph', { html: content }]];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Extract CommonPub metadata (difficulty, cost, parts) if available
|
|
35
|
+
const meta = (fc.cpubMetadata as Record<string, unknown>) || null;
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
id: fc.id as string,
|
|
39
|
+
type: contentType.value,
|
|
40
|
+
title,
|
|
41
|
+
slug: title.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/(^-|-$)/g, ''),
|
|
42
|
+
subtitle: null,
|
|
43
|
+
description: (fc.summary as string) || null,
|
|
44
|
+
content,
|
|
45
|
+
coverImageUrl: (fc.coverImageUrl as string) || null,
|
|
46
|
+
category: null,
|
|
47
|
+
difficulty: (meta?.difficulty as string) || null,
|
|
48
|
+
buildTime: (meta?.buildTime as string) || null,
|
|
49
|
+
estimatedCost: (meta?.estimatedCost as string) || null,
|
|
50
|
+
status: 'published',
|
|
51
|
+
visibility: 'public',
|
|
52
|
+
isFeatured: false,
|
|
53
|
+
seoDescription: null,
|
|
54
|
+
previewToken: null,
|
|
55
|
+
parts: Array.isArray(meta?.parts) ? meta.parts as ContentViewData['parts'] : null,
|
|
56
|
+
sections: null,
|
|
57
|
+
viewCount: 0,
|
|
58
|
+
likeCount: (fc.localLikeCount as number) ?? 0,
|
|
59
|
+
commentCount: (fc.localCommentCount as number) ?? 0,
|
|
60
|
+
forkCount: 0,
|
|
61
|
+
publishedAt: (fc.publishedAt as string) || null,
|
|
62
|
+
createdAt: (fc.receivedAt as string) || new Date().toISOString(),
|
|
63
|
+
updatedAt: (fc.receivedAt as string) || new Date().toISOString(),
|
|
64
|
+
licenseType: null,
|
|
65
|
+
series: null,
|
|
66
|
+
estimatedMinutes: null,
|
|
67
|
+
tags: Array.isArray(fc.tags) ? (fc.tags as Array<{ type: string; name: string }>).map(t => ({ id: '', name: t.name, slug: t.name.toLowerCase().replace(/\s+/g, '-') })) : [],
|
|
68
|
+
author: {
|
|
69
|
+
id: '',
|
|
70
|
+
username: (actor.value?.preferredUsername as string) || 'unknown',
|
|
71
|
+
displayName: (actor.value?.displayName as string) || (actor.value?.preferredUsername as string) || 'Unknown',
|
|
72
|
+
avatarUrl: (actor.value?.avatarUrl as string) || null,
|
|
73
|
+
},
|
|
74
|
+
buildCount: 0,
|
|
75
|
+
bookmarkCount: 0,
|
|
76
|
+
} satisfies ContentViewData;
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const viewComponent = computed(() => {
|
|
80
|
+
switch (contentType.value) {
|
|
81
|
+
case 'article': return resolveComponent('ViewsArticleView');
|
|
82
|
+
case 'blog': return resolveComponent('ViewsBlogView');
|
|
83
|
+
case 'explainer': return resolveComponent('ViewsExplainerView');
|
|
84
|
+
case 'project': return resolveComponent('ViewsProjectView');
|
|
85
|
+
default: return null;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const originDomain = computed(() => (fedContent.value?.originDomain as string) || 'unknown');
|
|
90
|
+
const originUrl = computed(() => (fedContent.value?.url as string) || null);
|
|
91
|
+
const authorHandle = computed(() => {
|
|
92
|
+
if (!actor.value) return '';
|
|
93
|
+
return `@${actor.value.preferredUsername ?? 'unknown'}@${actor.value.instanceDomain ?? ''}`;
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return {
|
|
97
|
+
contentType,
|
|
98
|
+
actor,
|
|
99
|
+
transformedContent,
|
|
100
|
+
viewComponent,
|
|
101
|
+
originDomain,
|
|
102
|
+
originUrl,
|
|
103
|
+
authorHandle,
|
|
104
|
+
};
|
|
105
|
+
}
|