Skip to content

Commit

Permalink
Merge pull request #9 from datocms/customer-stories
Browse files Browse the repository at this point in the history
Customer stories
  • Loading branch information
stefanoverna authored Nov 20, 2024
2 parents 70138e9 + b188b89 commit 9a67b0a
Show file tree
Hide file tree
Showing 7 changed files with 673 additions and 0 deletions.
139 changes: 139 additions & 0 deletions src/pages/customer-stories/[slug]/_graphql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
import { CodesandboxEmbedBlockFragment } from '~/components/blocks/CodesandboxEmbedBlock/graphql';
import { CtaButtonFragment } from '~/components/blocks/CtaButton/graphql';
import { DemoFragment } from '~/components/blocks/Demo/graphql';
import { ImageFragment } from '~/components/blocks/Image/graphql';
import { InternalVideoFragment } from '~/components/blocks/InternalVideo/graphql';
import { MultipleDemosBlockFragment } from '~/components/blocks/MultipleDemosBlock/graphql';
import { QuestionAnswerFragment } from '~/components/blocks/QuestionAnswer/graphql';
import { ShowcaseProjectBlockFragment } from '~/components/blocks/ShowcaseProjectBlock/graphql';
import { TableFragment } from '~/components/blocks/Table/graphql';
import { TutorialVideoFragment } from '~/components/blocks/TutorialVideo/graphql';
import { VideoFragment } from '~/components/blocks/Video/graphql';
import { BlogPostInlineFragment } from '~/components/inlineRecords/BlogPostInline/graphql';
import { ChangelogEntryInlineFragment } from '~/components/inlineRecords/ChangelogEntryInline/graphql';
import { BlogPostLinkFragment } from '~/components/linkToRecords/BlogPostLink/graphql';
import { ChangelogEntryLinkFragment } from '~/components/linkToRecords/ChangelogEntryLink/graphql';
import { ResponsiveImageFragment } from '~/components/ResponsiveImage/graphql';
import { TagFragment } from '~/lib/datocms/commonFragments';
import { executeQueryOutsideAstro } from '~/lib/datocms/executeQuery';
import {
CustomerStoryUrlFragment,
buildUrlForCustomerStory,
} from '~/lib/datocms/gqlUrlBuilder/customerStory';
import { graphql } from '~/lib/datocms/graphql';
import type { BuildSitemapUrlsFn } from '~/pages/sitemap.xml';

export const query = graphql(
/* GraphQL */ `
query PostQuery($slug: String!) {
post: customerStory(filter: { slug: { eq: $slug } }) {
seo: _seoMetaTags {
...TagFragment
}
title
seoH1
canonicalUrl
yoastAnalysis
content {
value
links {
... on RecordInterface {
id
__typename
}
...BlogPostInlineFragment
...ChangelogEntryInlineFragment
...BlogPostLinkFragment
...ChangelogEntryLinkFragment
}
blocks {
... on RecordInterface {
id
__typename
}
... on DemoRecord {
...DemoFragment
}
... on ImageRecord {
...ImageFragment
}
... on QuestionAnswerRecord {
...QuestionAnswerFragment
}
... on MultipleDemosBlockRecord {
...MultipleDemosBlockFragment
}
... on InternalVideoRecord {
...InternalVideoFragment
}
... on VideoRecord {
...VideoFragment
}
... on CodesandboxEmbedBlockRecord {
...CodesandboxEmbedBlockFragment
}
... on CtaButtonRecord {
...CtaButtonFragment
}
... on TutorialVideoRecord {
...TutorialVideoFragment
}
... on ShowcaseProjectBlockRecord {
...ShowcaseProjectBlockFragment
}
... on TableRecord {
...TableFragment
}
}
}
people {
name
title
company
avatar {
responsiveImage(imgixParams: { auto: format, w: 50, h: 50, fit: crop, crop: faces }) {
...ResponsiveImageFragment
}
}
}
}
}
`,
[
TagFragment,
ResponsiveImageFragment,
TableFragment,
InternalVideoFragment,
DemoFragment,
MultipleDemosBlockFragment,
VideoFragment,
ImageFragment,
TutorialVideoFragment,
CodesandboxEmbedBlockFragment,
CtaButtonFragment,
ShowcaseProjectBlockFragment,
QuestionAnswerFragment,
BlogPostInlineFragment,
ChangelogEntryInlineFragment,
BlogPostLinkFragment,
ChangelogEntryLinkFragment,
],
);

export const buildSitemapUrls: BuildSitemapUrlsFn = async ({ includeDrafts }) => {
const { entries } = await executeQueryOutsideAstro(
graphql(
/* GraphQL */ `
query BuildSitemapUrls {
entries: allCustomerStories(first: 500) {
...CustomerStoryUrlFragment
}
}
`,
[CustomerStoryUrlFragment],
),
{ includeDrafts },
);

return entries.map(buildUrlForCustomerStory);
};
127 changes: 127 additions & 0 deletions src/pages/customer-stories/[slug]/_style.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
.postWrapper {
position: relative;
}

.info {
align-items: center;
color: var(--light-body-color);
display: flex;
flex-direction: column;
font-size: 0.9em;
margin-bottom: 90px;
text-align: center;

.avatarWrapper {
align-items: center;
display: flex;
justify-content: center;
margin-bottom: 20px;
}

.avatar {
border-radius: 50%;
border: 2px solid #fff;
height: 50px;
margin-left: -6px;
min-width: 50px;
overflow: hidden;
width: 50px;
}

p {
max-width: 850px;
}
}

.body {
font-size: rfs(21px);
line-height: 1.6;
letter-spacing: -0.02em;
max-width: 850px;
margin: 0 auto;
font-family: var(--font-serif);

prose-island {
font-family: var(--font-sans);
}

h1,
h2,
h3,
h4,
h5,
h6 {
font-family: var(--font-sans);
}

> figure {
margin: 3em 0;

@media (width > 1100px) {
margin-left: -80px;
margin-right: -80px;
}

figcaption {
color: var(--light-body-color);
font-size: 0.8em;
margin-top: 10px;
text-align: center;
font-family: var(--font-sans);
}
}
}

.tocWrapper {
bottom: 0;
display: none;
left: 0;
position: absolute;
top: 0;
width: 340px;

@media (min-width: 1900px) {
display: block;
}
}

.toc {
border-left: 10px solid var(--accent-color);
left: 0;
padding: 40px 0 40px 40px;
position: sticky;
top: 50%;
transform: translateY(-50%);

ul {
font-size: 15px;
line-height: 1.2;
list-style-type: none;
margin: 0;
padding: 0;
}

li {
margin-bottom: 10px;
overflow: hidden;
text-overflow: clip ellipsis;
white-space: nowrap;
}

a {
color: inherit;
text-decoration: none;

&:hover {
text-decoration: underline;
}
}
}

.tocTitle {
color: var(--light-body-color);
font-size: 23px;
font-weight: bold;
letter-spacing: -0.04em;
margin-bottom: 15px;
}
Loading

0 comments on commit 9a67b0a

Please sign in to comment.