Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol diffdown.com

Add 'Documents Shared with You' section to dashboard

+27 -5
+27 -5
templates/documents.html
··· 11 11 <a href="/docs/new" class="btn">New Document</a> 12 12 </div> 13 13 </div> 14 - {{with .Content}} 15 14 <div class="repo-list" id="doc-list"> 16 - {{range .}} 15 + {{range .Content.OwnDocs}} 17 16 <a href="/docs/{{.RKey}}" class="repo-card"> 18 17 <h3>{{.Title}}</h3> 19 18 {{if .UpdatedAt}} ··· 29 28 </div> 30 29 {{end}} 31 30 </div> 31 + 32 + {{if .Content.SharedDocs}} 33 + <div class="dashboard-header" style="margin-top:2rem"> 34 + <h2>Documents Shared with You</h2> 35 + </div> 36 + <div class="repo-list" id="shared-list"> 37 + {{range .Content.SharedDocs}} 38 + <a href="/docs/{{.OwnerDID}}/{{.RKey}}" class="repo-card"> 39 + <h3>{{.Title}}</h3> 40 + {{if .UpdatedAt}} 41 + <time>Updated {{.UpdatedAt | fmtdate}}</time> 42 + {{else}} 43 + <time>Created {{.CreatedAt | fmtdate}}</time> 44 + {{end}} 45 + </a> 46 + {{end}} 47 + </div> 32 48 {{end}} 33 49 </div> 34 50 {{end}} ··· 36 52 <script> 37 53 (function() { 38 54 function setView(v) { 39 - var list = document.getElementById('doc-list'); 55 + var lists = [document.getElementById('doc-list'), document.getElementById('shared-list')]; 40 56 var btnCards = document.getElementById('btn-cards'); 41 57 var btnList = document.getElementById('btn-list'); 58 + lists.forEach(function(list) { 59 + if (!list) return; 60 + if (v === 'list') { 61 + list.classList.add('list-view'); 62 + } else { 63 + list.classList.remove('list-view'); 64 + } 65 + }); 42 66 if (v === 'list') { 43 - list.classList.add('list-view'); 44 67 btnList.classList.add('active'); 45 68 btnCards.classList.remove('active'); 46 69 } else { 47 - list.classList.remove('list-view'); 48 70 btnCards.classList.add('active'); 49 71 btnList.classList.remove('active'); 50 72 }