Giter VIP home page Giter VIP logo

Comments (2)

evanwill avatar evanwill commented on July 17, 2024

example:
Aerial has county and region both schema_map to contentLocation.
Which results in repeating contentLocation key, like:

 {
    "@context": "http://schema.org",
    "@type": "CreativeWork",
    "dateCreated": "1934",
    "description": "Black and white 1934 vertical air photo taken from aircraft, by the Washington National Guard.",
    "contentLocation": "Clearwater County (Idaho)",
    "contentLocation": "Sheep Mountain",
    "encodingFormat": "image/jpeg",
    "isPartOf": "Idaho Historical Aerial Photographs",
    "image": "https://digital.lib.uidaho.edu/digital/iiif/uiiap/256/full/max/0/default.jpg",
    "thumbnailUrl": "https://digital.lib.uidaho.edu/utils/getthumbnail/collection/uiiap/id/256",
    "url": "https://www.lib.uidaho.edu/digital/aerial/items/aerial256.html"
}

Should look like:

 {
    "@context": "http://schema.org",
    "@type": "CreativeWork",
    "dateCreated": "1934",
    "description": "Black and white 1934 vertical air photo taken from aircraft, by the Washington National Guard.",
    "contentLocation": ["Clearwater County (Idaho)","Sheep Mountain"],
    "encodingFormat": "image/jpeg",
    "isPartOf": "Idaho Historical Aerial Photographs",
    "image": "https://digital.lib.uidaho.edu/digital/iiif/uiiap/256/full/max/0/default.jpg",
    "thumbnailUrl": "https://digital.lib.uidaho.edu/utils/getthumbnail/collection/uiiap/id/256",
    "url": "https://www.lib.uidaho.edu/digital/aerial/items/aerial256.html"
}

Not impossible, but involves adding a ton of Liquid to catch repeating schema_map content.

from collectionbuilder-cdm-template.

evanwill avatar evanwill commented on July 17, 2024

example insane Liquid:

<script type="application/ld+json">
{ 
    "@context": "http://schema.org",
    "@type": "CreativeWork",
    {%- assign schema = site.data.config-metadata | where_exp: 'item', 'item.schema_map != nil' | group_by: "schema_map" -%}
    {%- assign schema-fields = schema | map: 'name' | uniq -%}
    {%- for f in schema-fields -%}
    {%- assign fields = schema | where: 'name',f | map: 'items' | map: 'field' -%}
    {% if fields.size > 1 %}
    {% capture values %}{% for t in fields %}{% if page[t] %}{{ page[t] }}||{% endif %}{% endfor %}{%- endcapture -%}
    {%- assign values = values | split: "||" | compact -%}
    {% if values != empty %}"{{ f }}": {{ values | jsonify }},{% endif %}
    {%- else -%}
    {% if page[fields.first] %}"{{ f }}": {{ page[fields.first] | jsonify }},{%- endif -%}
    {%- endif -%}
    {% endfor %}
    "isPartOf": {{ site.title | jsonify }},
    {% if page.format contains 'image' %}"image": "{% include image/original.html %}",{% endif %}
    "thumbnailUrl": "{% include image/thumb.html %}",
    "url": {{ page.url | absolute_url | jsonify }}
}
</script> 

from collectionbuilder-cdm-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.