chore: added publication
ceca6caf
6 file(s) · +32 −1
| 5 | 5 | ||
| 6 | 6 | type Props = SiteMeta; |
|
| 7 | 7 | ||
| 8 | - | const { title, description, ogImage, articleDate } = Astro.props; |
|
| 8 | + | const { title, description, ogImage, articleDate, atUri } = Astro.props; |
|
| 9 | 9 | ||
| 10 | 10 | const titleSeparator = "•"; |
|
| 11 | 11 | const siteTitle = `${title} ${titleSeparator} ${siteConfig.title}`; |
|
| 65 | 65 | <!-- RSS auto-discovery --> |
|
| 66 | 66 | <link rel="alternate" type="application/rss+xml" title={siteConfig.title} href={new URL("rss.xml", Astro.site)} |
|
| 67 | 67 | /> |
|
| 68 | + | ||
| 69 | + | <!-- Standard.site document verification --> |
|
| 70 | + | {atUri && <link rel="site.standard.document" href={atUri} />} |
|
| 68 | 71 | ||
| 69 | 72 | <link |
|
| 70 | 73 | rel="preload" |
|
| 15 | 15 | tags: z.array(z.string()).default([]).transform(removeDupsAndLowerCase), |
|
| 16 | 16 | ogImage: z.string().optional(), |
|
| 17 | 17 | hidden: z.boolean().optional().default(false), |
|
| 18 | + | atUri: z.string().optional(), |
|
| 18 | 19 | }), |
|
| 19 | 20 | }); |
|
| 20 | 21 |
| 3 | 3 | description?: string; |
|
| 4 | 4 | ogImage?: string | undefined; |
|
| 5 | 5 | articleDate?: string | undefined; |
|
| 6 | + | atUri?: string | undefined; |
|
| 6 | 7 | }; |
|
| 7 | 8 | ||
| 8 | 9 | export type { SiteMeta }; |
| 1 | + | export const prerender = true; |
|
| 2 | + | ||
| 3 | + | export async function GET() { |
|
| 4 | + | // Your DID from PDSPost.tsx |
|
| 5 | + | const DID = "did:plc:ia2zdnhjaokf5lazhxrmj6eu"; |
|
| 6 | + | ||
| 7 | + | // This should be the rkey of your actual site.standard.publication record |
|
| 8 | + | // You'll need to create this record in your PDS first |
|
| 9 | + | const PUBLICATION_RKEY = "self"; |
|
| 10 | + | ||
| 11 | + | const atUri = `at://${DID}/site.standard.publication/${PUBLICATION_RKEY}`; |
|
| 12 | + | ||
| 13 | + | return new Response(atUri, { |
|
| 14 | + | status: 200, |
|
| 15 | + | headers: { |
|
| 16 | + | "Content-Type": "text/plain", |
|
| 17 | + | }, |
|
| 18 | + | }); |
|
| 19 | + | } |
| 26 | 26 | let isPost = false; |
|
| 27 | 27 | let postText = ""; |
|
| 28 | 28 | let imagesHTML = ""; |
|
| 29 | + | let atUri = ""; |
|
| 29 | 30 | ||
| 30 | 31 | try { |
|
| 31 | 32 | let documentFound = false; |
|
| 60 | 61 | title = doc.title || "Post"; |
|
| 61 | 62 | description = doc.content?.markdown?.slice(0, 160) || description; |
|
| 62 | 63 | publishedAt = new Date(doc.publishedAt).toLocaleDateString(); |
|
| 64 | + | atUri = matchingDoc.uri; |
|
| 63 | 65 | ||
| 64 | 66 | if (doc.content && doc.content.markdown) { |
|
| 65 | 67 | contentHTML = md.render(doc.content.markdown); |
|
| 87 | 89 | title = doc.title || "Post"; |
|
| 88 | 90 | description = doc.content?.markdown?.slice(0, 160) || description; |
|
| 89 | 91 | publishedAt = new Date(doc.publishedAt).toLocaleDateString(); |
|
| 92 | + | atUri = `at://${DID}/site.standard.document/${slug}`; |
|
| 90 | 93 | ||
| 91 | 94 | if (doc.content && doc.content.markdown) { |
|
| 92 | 95 | contentHTML = md.render(doc.content.markdown); |
|
| 156 | 159 | const meta = { |
|
| 157 | 160 | title, |
|
| 158 | 161 | description, |
|
| 162 | + | atUri, |
|
| 159 | 163 | }; |
|
| 160 | 164 | --- |
|
| 161 | 165 | ||
| 127 | 127 | collection: "site.standard.document", |
|
| 128 | 128 | record: { |
|
| 129 | 129 | $type: "site.standard.document", |
|
| 130 | + | publication: { |
|
| 131 | + | uri: `at://${session.did}/site.standard.publication/self`, |
|
| 132 | + | }, |
|
| 130 | 133 | title: body.title.trim(), |
|
| 131 | 134 | site: "https://stevedylan.dev", |
|
| 132 | 135 | ...(body.path && { path: body.path.trim() }), |