Commit cc9233fd authored by Élodie Thiéblin's avatar Élodie Thiéblin
Browse files

[DublinCore] Add markdown converter when format is specified

parent c87beef3c4ea
......@@ -133,6 +133,13 @@ export const ALIASES = [
[
"http://ns.cubicweb.org/cubicweb/0.0/BlogEntry",
"http://rdfs.org/sioc/types#BlogPost"
],
// format
[
"http://purl.org/dc/elements/1.1/format",
"http://purl.org/dc/terms/format",
"http://ns.cubicweb.org/cubicweb/0.0/content_format"
]
];
......
import * as React from "react";
import { DublinCoreElement } from "./dcschema";
import * as ReactMarkdown from "react-markdown";
export const DublinCoreElementComponent: React.FC<{
dcelement: DublinCoreElement;
}> = ({ dcelement }) => (
<>
<h1>{dcelement.title}</h1>
<div>{dcelement.creator}</div>
<div>{dcelement.date}</div>
<div>{dcelement.description}</div>
</>
);
}> = ({ dcelement }) => {
let contentDisplay = <div>{dcelement.description}</div>;
if (dcelement.contentType === "text/markdown") {
contentDisplay = <ReactMarkdown source={dcelement.description} />;
}
return (
<>
<h1>{dcelement.title}</h1>
<div>{dcelement.creator}</div>
<div>{dcelement.date}</div>
{contentDisplay}
</>
);
};
......@@ -9,6 +9,7 @@ export interface DublinCoreElement extends rdfMeta.Loadable {
description: string;
creator: string;
date: string;
contentType: string;
}
/**
......@@ -29,7 +30,11 @@ DCE_METACLASS.properties = [
"creator",
"http://purl.org/dc/elements/1.1/creator"
),
new rdfMeta.MetaPropertyData("date", "http://purl.org/dc/elements/1.1/date")
new rdfMeta.MetaPropertyData("date", "http://purl.org/dc/elements/1.1/date"),
new rdfMeta.MetaPropertyData(
"contentType",
"http://purl.org/dc/elements/1.1/format"
)
];
/**
......
......@@ -77,7 +77,7 @@ class DCElementRendering implements implementation.ViewImplementation {
const dctitles = entity.getValuesForS("http://purl.org/dc/terms/title");
if (dctitles.length !== 0) {
return 10;
return 11;
}
return implementation.VIEW_PRIORITY_INAPPROPRIATE;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment