Skip to content

Commit

Permalink
Add published URL and source to document metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
allanlasser committed Dec 10, 2024
1 parent dcfe1bf commit d4876f4
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/lib/components/documents/Metadata.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import { LANGUAGE_MAP } from "@/config/config.js";
import { userOrgString } from "$lib/api/documents";
import Metadata from "../common/Metadata.svelte";
import { LinkExternal16 } from "svelte-octicons";
export let document: Document;
export let text: Maybe<DocumentText>;
Expand Down Expand Up @@ -44,6 +45,19 @@
</script>

<div class="meta">
{#if document.published_url}
<Metadata key={$_("edit.fields.published_url")}>
<a href={document.published_url} class="publishedUrl" target="_blank">
{new URL(document.published_url).hostname}
<LinkExternal16 height={12} width={12} />
</a>
</Metadata>
{/if}
{#if document.source}
<Metadata key={$_("edit.fields.source")}>
{document.source}
</Metadata>
{/if}
<Metadata key={$_("sidebar.contributed")}>
{userOrgString(document)}
</Metadata>
Expand All @@ -70,4 +84,10 @@
gap: 1rem;
padding: 0 0.5rem 1rem 0;
}
.publishedUrl {
display: flex;
align-items: center;
fill: var(--blue-3);
gap: 0.25rem;
}
</style>
31 changes: 31 additions & 0 deletions src/lib/components/documents/stories/Metadata.stories.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<script context="module" lang="ts">
import { Story, Template } from "@storybook/addon-svelte-csf";
import MetadataComponent from "../Metadata.svelte";
import type { Document } from "@/lib/api/types";
import doc from "@/test/fixtures/documents/document-expanded.json";
const document = doc as Document;
export const meta = {
title: "Components / Documents / Metadata",
component: MetadataComponent,
parameters: {
layout: "centered",
},
};
const args = {
document: {
...document,
source: "NYPD",
published_url:
"https://www.nytimes.com/live/2024/12/10/nyregion/unitedhealthcare-ceo-luigi-mangione",
},
};
</script>

<Template let:args>
<MetadataComponent {...args} />
</Template>

<Story name="Metadata" {args} />

0 comments on commit d4876f4

Please sign in to comment.