Skip to content

Commit 4fec19a

Browse files
committed
clean up rss feed query and allow capitalized publish tag
1 parent a128879 commit 4fec19a

14 files changed

+333
-89
lines changed

src/App.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const PostRoot = ({
134134
}
135135
const post = idx(props, _ => _.gitHub.repository.issue);
136136
const labels = idx(post, _ => _.labels.nodes) || [];
137-
if (!post || !labels.map(l => l.name).includes('publish')) {
137+
if (!post || !labels.map(l => l.name.toLowerCase()).includes('publish')) {
138138
return <ErrorBox error={new Error('Missing post.')} />;
139139
} else {
140140
return (

src/Post.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {lowerCase, sentenceCase} from 'change-case';
2525
import type {Post_post} from './__generated__/Post_post.graphql';
2626

2727
// n.b. no accessToken in the persistedQueryConfiguration for these mutations,
28-
// because we want to add reactions on behalf of the logged-in user, not the
28+
// because we want to add reactions on behalf of the logged-in user, not the
2929
// persisted auth
3030
const addReactionMutation = graphql`
3131
mutation Post_AddReactionMutation($input: GitHubAddReactionInput!)
@@ -344,6 +344,19 @@ export const ReactionBar = ({
344344
);
345345
};
346346

347+
export function postUrl({
348+
post,
349+
viewComments,
350+
}: {
351+
post: {
352+
+number: number,
353+
+repository: {+owner: {+login: string}, +name: string},
354+
},
355+
viewComments?: boolean,
356+
}) {
357+
return `/post/${post.number}${viewComments ? '#comments' : ''}`;
358+
}
359+
347360
const Post = ({relay, post}: Props) => {
348361
const {error: notifyError} = React.useContext(NotificationContext);
349362
const [showReactionPopover, setShowReactionPopover] = React.useState(false);
@@ -360,7 +373,7 @@ const Post = ({relay, post}: Props) => {
360373
<Heading level={3} margin="none">
361374
<Link
362375
style={{color: 'inherit'}}
363-
to={`/post/${post.number}`}
376+
to={postUrl({post})}
364377
onMouseOver={() =>
365378
fetchQuery(relay.environment, postRootQuery, {
366379
issueNumber: post.number,
@@ -375,7 +388,7 @@ const Post = ({relay, post}: Props) => {
375388
{formatDate(new Date(post.createdAt), 'MMM do, yyyy')}
376389
</Text>
377390
<Text size="xsmall">
378-
<Link to={`/post/${post.number}#comments`}>view comments</Link>
391+
<Link to={postUrl({post, viewComments: true})}>view comments</Link>
379392
</Text>
380393
</Box>
381394
<Text size="small">
@@ -449,6 +462,13 @@ export default createFragmentContainer(Post, {
449462
commentsCount: comments {
450463
totalCount
451464
}
465+
repository {
466+
name
467+
owner {
468+
login
469+
avatarUrl(size: 192)
470+
}
471+
}
452472
}
453473
`,
454474
});

src/Posts.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export default createPaginationContainer(
8181
first: $count
8282
after: $cursor
8383
orderBy: $orderBy
84-
labels: ["publish"]
84+
labels: ["publish", "Publish"]
8585
) @connection(key: "Posts_posts_issues") {
8686
edges {
8787
node {

src/RssFeed.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ import {fetchQuery} from 'react-relay';
99
import type {RssFeed_QueryResponse} from './__generated__/RssFeed_Query.graphql';
1010

1111
const feedQuery = graphql`
12-
query RssFeed_Query
12+
query RssFeed_Query($repoOwner: String!, $repoName: String!)
1313
@persistedQueryConfiguration(
1414
accessToken: {environmentVariable: "OG_GITHUB_TOKEN"}
15+
fixedVariables: {environmentVariable: "REPOSITORY_FIXED_VARIABLES"}
1516
) {
1617
gitHub {
17-
repository(name: "onegraph-changelog", owner: "onegraph") {
18+
repository(name: $repoName, owner: $repoOwner) {
1819
issues(
1920
first: 20
2021
orderBy: {direction: DESC, field: CREATED_AT}
21-
labels: ["publish"]
22+
labels: ["publish", "Publish"]
2223
) {
2324
nodes {
2425
id
@@ -40,6 +41,7 @@ const feedQuery = graphql`
4041
}
4142
`;
4243

44+
// TODO: make these fields configurable
4345
export async function buildFeed() {
4446
const data: RssFeed_QueryResponse = await fetchQuery(
4547
environment,

src/__generated__/App_Post_Query.graphql.js

Lines changed: 52 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__generated__/App_Query.graphql.js

Lines changed: 73 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__generated__/CommentsPaginationQuery.graphql.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__generated__/Comments_AddCommentMutation.graphql.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/__generated__/Post_AddReactionMutation.graphql.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)