SIMITClub / simitclub.github.io

SIM IT Club Website
https://simitclub.github.io/
12 stars 18 forks source link

Design schema for site content #47

Open mkamsani opened 1 year ago

mkamsani commented 1 year ago

Schemas enforce certain metadata in contents of the site.

See src/content/config.ts for context:

classDiagram
    direction BT

    class Position {
        String committee
        String role
    }

    class Image {
        String url
        String alt
    }

    class Member {
        Id     m_slug
        String m_nameFirst
        String m_nameLast
        String m_bio
        Enum m_status[alumni, current]
    }

    class Post {
        Id p_slug
        StringArr p_authors
        StringArr p_categories DEFAULT [  ]
        StringArr p_posts
        String p_title
        String p_description
        Boolean p_draft
        Date p_published
        Date p_updated
    }

    class Category {
        Id c_slug
        String c_title
        String c_description
    }

    Post --> Member: p_authors REF m_slug 
    Post --> Category: p_categories REF c_slug
    Position --* Member: Aggregation
    Image --* Member: Composition
    Image --* Post: Composition

The above schema needs to be converted to content collections format.

Some of these values can be set as optional.

mkamsani commented 1 year ago

Updated date improvements

Manually editing the last updated date may (eventually) become difficult to maintain.

Linking to revision history

The last updated date p_updated of a published blog post can be replaced with a link to revision history:

https://ben.balter.com/2023/03/02/github-for-non-technical-roles/

In the post above, Ctrl + F "View revision history" for an example of linking a blog post to its file history.

Ideally, the file names for blog posts shouldn't be changed, once they're committed to our site.

Generation from commit log

An alternative is to embed a shell script at build time to obtain the last commit to the file:

https://github.com/shelljs/shelljs

git log -1 --format=%cd ./my-blog-post.md # /src/content/post/my-blog-post.md